akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

main(){
    int i,n,a,b,c1,c2;

    while(1){
        scanf("%d",&n);
        if(!n)break;
        a=b=0;

        for(i=0;i<n;i++){
            scanf("%d %d",&c1,&c2);
            if(c1>c2){
                a+=c1+c2;
            }else if(c1<c2){
                b+=c1+c2;
            }else{
                a+=c1;
                b+=c2;
            }
        }
        printf("%d %d\n",a,b);
    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

vector<int> calc(int N) {
    if(N == 3) {
        // cout << "2 5 63" << endl;
        return vi{2, 5, 63};
    }
    // n-=2;
    // vi ans;
    // int s = n*(n+1);
    // rep(i, n) ans.pb((i+1)*2);
    // for(int i = 3; i < 30000; i += 2) {
    //     for(int j = 3; j < i; j += 2) {
    //         if(__gcd(i, s+j) != 1 && __gcd(j, s+i) != 1) {
    //             ans.pb(i);
    //             ans.pb(j);
    //             i = INF;
    //             break;
    //         }
    //     }
    // }
    for(int m = 2; m < N; m+=2) {
        int n = N - m;
        if(n*(n+1)%3 != 0) continue;
        if(6*m-3 > 30000 || 2*n > 30000) continue;
        vi ans;
        rep(i, n) ans.pb((i+1)*2);
        rep(i, m) ans.pb(6*i+3);
        return ans;

    }
    // return ans;
    assert(false);
}

int main(){
    int n;
    cin >> n;
    auto ans = calc(n);
    rep(i, n) {
        if(i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum, a[310000], b[210000];
string str;
bool f;
char c[1100][1100];

int main() {
	cin >> m >> k;
	if ((1LL << m) <= k) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 0) {
		rep(i, 1LL << (m + 1)) {
			if (i)cout << " ";
			cout << i / 2;
		}
		cout << endl;
		return 0;
	}
	rep(i, 1LL << m) {
		if (i != k) {
			a[cnt] = i;
			cnt++;
		}
	}
	a[cnt] = k;
	cnt++;
	rep(i, 1LL << m) {
		if (k != (1LL << m) - i - 1) {
			a[cnt] = (1LL<<m)-i-1;
			cnt++;
		}
	}
	a[cnt] = k;
	cnt++;
	rep(i, 1LL << m) {
		p ^= i;
	}
	if (p != 0) {
		cout << -1 << endl;
		return 0;
	}
	rep(i, cnt) {
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int SET(int N, int pos)  {return N=N | (1<<pos);}
int RSET(int N,int pos)  {return N= N & ~(1<<pos);}
bool CHK(int N,int pos)  {return (bool)(N & (1<<pos));}

#define ll             long long
#define pll            pair<ll,ll>
#define unique(a)      a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p)     memset(v,p,sizeof v)
#define all(x)         x.begin(), x.end()
#define index(x,i)     x.find_by_order(i)
#define lesscount(x,i) x.order_of_key(i)
#define PI             acos(-1.0)
#define EPS            0.000000001
#define INF            1e18+10
#define MAX            300005
#define MOD            1000000007


signed int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(0);
	
	ll n, x;
	cin >> n;
	
	ll mx= INF, ans=0;
	for(int i=0;i<n;i++)
	{
		cin >> x;
		mx= min(x,mx);
		
		if(x>mx) continue;
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S, T, U;
    pair<int, int> num;
    cin >> S >> T;
    cin >> num.first >> num.second;
    cin >> U;
    if (U == S){
        cout << num.first - 1  << " " << num.second << endl;
    }
    else{
        cout << num.first << " " << num.second - 1 << endl;
    }
}

Measured memory_bytes: 3564
import collections

n = int(input())
S = []
for i in range(n):
    S.append(input())

a = collections.Counter(S)
m = max(a.values())
s = []
for i in a:
    if a[i] == m:
        s.append(i)
s.sort()
for i in s:
    print(i)

Measured memory_bytes: 35564
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  bool ok = 1;

  for(int i = 0; i < s.size(); i+= 2) {
    ok &= s[i] != 'L';
  }
  for(int i = 1; i < s.size(); i+= 2) {
    ok &= s[i] != 'R';
  }

  Yes(ok);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[])
  {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int area= a * b;
    int c = a + b;
    int perimeter = 2 * c;
    System.out.println(area + " " + perimeter);
  }
}



Measured memory_bytes: 26364
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

template <class T>
struct dice {
  T t,b,n,s,e,w;              // top bottom north south east west
  dice() {}
  dice(T t, T b, T n, T s, T e, T w) : t(t),b(b),n(n),s(s),e(e),w(w) {}
  void roll(T &a, T &b, T &c, T &d) { swap(a,b); swap(b,c); swap(c,d); }
  void roll_x() { roll(t, n, b, s); }
  void roll_y() { roll(t, w, b, e); }
  void roll_z() { roll(s, e, n, w); }
  void roll_d(int d) {
    if(d==0) roll(t,s,b,n);
    else if(d==1) roll(t,n,b,s);
    else if(d==2) roll(t,w,b,e);
    else roll(t,e,b,w);
  }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k=0; k<6; (k&1?roll_y():roll_x()),++k)
      for (int i=0; i<4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  void toTable(int *res) {
    res[0]=t;res[1]=b;res[2]=n;
    res[3]=s;res[4]=e;res[5]=w;
  }
};

int main() {
  int dy[] = {1,-1,0,0};
  int dx[] = {0,0,1,-1};
  dice<int> DI(1,6,2,5,4,3);
  vector<dice<int> > vs = DI.all_rolls();
  int n;
  while(cin >> n, n) {
    map<pii,pii> mp;
    REP(i,n) {
      int t, s;
      cin >> t >> s;
      dice<int> di;
      bool tmp = 0;
      //cout << "a" << endl;
      FOR(it, vs) {
        if (it->t == t && it->s == s) {
          di = *it;
          tmp = 1;
          break;
        }
      }
      //cout << "a" << endl;
      assert(tmp==1);
      int y=0,x=0;
      while(1) {
        pii now = mp[pii(y,x)];
        bool f = 0;
        for (int j=6; j>=4; --j) {
          int r[6]; di.toTable(r);
          for (int k=2;k<6;++k) {
            if (r[k] == j) {
              int yy = y+dy[k-2];
              int xx = x+dx[k-2];
              pii p = mp[pii(yy,xx)];
              if (p.first < now.first) {
                y = yy;
                x = xx;
                f = 1;
                di.roll_d(k-2);
                break;
              }
            }
          }
          if (f) break;
        }
        if (!f) break;
      }
      mp[pii(y,x)].first++;
      mp[pii(y,x)].second = di.t;
    }
    int ar[6] = {};
    FOR(it, mp) {
      pii p =  it->first ;
      pii q = it->second;
      // cout << p.first << "," << p.second << endl;
      // cout << q.first << ";" << q.second << endl;
      if (it->second.first > 0) {
        ar[it->second.second-1]++;
      }
    }
    REP(i,6) {
      if(i) cout << " ";
      cout << ar[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
/*  ex7_3
    kento_titech*/
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int row,col,i,j,*check_row,*check_col;
    char **grid;
    scanf("%d %d",&row,&col);
    grid=(char**)malloc(sizeof(char*)*(row+1));//行に関して文字列配列を動的配列で割り当てる
    check_row=(int*)malloc(sizeof(int)*row);//チェック用の配列も動的配列で割り当てる
    check_col=(int*)malloc(sizeof(int)*col);
    if(grid==NULL||check_row==NULL||check_col==NULL){//エラー出力
        fprintf(stderr,"error\n");
        exit(1);
    }
    for(i=0;i<row;i++){
        grid[i]=(char*)malloc(sizeof(char)*(col+1));//列に関して文字列配列を動的配列で割り当てる
        if(grid[i]==NULL){//エラー出力
            fprintf(stderr,"error\n");
            exit(1);
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c",&grid[i][j]);//row行col列の入力
        }
    }
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            if(grid[i][j]=='#'){//ある行にひとつでも黒色があればその行は消さない。列も同様
                check_row[i]=1;
                check_col[j]=1;
            }
        }
    }
    for(i=0;i<row;i++){
        if(check_row[i]==1){//ある行に黒色があれば列について確認、白色しかなければその行は出力しないで次の行に
            for(j=0;j<col;j++){
                if(check_col[j]==1){//列について黒色がある列のみ出力
                    printf("%c",grid[i][j]);
                }
            }printf("\n");
        }
    }
    for(i=0;i<row;i++){
        free(grid[i]);//列についてメモリ解放
    }
    free(grid);//行についてメモリ解放
    free(check_row);//チェック用配列についてメモリ解放
    free(check_col);

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int N,ans,A,B,C;
void count(int pos,bool a,bool b,bool c){
    if(N<pos) return;
    if(a&&b&&c) ans++;
    count(pos*10+A,true,b,c);
    count(pos*10+B,a,true,c);
    count(pos*10+C,a,b,true);
}
main() {
    ans=0; A=7; B=5; C=3; cin >> N;
    count(0,false,false,false);
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define PI 3.141592653589793

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double ans = 0;
	
	if (a/2.0*b <= x/a){
		// 台形
		ans = atan(((2*b) - ((2*x)/a/a)) / a);
	} else {
		// 三角形
		ans = atan((a*b*b) / (2*x));
	}
	
	cout << std::fixed << std::setprecision(15) << ans * (180.0 / PI) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(all(a));
	if(a[0] != a[1] && a[1] != a[2]) cout << 3 << endl;
	else if(a[0] == a[1] && a[1] ==  a[2]) cout << 1 << endl;
	else cout << 2 << endl;
    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))
a=[]
d=[(1,-1),(1,1),(-1,-1),(-1,1)]
for p,q in d:
    if y==(x*p+ans)*q:
        a.append(ans+[p,q].count(-1))

print(min(a))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 5; // 適宜
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void mainsolve(){

	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	if(k==1){
		cout << 0 << endl;
		return;
	}

	COMinit();

	sort(a.begin(), a.end());
	vector<ll> cums(n+1);
	rep(i,n) cums[i+1] = (cums[i] + a[i]) % MOD;

	ll res = 0;
	// d = r-l
	for(ll d = k-1; d <= n-1; d++){
		ll cc = (cums[n] - cums[d] + MOD) % MOD;
		cc = (cc - cums[n-d] + MOD) % MOD;
		(res += (COM(d-1,k-2) * cc) % MOD) %= MOD;
		//(res += (COM(d-1,k-2) * ((cums[n] - ((2 * cums[d]) % MOD) + MOD) % MOD) % MOD)) %= MOD;
	}

	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,l;
    std::cin >> n >>l;
    int aji=0;
    int tmp=1+l-1;
    int sum=0;
    for (int i = 2; i <= n; i++) {
        aji=i+l-1;
        if(abs(tmp)<abs(aji)){
            sum+=aji;
        }else{
            sum+=tmp;
            tmp=aji;
        }
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int grid[2000][2000] = {};
int main() {
	int h, w;
	cin >> h >> w;
	vector<tuple<int, int, int, int>> ans;
	REP(i, h) {
		REP(q, w) {
			cin >> grid[i][q];
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int q = 0; q < w - 1; ++q) {
			if (grid[i][q] % 2 == 1) {
				ans.push_back(make_tuple(i, q, i, q + 1));
				grid[i][q]--;
				grid[i][q + 1]++;
			}
		}
	}
	for (int i = 0; i < h - 1; ++i) {
		if (grid[i][w - 1] % 2 == 1) {
			ans.push_back(make_tuple(i, w-1, i + 1, w-1));
			grid[i][w - 1]--;
			grid[i + 1][w - 1]++;
		}
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); ++i) {
		cout << get<0>(ans[i]) + 1 << " " << get<1>(ans[i]) + 1 << " " << get<2>(ans[i]) + 1 << " " << get<3>(ans[i]) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 500002
#define INF 2e9 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")
//


ll n, m, ans;

void calc(string t, char mx)
{
    if(t.size() == n)
        cout << t << "\n";
    else
    {
        for(char c = 'a'; c <= mx; c++)
        {
            calc(t + c, (c == mx) ? char(mx + 1) : mx);
        }
    }

}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);

    cin >> n;


    string s;
    calc(s, 'a');

    return 0;
}



Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main {
    static int MAX_INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        String line;
        while ((line = in.readLine()) != null) {
            st = new StringTokenizer(line, " ");
            int m = Integer.parseInt(st.nextToken());
            int d = Integer.parseInt(st.nextToken());
            if (m == 0 && d == 0) {
                break;
            }
            int days = 4;
            switch (m) {
                case 12 : days += 30;
                case 11 : days += 31;
                case 10 : days += 30;
                case 9 : days += 31;
                case 8 : days += 31;
                case 7 : days += 30;
                case 6 : days += 31;
                case 5 : days += 30;
                case 4 : days += 31;
                case 3 : days += 29;
                case 2 : days += 31;
            }
            days += d - 1;
            String ans = "";
            switch (days % 7) {
                case 1 : ans += "Monday"; break;
                case 2 : ans += "Tuesday"; break;
                case 3 : ans += "Wednesday"; break;
                case 4 : ans += "Thursday"; break;
                case 5 : ans += "Friday"; break;
                case 6 : ans += "Saturday"; break;
                case 0 : ans += "Sunday"; break;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 24220
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long ll;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

void solve_case() {
  int n;cin >> n;
  vector<int> vec(n);
  for(auto &a : vec)cin >> a;
  int ans = 1e9;
  for(int x = 1; x<101; x++){
    int ans1 = 0;
    for(auto a : vec){
      ans1 += pow(x - a, 2);
    }
    ans = min(ans1, ans);
  }
  cout << ans;

}

/**************/


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
 
  int tt = 1;
  // cin >> tt;
  while (tt--) {
    solve_case();
  } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    vector<int> g1, g2;

    rep(i, m) {
        int t1, t2;
        cin >> t1 >> t2;
        if (t1 == 1) {
            g1.emplace_back(t2);
        }
        if (t2 == n) {
            g2.emplace_back(t1);
        }
    }

    if(g1.empty()||g2.empty()){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    sort(g2.begin(), g2.end());

    bool b = false;
    rep(i, g1.size()) {
        int t1 = g1[i];
        auto itr = lower_bound(g2.begin(), g2.end(), t1);

        if (*itr == t1) {
            b = true;
            break;
        }
    }

    if (b) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n,tmp;
    string s;
    cin >> n >> s;
    int size = s.size();
    for (int i = 0; i < size; i++) {
        tmp = s[i] + n;
        if (tmp > 90) tmp -= 26;
        s[i] = tmp;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
	LL n, k; cin >> n >> k;

	LL x = n % k; LL y = k - x;
	LL ans = min(x, y);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define reint register int
#define coint const int

using namespace std;

coint SIZE = 10 + 5;

int num[SIZE][SIZE];

int main(void) {
    int n, d;
    scanf("%d%d", &n, &d);
    for (reint i = 1; i <= n; ++i)
        for (reint j = 1; j <= d; ++j) scanf("%d", &num[i][j]);
    int ans = 0;
    for (reint i = 1; i <= n; ++i)
        for (reint j = i + 1; j <= n; ++j) {
            int sum = 0;
            for (reint k = 1; k <= d; ++k) {
                coint tmp = abs(num[i][k] - num[j][k]);
                sum += tmp * tmp;
            }
            //printf("i = %d, j = %d, sum = %d\n", i, j, sum);
            double xsqrt = sqrt(sum);
            if (fabs(round(xsqrt) - xsqrt) <= 1e-8) ++ans;
        }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 384
#C
# 7,77,777･･･=7*(1,11,111･･･)
# 7*(10^i)=7*(10^i-1)/10-1 = 7*(10^i-1)/9 がkで割れる
# 10^iを(9k,7の倍数だったら9k/7)で割ってあまりが１だったら良い
import sys
k=int(input())
if k%7==0:
    k//=7
k*=9
a=10%k
for i in range(k):
    a=a%k
    if a==1:
        print(i+1)
        sys.exit()
    a*=10
print(-1)


Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],cnt[N];
bool calc(int n){
	for(int i=1;i<=n;++i) cnt[i]=0;
	for(int i=1;i<=n;++i){
		int l=max(i-a[i],1),r=min(i+a[i],n);
	//	cout<<i<<" "<<l<<" "<<r<<endl;
		cnt[l]++;cnt[r+1]--;
	}
	for(int i=1;i<=n;++i){
		cnt[i]+=cnt[i-1];
		a[i]=cnt[i];
	}
	for(int i=1;i<=n;++i)
		if(a[i]<n) return 0;
	return 1;
}
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=k;++i)
		if(calc(n)) break;
	for(int i=1;i<=n;++i)
		cout<<a[i]<<" ";
	return 0;
}

Measured memory_bytes: 5188
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n, k = map(int, input().split())
mod = 10**9 + 7

lst = [0 for i in range(k+1)]
for i in range(1, k+1)[::-1]:
    num = pow(k//i, n, mod)
    lst[i] += num
    divisors = make_divisors(i)
    for j in divisors:
        if j != i: lst[j] -= lst[i]

ans = 0
for i in range(1, k+1):
    ans = (ans + i*lst[i]) % mod
print(ans)

Measured memory_bytes: 80352
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k,h[100005],f[100005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	  scanf("%d",&h[i]);
	for(int i=2;i<=n;i++)
	{
		f[i]=2147483647;
		for(int j=max(1,i-k);j<i;j++)
		  f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  int N;
  cin >> N;

  vector<long long> a(N),b(N),c(N);
  for(int i = 0;i < N;i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }

  long long dp[100100][3];

  for(int i = 0;i < 100100;i++) {
    for(int j = 0;j < 3;j++) {
      dp[i][j] = 0;
    }
  }

  dp[0][0] = a.at(0);
  dp[0][1] = b.at(0);
  dp[0][2] = c.at(0);

  for(int i = 1;i < N;i++) {

    dp[i][0] = max(dp[i - 1][1] + a.at(i),dp[i - 1][2] + a.at(i));
    dp[i][1] = max(dp[i - 1][0] + b.at(i),dp[i - 1][2] + b.at(i));
    dp[i][2] = max(dp[i - 1][0] + c.at(i),dp[i - 1][1] + c.at(i));
  
  }

  cout << max({dp[N - 1][0],dp[N - 1][1],dp[N - 1][2]}) << endl;


}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  ll ans = 0;
  ll mx = 0;
  for(int i = 0; i < n; i++){
    mx = max(mx, a[i]);
    if(a[i] < mx)ans += mx - a[i];    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4728
K = int(input())
S = input().strip()

MOD = 10 ** 9 + 7

ans = 0

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]


def cmb(n, k, p):
    global fact, factinv
    if (k < 0) or (n < k):
        return 0
    r = min(k, n - k)
    return fact[n] * factinv[k] * factinv[n - k] % p


N = 2 * 10 ** 6
for i in range(2, N + 10):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)


for i in range(K + 1):
    ans += pow(25, i, MOD) * cmb(i + len(S) - 1, len(S) - 1, MOD) * pow(26, K - i, MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 226776
#include <stdio.h>
 
int main(void){
  	char c[3];
  	int i;
  	
    for(i=0;i<3;i++){
    	scanf("%c",&c[i]);
    }
	if(c[1] == 'R'){
    	printf("ABC\n");
    }else{
    	printf("ARC\n");
    }
}

Measured memory_bytes: 1596
import sys,re
for e in sys.stdin:
    s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e.strip())])
    for i in '0123456789'[s:]:
        if eval(e.replace('X',i).replace('=','==')):print(i);break
    else:print('NA')


Measured memory_bytes: 6568
from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class BinaryIndexTree:  # 1-indexed
    def __init__(self, N):
        """
        INPUT
        N [int] -> 全部0で初期化
        N [list] -> そのまま初期化
        """
        if isinstance(N, int):
            self.N = N
            self.depth = N.bit_length()
            self.tree = [0] * (N + 1)
            self.elem = [0] * (N + 1)
        elif isinstance(N, list):
            self.N = len(N)
            self.depth = self.N.bit_length()
            self.tree = [0] + N
            self.elem = [0] + N
            self._init()
        else:
            raise "INVALID INPUT: input must be int or list"

    def _init(self):
        size = self.N
        for i in range(1, self.N):
            if i + (i & -i) > size:
                continue
            self.tree[i + (i & -i)] += self.tree[i]

    def add(self, i, x):
        self.elem[i] += x
        while i <= self.N:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):
        res = 0
        while i > 0:
            res += self.tree[i]
            i -= i & -i
        return res

    def lower_bound(self, val):
        if val <= 0:
            return 0
        i = 0
        k = 1 << self.depth
        while k:
            if i + k <= self.N and self.tree[i + k] < val:
                val -= self.tree[i + k]
                i += k
            k >>= 1
        return i + 1


N, Q = map(int, input().split())
U = 5 * 10 ** 5 + 10

C = tuple(map(int, input().split()))
LR = [list() for _ in range(U)]
for i in range(Q):
    l, r = map(int, input().split())
    LR[r].append((l, i))

ans = [-1] * Q
bit = BinaryIndexTree(N + 5)
seen = defaultdict(int)
for i, c in enumerate(C, 1):
    if seen[c]:
        bit.add(seen[c], -1)
    bit.add(i, 1)
    seen[c] = i
    if LR[i]:
        R = bit.sum(i)
        for L, x in LR[i]:
            ans[x] = R - bit.sum(L - 1)


print(*ans, sep="\n")

Measured memory_bytes: 248120
L,R=(int(x) for x in input().split())
mod_list=[]
minimum=10000000000
index=0
flag=0
for i in range(L,R):
    for j in range(i+1,R+1):
        if((i*j)%2019==0):
            minimum=0
            flag=1
            break
        else:
            candidate=(i*j)%2019
            if(minimum>candidate):
                minimum=candidate
    if(flag==1):
        break
print(minimum) 

Measured memory_bytes: 39536
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000009
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
        mp[arr[i]]++;
    }
    ll sum = 0;
    for (auto i : mp)
    {
        sum += (i.second) * (i.second - 1ll) / 2ll;
    }
    for (ll i = 0; i < n; i++)
    {
        cout << sum - mp[arr[i]] + 1ll << endl;
    }
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int answer;
        
        if(n <= 9){
            answer = n;
        }else if(n <= 99){
            answer = 9;
        }else if(n <= 999){
            answer = 9 + (n - 99);
        }else if(n <= 9999){
            answer = 909;
        }else if(n <= 99999){
            answer = 909 + (n - 9999);
        }else{
            answer = 90909;
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int n;
void test() {
    cin>>n;
    cout<<(1000-(n%1000))%1000<<endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int t; cin>>t;
    // while (t--) {
    //     test();
    // }
    test();
    // for (int i=1; i<=t; ++i) {
    //     cout<<"Case #"<<i<<": ";
    //     test();
    // }
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;

int GCD(int x, int y){
  if(x%y) return GCD(y, x%y);
  else return y;
}

int main(){

  int x, y;

  cin>>x>>y;

  if(x>y) cout<<GCD(x, y)<<endl;
  else cout<<GCD(y, x)<<endl;

  return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>

enum{ MOD=1000000007 };
template<class T>
static T inv(T a)
{
    T b=MOD;
    T u=0, v=1;
    while(a)
    {
        const auto t=b/a;
        std::swap(b-=t*a,a);
        std::swap(u-=t*v,v);
    }
    return (u+MOD)%MOD;
}

int main()
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    for(int H,W,A,B; std::cin >> H >> W >> A >> B; )
    {
        std::vector<long long> fact(std::max(H,W)*2+1); fact[0]=1;
        for(int i=1; i<fact.size(); ++i) fact[i]=fact[i-1]*i%MOD;
        long long sum=0;
        const auto d1=inv(fact[B-1]);
        const auto d2=inv(fact[W-B-1]);
        for(int i=1; i<=H-A; ++i)
        {
            const auto v1 = fact[B+i-2]*inv(fact[i-1])%MOD*d1%MOD;
            const auto v2 = fact[H-i+W-B-1]*inv(fact[H-i])%MOD*d2%MOD;
            sum=(sum+v1*v2)%MOD;
        }
        std::cout << sum << std::endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;

int N;
int A[1000001];
int ans[1000001] = {0};

int main(){
	scanf("%d",&N);
	for(int i = 1; i < N; i++){
		scanf("%d",&A[i]);
		ans[A[i]]++;
	}
	for(int i = 1; i <= N; i++){
		printf("%d\n",ans[i]);
	}


	return 0;
}


Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 80; 
const ll MOD = 1e9 + 7;
struct matrix{
	int n;
	ll v[MAXN][MAXN];
	matrix(int _n = 0){
		n = _n;
		memset(v, 0, sizeof(v));
	}
	matrix operator * (matrix m){
		matrix ans = matrix(n);
		for(int i = 1; i <= n; i++){
			for(int j = 1;  j <= n; j++){
				for(int k = 1; k <= n; k++){
					ans.v[i][j] += v[i][k]*m.v[k][j];
					ans.v[i][j] %= MOD;
				}
			}
		}
		return ans;
	}
	matrix operator ^ (ll k){
		matrix ans = matrix(n);
		for(int i = 1; i <= n; i++) ans.v[i][i] = 1;
		for(int i = 62; i >= 0; i--){
			ans = ans*ans;
			if(k&(1LL<<i)){ 
				ans = ans*(*this);			
			}
		}
		return ans;
	}
	ll sum(){
		ll ans = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				ans += v[i][j];
				ans %= MOD;
			}
		}
		return ans;
	}
};

matrix T;
int n;

ll k;
int main(){
	scanf("%d %lld", &n, &k);
	T = matrix(n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			scanf("%lld", &T.v[i][j]);
		}
	}
	matrix a = T^k;
	printf("%lld\n", a.sum());
}

Measured memory_bytes: 3936
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static long[] RIs => R.Split(' ').Select(long.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");

		static void Main(string[] args)
		{
			var inp = RIs;
			var a = Math.Abs(inp[0] - 2);
			var b = Math.Abs(inp[1] - 2);
			Out(a * b);
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
  ll n,x,m;
  cin >> n >> x >> m;
  unordered_set<ll> num;
  map<ll,int> pl;
  vector<ll> sum(10000000);
  ll ans=0;
  ans+=x;
  num.insert(x);
  ll a=x;
  sum.at(0)=x;
  pl[x]=0;

  ll b,c;
  bool d=false;
  rep(i,n-1){
      a=(a*a)%m;
      if(num.count(a)){
        b=i;
        c=a;
        d=true;
        break;
      }
      num.insert(a);
      pl[a]=i+1;
      ans+=a;
      sum.at(i+1)=ans;
  }
  if(d){
  ll lest=n-b-1;
  ll roop=b-pl.at(c)+1;
  ll rosum;
  if(pl.at(c)==0){
    rosum=sum.at(b);
  }
  else rosum=sum.at(b)-sum.at(pl.at(c)-1);
  ans+=(lest/roop)*rosum;
  ll ama=lest%roop;
  if(ama!=0){
    if(pl.at(c)==0) ans+=sum.at(pl.at(c)-1+ama);
    else ans+=sum.at(pl.at(c)-1+ama)-sum.at(pl.at(c)-1);
  }
  }
  cout << ans << endl;
} 
    

Measured memory_bytes: 86468
#include <iostream>

int main() {
    
    int a;
    std::cin >> a;
    int h,m,s;
    h = a / 3600;
    m = (a / 60) % 60;
    s = a % 60;
    
    std::cout << h << ":" << m << ":" << s << "\n";
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{

    vec A(3);
    rep(i, 3)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    if (A[2] == A[0] + A[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int n, m;
	sfd(n);
	set<int> arr;
	while( n-- ) {
		sfd(m);
		arr.insert(m);
	}
	pfd(arr.size());
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int k;
signed main(){
    cin>>s>>k;
    int l=s.size();
    rep(i,l){
        if('z'-s[i]<k&&s[i]!='a'){
            k-=('z'-s[i])+1;
            s[i]='a';
        }
    }
    k%=26;
    char c=s[l-1]+k;
    s[l-1]=c;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<P> vec[20];
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        for(int j = 0;j < A;j++) {
            int B,C;
            cin >> B >> C;
            B--;
            vec[i].push_back(P(B,C));
        }
    }
    int ret = 0;
    for(int bit = 0;bit < (1 << N);bit++) {
        vector<int> cnt;
        for(int i = 0;i < N;i++) {
            if(bit & (1 << i)) {
                cnt.push_back(i);
            }
        }
        vector<int> cnt2(N,0);
        for(int i = 0;i < cnt.size();i++) {
            cnt2.at(cnt.at(i)) = 1;
        }
        bool cnt3 = true;
        for(int i = 0;i < cnt.size();i++) {
            for(int j = 0;j < vec[cnt.at(i)].size();j++) {
                if(cnt2.at(vec[cnt.at(i)].at(j).first) != vec[cnt.at(i)].at(j).second) {
                    cnt3 = false;
                }
            }
        }
        if(cnt3 == true) {
            int count = 0;
            for(int i = 0;i < N;i++) {
                if(cnt2.at(i) == 1) {
                    count++;
                }
            }
            ret = max(ret,count);
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int num,fir;
};
node a[100000];
bool cmp(node a,node b){
	return a.fir < b.fir;
}
int main(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		int t;
		cin >> t;
		a[i].num=i;
		a[i].fir = t;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		cout << a[i].num << " ";
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;

int main() { 
  int N;
  string S;
  int K;
  cin >> N >> S >>K;
  for(int i=0; i<N; i++){
    if( S.at(i) == S.at(K-1) ){
    }
    else{
      S.at(i)='*';
    }
  }
    cout << S << endl;


}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

#define ll long long

class FIO
{
public:
    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }
    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }
private:
    char f,c,a[25],i;
    template<typename T>inline void _R(T& x)
    {
        for(f=0;(c=getchar())<48;c==45&&(f=1));
        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));
        if(f)x=-x;
    }
    template<typename T>inline void _W(T x)
    {
        if(sizeof(x)==1){ putchar(x);return; }
        if(x<0)putchar(45),x=-x;
        if(x>99) {
            for(i=0;x;x/=10)a[i++]=x%10;
            while(i--)putchar(a[i]+48);
        } else if(x>9) putchar(x/10+48),putchar(x%10+48);
        else putchar(x+48);
    }
}io;


ll a[200005];

int main()
{
    ll n,k;
    io>>n>>k;
    for(int i=0;i<n;++i)io>>a[i];
    std::sort(a,a+n);
    ll ans=0;
    for(int i=0,_i=n-k;i<_i;++i)
        ans+=a[i];
    io<<ans;
    return 0;
}

Measured memory_bytes: 2984
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var q = new int[n].Select(_ => Console.ReadLine())
			.GroupBy(x => x)
			.GroupBy(g => g.Count(), g => g.Key)
			.OrderBy(g => -g.Key)
			.First()
			.OrderBy(x => x);
		Console.WriteLine(string.Join("\n", q));
	}
}


Measured memory_bytes: 71448
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int cnt = 1;
        
        int od = 0;
        for (int i = 2; i <= n + 1; i++) {
            int nd = od + sc.nextInt();
            if (nd <= x) {
                cnt++;
            }
            od = nd;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21972
import math

N, H = map(int, input().split())

swords = [list(map(int, input().split())) for _ in range(N)]

swords_T = [list(x) for x in zip(*swords)]

#print(swords_T)

swing_max = max(swords_T[0])

order = sorted(swords_T[1])
#print(order)
count = 0

while H > 0 and len(order) != 0:
    tmp = order.pop()
    if tmp > swing_max:
        H -= tmp
        count += 1
#print(f'{H=}')
if H > 0:
    count += math.ceil(H/swing_max)

print(count)

Measured memory_bytes: 36820
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<pp,null_type,less_equal<pp>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
#define log sdfdsfdsf

const ll DIM = 2E5+7;
const ll MOD = 1e9+123;
const ll M1 = 1e9+7;
const ll INF = 1E17;
const ld eps = 0.0000000001;
const ld PI = 3.14159265358979323846;
int getInt(int a = 0, int b = INT_MAX){
	static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	return uniform_int_distribution <int> (a, b)(rng);
}
const ll MAXN = 1E9;
pp A[DIM];
super_set S[DIM];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    string ss;
    getline(cin,ss);
    forn(i,n){
        string s;
        getline(cin,s);
        ll pos = 0;
        ll num = 0;
        while(pos<s.length() && s[pos]!='.'){
            num*=10;
            num+=(s[pos]-'0');
            ++pos;
        }

        ll mult = MAXN;
        ++pos;
        while(pos<s.length()){
            num*=10;
            num+=(s[pos]-'0');
            mult/=10;
            ++pos;
        }
        num*=mult;
        ll a = num;
       // cout<<a<<' ';
        ll cnt1 = 0;
        while(a%2==0){
            a/=2;
            ++cnt1;
        }
        ll cnt2 = 0;
        while(a%5==0){
            a/=5;
            ++cnt2;
        }
        A[i] = {cnt1,cnt2};
        //cout<<cnt1<<' '<<cnt2<<endl;
    }
   // cout<<endl;
    ll res = 0;
    forn(i,n){
        ll need1 = max(0ll,18ll-A[i].fi);
        ll need2 = max(0ll,18ll-A[i].sc);

        ll r = 0;
        for(ll j = need1;j<=18;++j){
            r += S[j].size()-S[j].order_of_key({need2,-INF});
        }
        res+=r;
        S[min(18ll,A[i].fi)].insert({min(18ll,A[i].sc),i});
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 38016