akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n, m;   cin >> n >> m;  unordered_map<int, int> mp;
    for(int i=0;m>i;i++){
        int a, b;   cin >> a >> b;
        mp[a]++; mp[b]++;
    }
    for(auto it=mp.begin();it!=mp.end();++it){
        if((it->second)%2){
            cout << "NO";   return 0;
        }
    }
    cout << "YES";
}


Measured memory_bytes: 4004
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int MOD = 1e9 + 7;
const int N = 65;
int _ws[N];
int n;

void init() {
    scanf(I,&n); 
    rep (i,n) {
        int x; scanf(I,&x);
        rep (i,61) _ws[i] += ((x>>i)&1);
    }   
}

void solve() {
    int ans = 0;
    rep (i,N) (ans += (1LL<<i) % MOD * _ws[i] % MOD * (n-_ws[i]) % MOD) %= MOD;
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
ans = 0
while True:
	if A == B == C:
		break
	A, B, C = sorted([A, B, C])
	if C - A > 1:
		A += 2
	else:
		A += 1
		B += 1
	ans += 1
print(ans)

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


//各部分集合に対して部分集合を列挙すると計O(3^n)になる

int N, A[16][16];
ll dp[1 << 16];
ll cst[1 << 16];

int main() {
    cin >> N;
    rep(i, N) rep(j, N) cin >> A[i][j];

    //cst[msk]はmskでグループを作った時の得点
    rep(msk, 1 << N) {
        rep(i, N) for (int j = i + 1; j < N; j++) {
            if ((msk & (1 << i)) && (msk & (1 << j))) cst[msk] += A[i][j];
        }
    }

    //m1とm2に包含関係があればm1<=m2が成り立つので数としての大きさの順序でやればよい
    rep(msk, 1 << N) {
        for (int msk2 = msk; msk2 > 0; msk2 = (msk2 - 1)&msk) { //mskの部分集合msk2の列挙
            ll nxt = dp[msk - msk2] + cst[msk2];
            chmax(dp[msk], nxt);
        }
    }

    cout << dp[(1 << N) - 1] << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
template<class T>
T gcd(T a, T b)
{
  if (a < b) swap(a,b);
  return b ? gcd(b, a % b) : a;
}
template<class T>
T lcm(T a, T b)
{
  // return a * b / gcd(a, b);
  ll g = gcd(a, b);
  a /= g; b /= g;
  return a * b * g;
}

int main(int argc,char** argv){ fastio; myio;
  int n;
  cin>>n;
  vl t(n);
  cin>>t;
  ll lcma = 1;
  rep(i,n) lcma = lcm(lcma,t[i]);
  cout<<lcma;
}

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

int main() {
  int N, M, Q, L[200009], R[200009], X[509][509], C[509][509];
  cin >> N >> M >> Q;

  for (int i = 1; i <= M; i++) {
    cin >> L[i] >> R[i];
    X[L[i]][R[i]]++;
  }

  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      C[i][j] = C[i][j -1] + X[i][j];
    }
  }

  for (int i = 0; i < Q; i++) {
    int s, e;
    cin >> s >> e;
    int sum = 0;
    for (int j = s; j <= e; j++) {
      sum += C[j][e] - C[j][s -1];
    }
    cout << sum << endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  string s;
  cin >> s;
  if(s[0] == '1')s[0] = '9';
  else if(s[0] == '9')s[0] = '1';
  if(s[1] == '1')s[1] = '9';
  else if(s[1] == '9')s[1] = '1';
  if(s[2] == '1')s[2] = '9';
  else if(s[2] == '9')s[2] = '1';
  cout << s << endl;

  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdlib>
#include<sstream>
#define EPS 1e-10
#define F first
#define pb push_back
#define S second
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;
typedef pair<long double,long double> P;


int N;
/*
cout << setiosflags(ios::fixed) << setprecision(5) << ans.F << " " << ans.S << endl;
*/

class Point{
public:
  long double x,y;

  Point (long double x=0,long double y=0):x(x),y(y){}

  Point operator + (Point p) {return Point(x+p.x,y+p.y); }
  Point operator - (Point p) {return Point(x-p.x,y-p.y); }
  Point operator * (long double p) {return Point(x*p,y*p); } 
  Point operator / (long double p) {return Point(x/p,y/p); }

  bool operator < (const Point &p) const {
    return x!=p.x?x<p.x:y<p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }

};

struct Segment{
  Point p1,p2;
};

long double norm(long double x,long double y){
  return x*x+y*y;
}

long double abs(long double x,long double y){
  return sqrt(norm(x,y));
}

long double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}

long double det(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}



bool isParallel(Segment s1,Segment s2){
  return equals(det(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}

vector<Point> Pvec;
vector<Segment> Svec;
Point ans;

void makeSvec(){
  rep(i,Pvec.size()){
    Segment s;
    if(i == Pvec.size()-1){
      s.p1 = Pvec[i];
      s.p2 = Pvec[0];
    }else{
    s.p1 = Pvec[i];
    s.p2 = Pvec[i+1];
    }
    Svec.pb(s);
  }
}

void input(){
  ans.x = 0;ans.y = 0;
 cin >> N;  
  rep(i,N){
    Point pos;
    cin >> pos.x >> pos.y;
    ans.x = ans.x+pos.x; ans.y = ans.y+pos.y; 
    Pvec.pb(pos);
  }
  ans.x = ans.x/N;
  ans.y = ans.y/N;
  makeSvec();
}


int main(){
  input();
  if(N%2 != 0){
    cout << "NA" << endl;
    return 0;
  }
  rep(i,N){
    bool fin = false;
    rep(j,N){
      if(i == j)continue;
      if(isParallel(Svec[i],Svec[j]))fin = true;
    }
    if(!fin){
      cout << "NA" << endl;
      return 0;
    }
  }
  cout << setiosflags(ios::fixed) << setprecision(5) << ans.x << " " << ans.y << endl;
  return 0;
}

Measured memory_bytes: 1312
#include<stdio.h>
int main()
{
    int a,b,c,d;
    int x,y;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            printf("Yes\n");
            break;
        }
        a-=d;
        if(a<=0)
        {
            printf("No\n");
            break;
        }

    }
    return 0;
}


Measured memory_bytes: 1648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int n, m;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    int a[m];
    for(int i=0;i<m;i++) cin>>a[i];
    if(n>=m){
         cout <<0<< "\n";
         return 0;
    }
    sort(a,a+m);
    int b[m-1];
    for(int i=0;i<m-1;i++){
        b[i]=a[i+1]-a[i];
    }
    sort(b,b+m-1);
    ll ans=0;
    for(int i=0;i<m-1-(n-1);i++){
        ans+=b[i];
    }
    cout << ans<< "\n";
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int a,b,min,c;
  scanf("%d%d",&a,&b);
  if(a<b) {
    min=a;
    a=b;
    b=min;
  }
  while(1){
    c=a%b;
    if(c==0) break;
    a=b;
    b=c;
  }
  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 592
s = input()
N = len(s)
ans = 0
count = 0
for i in range(N):
    if s[i] == "g":
        if count > 0:
            count -= 1
            ans += 1
        else:
            count += 1
    else:
        if count > 0:
            count -= 1
        else:
            count += 1
            ans -= 1

print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>

int main(void){
  int N;
  int n[200], d[200];
  int i,j,k;
  int W,H;
  int result[400][400];
  int max_W, min_W;
  int max_H, min_H;

  while(1){
    scanf("%d", &N);
    if(N==0) break;

    memset(n, 0, sizeof(n));
    memset(d, 0, sizeof(d));
    memset(result, -1, sizeof(result));

    result[200][200]=0;
    max_W=200, min_W=200;
    max_H=200, min_H=200;

    for(i=0; i<N-1; i++){
      scanf("%d %d", &n[i], &d[i]);
    }

    for(k=0; k<N-1; k++){
      for(i=0; i<400; i++){
        for(j=0; j<400; j++){
          if(n[k]==result[i][j]){
            if(d[k]==0){
              result[i][j-1]=k+1;
            }
            else if (d[k]==1){
              result[i+1][j]=k+1;
            }
            else if (d[k]==2){
              result[i][j+1]=k+1;
            }
            else if (d[k]==3){
              result[i-1][j]=k+1;
            }
          }
        }
      }
    }
    for(k=0; k<=N-1; k++){
      for(i=0; i<400; i++){
        for(j=0; j<400; j++){
          if(result[i][j]==k){
            if(i>=max_H) max_H=i;
            if(i<=min_H) min_H=i;
            if(j>=max_W) max_W=j;
            if(j<=min_W) min_W=j;
          }
        }
      }
    }

  W=max_W-min_W+1;
  H=max_H-min_H+1;

    printf("%d %d\n", W, H );
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, x) for (int i = x; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 200000;

struct SegTree {
    vpii t;
    int m = 1;

    SegTree(int n) {
        while (m < n) m <<= 1;

        t.assign(2 * m, {0, INF64});
    }

    bool better(pii p, int v, int x) {
        return (p.ff * x + p.ss) < (t[v].ff * x + t[v].ss);
    }

    void add(int v, int l, int r, pii p) {
        if (l > r) return;

        int mm = (l + r) >> 1;

        bool left = better(p, v, l);
        bool mid = better(p, v, mm);

        if (mid) {
            swap(t[v], p);
        }

        if (l == r) return;

        if (left ^ mid) {
            add(v << 1, l, mm, p);
        } else {
            add((v << 1) + 1, mm + 1, r, p);
        }
    }

    int get(int x, int v, int l, int r) {
        if (l > r) return INF64;

        int mid = (l + r) >> 1;

        int curr = t[v].ff * x + t[v].ss;

        if (l == r)
            return curr;

        if (x < mid) {
            return min(curr, get(x, v << 1, l, mid));
        } else {
            return min(curr, get(x, (v << 1) + 1, mid + 1, r));
        }
    }

    int get(int x) {
        return get(x, 1, 1, m);
    }

    void add(int k, int b) {
        add(1, 1, m, {k, b});
    }
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, c;
    cin >> n >> c;

    vi h(n + 1);
    in(h, 1);

    SegTree t(1000000);

    vi dp(n + 1, 0);
    t.add(-2 * h[1], h[1] * h[1]);

    for (int k = 2; k <= n; ++k) {
        dp[k] = t.get(h[k]) + h[k] * h[k] + c;

        t.add(-2 * h[k], h[k] * h[k] + dp[k]);
    }

    cout << dp[n];
}

Measured memory_bytes: 36224
#include<iostream>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int X;
	cin >> X;
	int ans = 0;

	while (X > 0) {
		if (X >= 500) {
			ans += 1000;
			X -= 500;
		}
		else if(X >= 5){
			ans += 5;
			X -= 5;
		}
		else {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct node_tag
{
  int key;
  int parent,left,right;
}Node;

//static Node *make_node(int value);

int main()
{
  int i;
  int H,value;
  Node node[251];

  scanf("%d",&H);

  for(i=1;i<251;i++)
  {
    node[i].key = -2000000001;
    node[i].left = -2000000001;
    node[i].right = -2000000001;
    node[i].parent = -2000000001;
  }

  //scan
  for(i=1;i<=H;i++)
  {
    scanf(" %d",&value);
    if(i==1)
    {
      node[1].key = value;
    }
    else
    {
      node[i].key = value;
      if(i%2 == 0)
      {
        node[i/2].left = node[i].key;
      }
      if(i%2 == 1)
      {
        node[i/2].right = node[i].key;
      }
      if(i != 1)
      {
        node[i].parent = node[i/2].key;
      }
    }
  }
  
  //printf("%d",node[1].left);

  /*  for(i=1;i<=H;i++)
  {
  if(scanf(" %d",&value)!=1)
  //    printf("\n%d",value);
  {
  if(i==1)
  {
  node[1].key = value;
}
else
{
node[i].key = value;
node[i].parent = node[i/2].key;
if(i/2==0)
{
node[i/2].left = node[i].key;
}
else if(i/2==1)
{
node[i/2].right = node[i].key;
}
}

}
}
*/


/*  for(i=0;i<H;i++)
{
printf("/ %d /",&node[i].key);
}
*/


//print
   for(i=1;i<=H;i++)
     {
       printf("node %d: ",i);
       printf("key = %d, ",node[i].key);
       if(i!=1)
	 {
	   printf("parent key = %d, ",node[i].parent);
	 }
       if(node[i].left != -2000000001)
	 {
	   printf("left key = %d, ",node[i].left);
	 }
       if(node[i].right != -2000000001)
	 {
	   printf("right key = %d, ",node[i].right);
	 }
       printf("\n");
     }
return 0;
}


/*static Node *make_node(int value)
{
Node *new_node;
new_node = (Node *)malloc( sizeof(node_t) );
if( new_node == NULL)
{
return NULL;
}
new_node->key = value;
new_node->left = NULL;
new_node->right = NULL;
return new_node;
}*/



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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void solve() {
	int n; cin >> n;
	string s, t; cin >> s >> t;
	for (int i = 0; i <= n; i++) {
		bool ok = true;
		for (int p = i; p < n; p++) {
			if (s[p] != t[p - i]) ok = false;
		}
		if (ok) {
			cout << n + i << endl;
			return;
		}
	}
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int n,x,m;
bool isans = false;
int sum = -1;
vector<int> l;
vector<int> r;
vector<int> s;
vector<int> ans;

void saiki(int n1,vector<int> ar){
    if(n1 >= n){
	REP(i,n){
	    ar[i+1] += ar[i];
	}
	bool flg = true;
	REP(i,m){
	    if(ar[r[i]]-ar[l[i]-1] != s[i]){
		flg = false;
	    }
	}
	if(!flg) {
	    return;
	}else isans = true;

	if(sum< ar[ar.size()-1]){
	    sum= ar[ar.size()-1];
	    sum= 0;
	    ans = vector<int>(n);
	    REP(i,ar.size()-1){
		ans[i] = ar[i+1] - ar[i];;
	    }
	}
	return ;
    }

    REP(i,x+1){
	ar[n1+1] = i;
	saiki(n1+1,ar);
    }
}

int main(){
    cin >> n >> x >> m;
    vector<int> ar(n+1,x);
    ll six = pow(x,n);
    REP(i,m){
	int a,b,c;
	cin >> a;
	if(cin.eof()) break;
        cin >> b >> c;
	l.PB(a);
	r.PB(b);
	s.PB(c);
    }

    sum= -1;
    ar[0] = 0;
    saiki(0,ar);
    if(isans){
	cout << ans[0];
	FOR(i,1,ans.size()){
	    cout << " " << ans[i];
	}
	cout << endl;
    }else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;

int a[maxn], dp[maxn], n;

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i ++)
	{
		a[i] = read();
	}
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3; i <= n; i ++)
	{
		int x = dp[i - 1] + abs(a[i] - a[i - 1]);
		int y = dp[i - 2] + abs(a[i] - a[i - 2]);
		dp[i] = min(x, y);
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
start_num,end_num, div1, div2 =  gets.split(' ').map{|x| x.to_i }
#puts (start_num..end_num).to_a.count{|x| x % div1 != 0 && x % div2 != 0}
div1_wari = end_num / div1 - (start_num - 1) / div1
div2_wari = end_num / div2 - (start_num - 1) / div2
lcm = div1.lcm(div2)
lcm_wari = end_num / lcm - (start_num - 1) / lcm
puts (end_num - start_num + 1) - (div1_wari + div2_wari - lcm_wari)


Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

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

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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

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

#define MAX_N (1<<17)

int n, q;
int segtree[2*MAX_N - 1];

void init(int _n){
  n = 1;
  while(n<_n) n *= 2;

  for(int i = 0; i < 2 * n - 1; i++) segtree[i] = (1L<<31) - 1;
}

// [a, b) : ?????????????????????
// [l, r) : ????????????
// k      : ?????????????????????
int _find(int a, int b, int k, int l, int r){
  if(a <= l && r <= b) return segtree[k];
  else if(r <= a || b <= l) return (1L<<31)-1;
  else{
    int lv = _find(a, b, k * 2 + 1, l, (l + r) / 2);
    int rv = _find(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(lv, rv);
  }
}

int find(int a, int b){
  return _find(a, b, 0, 0, n);
}

void update(int k, int a){
  k += n - 1;
  segtree[k] = a;
  while(k > 0){
    k = (k-1)/2;
    segtree[k] = min(segtree[k*2+1], segtree[k*2+2]);
  }
}

int main(void){
  ios_base::sync_with_stdio(0);
  int _n, x, y, com;

  cin >> _n >> q;
  init(_n);

  rep(i, q){
    cin >> com >> x >> y;
    if(com == 0) update(x, y);
    else if(com == 1) cout << find(x, y+1) << endl;
  }
  return 0; 
}

Measured memory_bytes: 2220
#include<iostream>
#include<string>

int main(){

	std::string str;
	std::getline(std::cin, str);

	for (int i = 0; i < str.size(); i++){
		if ('a' <= str[i] && str[i] <= 'z')str[i] -= 32;
		else if ('A' <= str[i] && str[i] <= 'Z')str[i] += 32;
	}

	std::cout << str << std::endl;

	return 0;
}

Measured memory_bytes: 1176
N = int(input())
arr = list(map(int, input().split()))

count=0
flag = False

while True:
    for j in range(N):
            if arr[j]%2 == 0:
                arr[j] /=2
            elif arr[j]%2 != 0:
                flag = True
                break

    if flag == True:
        break
    count += 1

print(count)


Measured memory_bytes: 2940
A = list(input())
B = list(input())
C = list(input())
A.append('a')
B.append('b')
C.append('c')
t = 0

while (len(A) != 0 and len(B) != 0 and len(C) != 0):
    if t == 0:
        start = A[0]
        A = A[1:]
        t = 1
    elif start == 'a':
        start = A[0]
        A = A[1:]
    elif start == 'b':
        start = B[0]
        B = B[1:]
    elif start == 'c':
        start = C[0]
        C = C[1:]

if len(A) == 0:
    print("A")
elif len(B) == 0:
    print("B")
else:
    print("C")

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int A[3][3], N, b, ans[3][3], f=0;

    REP(i, 3){
        REP(j, 3){
            cin >> A[i][j];
        }
    }
    cin >> N;

    REP(i, N){
        cin >> b;
        REP(i, 3){
            REP(j, 3){
                if(b == A[i][j]){
                    ans[i][j] = 1;
                }
            }
        }
    }

    int r, c;
    REP(i, 3){
        r = ans[i][0] + ans[i][1] + ans[i][2];
        c = ans[0][i] + ans[1][i] + ans[2][i];
        if(r==3 || c == 3){
            f = 1;
        }
    }

    int d;
    d = ans[0][0] + ans[1][1] + ans[2][2];
    if(d == 3) f=1;

    d = 0;
    d = ans[0][2] + ans[1][1] + ans[2][0];
    if(d == 3) f=1;

    string s;
    if(f == 1){
        s = "Yes";
    } else {
        s = "No";
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long m = sc.nextLong();
        long v = sc.nextLong();
        int p = sc.nextInt();
        long[] a = new long[n];
        
        Map<Long, Long> map = new HashMap<Long, Long>();
        
        for(int i = 0; i < n; i++){
            long tmp = sc.nextLong();
            a[i] = tmp;
            if(map.containsKey(tmp)){
                map.put(tmp,map.get(tmp)+1);
            }else{
                map.put(tmp,(long)1);
            }
        }
        Arrays.sort(a);
        long border = a[n-p];
        for(int i = 1; i < n; i++){
            a[i] += a[i-1];
        }
        Object[] mapkey = map.keySet().toArray();
        Arrays.sort(mapkey);
        
        long[] arr = new long[mapkey.length];
        arr[0] = (long)mapkey[0] * map.get((long)mapkey[0]);
        for(int i = 1; i < mapkey.length; i++){
            arr[i] = arr[i-1] + (long)mapkey[i] * map.get((long)mapkey[i]);
        }
        
        long backCnt = 0;
        for(int i = 0; i < mapkey.length; i++){
            long tmp = (long)mapkey[i];
            if(tmp+m < border){
                backCnt += map.get(tmp);
                continue;
            }else{
                long back = backCnt + map.get(tmp);
                long remPoint = Math.max(0,m*(v-(back + p-1)));
                if(n-p+1-back <= 0){
                    break;
                }
                long average = (a[n-p]-a[(int)(back-1)]+remPoint) / (n-p+1-back);
                if((a[n-p]-a[(int)(back-1)]+remPoint) % (n-p+1-back) != 0){
                    average += 1;
                }
                //System.out.println(tmp +" "+ (n-p+1-back) +" "+average + " " + (tmp + m) + " " + remPoint + " " + (a[n-p]-a[(int)(back-1)]+remPoint) );
                if(average > tmp+m){
                    backCnt += map.get(tmp);
                    continue;
                }else{
                    break;
                }
            }
            
        }
        System.out.println(n-backCnt);
    }
}
 


Measured memory_bytes: 71840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
int main() {
  cin >> N;
  vector<int> isRed(2 * N, -1);

  string lRes;
  cout << "?";
  rep(i, N) cout << " " << (i + 1);
  cout << endl;
  cin >> lRes;

  // [l, r)
  int l = 0, r = N;
  while (r - l > 1) {
    int m = (l + r) / 2;

    cout << "?";
    rep(i, N) cout << " " << (m + i + 1);
    cout << endl;

    string res;
    cin >> res;
    if (res == lRes) {
      l = m;
    } else {
      r = m;
    }
  }

  isRed[l] = (lRes == "Red");
  isRed[l + N] = !isRed[l];

  string sIn = "?", sOut = "?";
  rep(i, 2 * N) {
    if (i == l || i == l + N) continue;
    if (l < i && i < l + N) {
      sIn += " " + to_string(i + 1);
    } else {
      sOut += " " + to_string(i + 1);
    }
  }

  rep(i, 2 * N) {
    if (i == l || i == l + N) continue;
    if (l < i && i < l + N) {
      cout << sOut;
    } else {
      cout << sIn;
    }
    cout << " " << (i + 1) << endl;

    string res;
    cin >> res;
    isRed[i] = (res == "Red");
  }

  cout << "! ";
  rep(i, 2 * N) cout << (isRed[i] ? "R" : "B");
  cout << endl;
  return 0;
}


Measured memory_bytes: 724
l = int(input())

b = bin(l)[2:][::-1]

l = []
for i in range(len(b)):
    if b[i] == '1':
        l.append(i)

k = l.pop()

nodes = [i for i in range(1, k + 2)]
edges = []
for i in range(len(nodes) - 1):
    edges.append([nodes[i], nodes[i+1], 2 ** (k - i - 1)])
    edges.append([nodes[i], nodes[i+1], 0])

covered = 2 ** k - 1
for x in l:
    edges.append([1, k + 1 - x, covered + 1])
    covered = edges[-1][-1] + 2 ** x - 1

print(max(nodes), len(edges))
for u, v, w in edges:
    print(u, v, w)


Measured memory_bytes: 38512
#include <stdio.h>

typedef struct
{
    int face[6];

} Dice;

int main(void)
{
    Dice dice;
    char operation[101];
    
    int i;
    for(i = 0; i < 6; ++i)
    {
        scanf("%d", &dice.face[i]);
    }

    scanf("%s", &operation);

    int temp;
    for(i = 0; operation[i] != '\0'; ++i)
    {
        switch(operation[i])
        {
            case 'N':
                temp = dice.face[0];
                dice.face[0] = dice.face[1];
                dice.face[1] = dice.face[5];
                dice.face[5] = dice.face[4];
                dice.face[4] = temp;
                break;

            case 'S':
                temp = dice.face[0];
                dice.face[0] = dice.face[4];
                dice.face[4] = dice.face[5];
                dice.face[5] = dice.face[1];
                dice.face[1] = temp;
                break;

            case 'E':
                temp = dice.face[0];
                dice.face[0] = dice.face[3];
                dice.face[3] = dice.face[5];
                dice.face[5] = dice.face[2];
                dice.face[2] = temp;
                break;

            case 'W':
                temp = dice.face[0];
                dice.face[0] = dice.face[2];
                dice.face[2] = dice.face[5];
                dice.face[5] = dice.face[3];
                dice.face[3] = temp;
                break;

            default:
                break;
        }
    }

    printf("%d\n", dice.face[0]);

    return 0;
}

Measured memory_bytes: 596
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A;
    cin >> A;
    ll N = A.size();
    ll dp[200010];
    rep(i,0,N) dp[i] = INF;
    vector<ll> pos[27];
    rep(i,0,N) pos[A[i]-'a'].push_back(i);
    dp[N] = 1;
    map<ll, pair<char, ll> > restore;
    rrep(i,N-1,0){
        rep(c,0,26){
            ll p = lower_bound(pos[c].begin(), pos[c].end(), i) - pos[c].begin();
            if(p == pos[c].size()){
                if(dp[i] > 1){
                    restore[i] = {(char) ('a' + c), N};
                    dp[i] = 1;
                }
                continue;
            }
            ll nxt = pos[c][p];
            if(dp[i] > dp[nxt+1] + 1){
                restore[i] = {(char)('a' + c), nxt+1};
                dp[i] = dp[nxt+1] + 1;
            }
        }
    }
    string ans = "";
    ll cur = 0;
    while(cur < N){
        auto lp = restore[cur];
        ans += lp.first;
        cur = lp.second;
    }
    print(ans);
}

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

int main() {
 string a,b,c;
 int A,B;
 cin >> a >> b >> c;
  A = a.size();
  B = b.size();

  if(a[A-1]==b[0] && b[B-1]==c[0]){
  cout << "YES" << endl;
  }
  else{
  cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        for(int i = 0; i < n; i++){
            t[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        int[] p = new int[m];
        int[] x = new int[m];
        for(int i = 0; i < m; i++){
            p[i] = sc.nextInt();
            x[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = sum + t[i];
        }
        for(int i = 0; i < m; i++){
            System.out.println(sum - t[p[i]-1] + x[i]);
        }
    }
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ld T, X;

    cin >> T >> X;

    cout << T / X << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	if(n==1&&m==1) cout << 1 << endl ;
	else if(n==1||m==1) cout << n*m-2 << endl ;
	else cout << (n-2)*(m-2) << endl ;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = [int(i) for i in input().split()]
ablenum = [int(i) for i in range(10)]
lis_n = str(n)
lis_n = list(lis_n)

#print(lis_n)

# 使用可能な数一覧
for i in d:
    ablenum.remove(i)

#print(ablenum)

flag_bigdigit = -1

# max(ablenum)より大きい桁があるかどうか
for i in range(len(lis_n)):
    _i = len(lis_n) - i - 1
    if(int(lis_n[_i]) > max(ablenum)):
        flag_bigdigit = _i
        break

#  max(ablenum)より大きい桁があれば
if(flag_bigdigit != -1):
    flag_increaseDights = 1
    #  桁を増やす必要があるかどうか確認
    for i in range(flag_bigdigit-1, 0):
        # nの桁より大きい数字がablenumに存在していれば桁を増やす必要はない
        if(int(lis_n[i]) < max(ablenum)):
            flag_increaseDights = 0
            break
else:
    flag_increaseDights = 0

#print("bigdigit:{0} increace:{1}".format(flag_bigdigit, flag_increaseDights))

ans = ""
# 桁を増やす必要があるならば
if(flag_increaseDights == 1):
    for i in range(len(lis_n)+1):
        # 一桁目は0以外の最も小さな数
        if(i == 0):
            mnum = min(ablenum)
            if(mnum == 0):
                mnum = ablenum[1]
            ans += str(mnum)
        # 2桁目以降は最も小さい数
        else:
            mnum = min(ablenum)
            ans += str(mnum)
# 桁を増やす必要がなければ、各桁の数字以上の最も小さい数を使う
else:
    flag_over = 0
    for i in range(len(lis_n)):
        if(flag_over == 0):
            mnum = min(ablenum)
            # その桁以上の数になるまで大きくする
            j = 0
            while mnum < int(lis_n[i]):
                #print("mnum:{0} j:{1}".format(mnum, j))
                j += 1
                mnum = ablenum[j]
            if(mnum > int(lis_n[i])):
                flag_over = 1
            ans += str(mnum)
        else:
            mnum = min(ablenum)
            ans += str(mnum)

print(ans)


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
typedef long long ll;
const int INF = 1e+7;
typedef pair<int,int> P;

struct dijkstra{
    vector<int> color;
    vector<vector<P>> adj;
    vector<int> d;
    vector<int> p;
    int n_;
    dijkstra(int n):color(n,0),adj(n),d(n,INF),p(n,-1){
        n_ = n;
    }
    void init(){
        rep(i,n_){
            int u,k;cin>>u>>k;
            rep(j,k){
                int v,c;cin>>v>>c;
                P tmp = make_pair(v,c);
                adj[i].push_back(tmp);
            }
        }
    }
    void solve(){
        init();
        d[0] = 0;
        p[0] = -1;
        while(true){
            int mincost = INF;
            int u;
            rep(i,n_){
                if(color[i]!=2 && d[i]<mincost){
                    mincost = d[i];
                    u = i;
                }
            }
            if(mincost == INF)break;
            color[u] = 2;
            for(P v:adj[u]){    
                if(color[v.first]!=2 && d[u]+v.second < d[v.first]){
                    d[v.first] = d[u] + v.second;
                    p[v.first] = u;
                    color[v.first] = 1;
                }
            }
        }
        rep(i,n_){
            cout<<i<<" "<<d[i]<<endl;
        }
    }
};


int main(){
    int n;cin>>n;
    dijkstra dj(n);
    dj.solve();
    return 0;
}


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

int main()
{
	int n, k;
	cin >> n;
	
	int sum = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> k;
		sum += (k - 1);
	}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    string s;
    cin >> s;
    int ans = 0, x = 0;
    for (char c : s){
        if (c == 'R') x++;
        else x = 0;
        chmax(ans, x);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>

int main() {
std::string number;
do{
std::cin >> number;

int sum = 0;
for(int i = 0; number[i]; i++){
int num = number[i] - '0';
sum += num;
}
if(!(number[0] == '0')){
std::cout << sum << std::endl;
}
} while(!(number[0] == '0'));
}

Measured memory_bytes: 3192
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] a = new long[n];
		HashMap<Long, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextLong();
			if (map.containsKey(a[i])) {
				map.remove(a[i]);
			} else {
				map.put(a[i], 1);
			}
		}
		System.out.println(map.size());
	}
}


Measured memory_bytes: 67680
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    int h[1000];
    h[0] = 0;
    for (int i = 1; i <= 999; ++i)
    {
        h[i] = h[i - 1] + i;
    }
    
    cout << h[b - a] - b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long 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;
    }
}

// 二項係数計算
long long 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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// ここから開始
int n;
double sum=0;
vector<pair<double,double> > v;
// set<int> used;
// void dfs(int i, int x){
//   used.insert(x);
//   if(i!=n){
//     for(int j = 0; j < n; j++){
//       if(n!=0&&used.find(j)!=used.end()){
//         sum+=sqrt(pow((v[x].first-v[j].first),2)+pow((v[x].second-v[j].second),2));
//         }
//       dfs(i+1,j);
//     }
//   }
// }
int main(){
  cin>>n;
  for(int i = 0; i < n; i++){
    int x,y;
    cin>>x>>y;
    v.push_back(make_pair(x,y));
  }
  double x=1;
  vector<int> z;
  for(int i = 0; i < n; i++){
    z.push_back(i);
    x*=(i+1);
  }
  double sum=0;
  do{
    for(int i = 1; i < n; i++){
      // cout<<v[z[i]].first<<" "<<v[z[i-1]].first<<endl;
      sum+=sqrt((v[z[i-1]].first-v[z[i]].first)*(v[z[i-1]].first-v[z[i]].first)+(v[z[i-1]].second-v[z[i]].second)*(v[z[i-1]].second-v[z[i]].second));
    }
  }while(next_permutation(z.begin(), z.end()));

  // cout<<sum<<endl;
  cout<<fixed<<setprecision(7)<<sum/x<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = (int)1e5 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

int main()
{
    int a,b,c,n,d,e,f;
    scanf("%d %d %d",&a,&b,&c);
    d=a>b?a:b;
    e=a<b?a:b;
    d=d>c?d:c;
    f=e<c?e:c;
    e=a+b+c-d-f;
    n=0;
    while(e-f>=2)
    {
        f+=2;
        n++;
    }
    if(e==f)
    {
        n+=d-e;
    }
    else
    {
        n+=d-e;
        n+=2;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 128
<?php
list($n) = ints();
for ($i = 0; $i < $n; ++$i) list($a[], $b[]) = ints();
$c = 0;
for ($i = $n - 1; $i >= 0; --$i)
    $c += ($b[$i] - ($c + $a[$i]) % $b[$i]) % $b[$i];
echo $c;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

void fnInput(string& rsMaxNum)
{
  cin >> rsMaxNum;
}

int fnDgtDP(string sMaxNum)
{
  // dp[nPos][nSmall][nDgt3][nDgt5][nDgt7] :=
  //    nPos  : 上位 nPos 桁目まで決定
  //    nSmall: small(数字を自由に選べる)か
  //    nDgt3 : 上位 nPos 桁までで 3 を選択したかflag
  //    nDgt5 : 上位 nPos 桁までで 5 を選択したかflag
  //    nDgt7 : 上位 nPos 桁までで 7 を選択したかflag
  //                             の条件を満たす数値の数
  const vector<int> cnvnDgt = {0, 3, 5, 7};
  int nLen = sMaxNum.size();

  int dp[nLen + 1][2][2][2][2] = {};
  dp[0][0][0][0][0] = 1;

  for (int nPos = 0; nPos < nLen; ++nPos)
  {
    int nMaxDgt = sMaxNum[nPos] - '0';

    for (int nSmall = 0; nSmall < 2; ++nSmall)
      for (int nDgt3 = 0; nDgt3 < 2; ++nDgt3)
        for (int nDgt5 = 0; nDgt5 < 2; ++nDgt5)
          for (int nDgt7 = 0; nDgt7 < 2; ++nDgt7)
            for (int nx = 0; nx < cnvnDgt.size(); ++nx)
            {
              if ( !nSmall && nMaxDgt < cnvnDgt[nx] ) 
                break;
              if (( nDgt3 || nDgt5 || nDgt7) && !cnvnDgt[nx] )
                continue;

              int nTrgSmall = nSmall || (cnvnDgt[nx] < nMaxDgt);
              int nTrgDgt3  = nDgt3  || (cnvnDgt[nx] == 3);
              int nTrgDgt5  = nDgt5  || (cnvnDgt[nx] == 5);
              int nTrgDgt7  = nDgt7  || (cnvnDgt[nx] == 7);
              dp[ nPos + 1 ][ nTrgSmall ][ nTrgDgt3 ][ nTrgDgt5 ][ nTrgDgt7 ]
                += dp[nPos][nSmall][nDgt3][nDgt5][nDgt7];
            }
  }
  return dp[nLen][0][1][1][1] + dp[nLen][1][1][1][1];
}

int main()
{
  string sMaxNum;

  fnInput(sMaxNum);
  cout << fnDgtDP(sMaxNum) << endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long 

const int N = 2e5 + 9;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int f[N];

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
}

int C(int n, int k) {
	return divv(f[n], mul(f[k], f[n - k]));
}

int sl(int a, int b) {
	return C(a + b, a);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	init();

	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int i = h - a;
	int j = b - 1;
	int ans = 0;
	i--;
	j++;
	while (i >= 0 && j < w) {
		ans = add(ans, mul(sl(i, j), sl(h - 1 - i, w - 1 - j)));
		i--;
		j++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792