akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
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, k, a[200005];
set<int> S;
ll kind, ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> k;
    rep(i, 0, n) {
        int x; cin >> x;
        S.insert(x);
        a[x]++;
    }
    sort(a, a+200005);
    kind = S.size();
    rep(i, 0, 200005) {
        if (k >= kind) break;
        if (a[i] > 0) {
            kind--;
            ans += a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=500005;
//Code begin....

char s[N];
int num[N], pos=0, n, cnt;
VI a[N];
int dp[N][5];

void init(){
    int now=1;
    while (now<=n && s[now]=='0') ++now;
    FOR(i,now,n) {
        if (i==1 || s[i]!=s[i-1]) num[++pos]=1;
        else ++num[pos];
    }
    FOR(i,1,pos) {
        if (i&1) a[cnt].pb(num[i]);
        else if (num[i]>1) ++cnt;
    }
}
int main ()
{
    int sum=0;
    scanf("%d%s",&n,s+1);
    init();
    FOR(i,0,cnt) {
        if (i) FOR(j,0,a[i-1].size()-1) FOR(k,0,4) dp[j][k]=0;
        int siz=a[i].size()-1;
        FOR(j,1,siz) {
            dp[j][0]=max(dp[j-1][0]+a[i][j-1]-1,dp[j-1][3]+a[i][j-1]);
            dp[j][0]=max(dp[j][0],max(dp[j-1][1],dp[j-1][2])+1);
            dp[j][0]=max(dp[j][0],dp[j-1][4]);

            dp[j][1]=max(dp[j-1][4],max(dp[j-1][0],dp[j-1][3]));
            dp[j][1]=max(dp[j][1],max(dp[j-1][1],dp[j-1][2])+a[i][j]-1);

            if (a[i][j]>1) {
                dp[j][2]=max(dp[j-1][0]+a[i][j-1]-1,dp[j-1][3]+a[i][j-1]);
                dp[j][2]=max(dp[j][2],max(dp[j-1][1],dp[j-1][2])+1);
                dp[j][2]=max(dp[j][2],dp[j-1][4]);
            }

            dp[j][3]=max(max(dp[j-1][0],dp[j-1][1]),max(dp[j-1][2],dp[j-1][4]));
            dp[j][3]=max(dp[j][3],dp[j-1][3]);

            dp[j][4]=max(dp[j-1][4],max(dp[j-1][0],dp[j-1][3]));
            dp[j][4]=max(dp[j][4],max(dp[j-1][1],dp[j-1][2])+a[i][j]);

        }
        sum+=max(max(dp[siz][0],dp[siz][1]),max(max(dp[siz][2],dp[siz][3]),dp[siz][4]));
    }
    printf("%d\n",sum);
    return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int negative_cnt = 0;
    ll a_sum = 0;
    ll a_max_negative = 1e10;
    REP(i, n) {
        ll a;
        cin >> a;
        a_sum += abs(a);
        a_max_negative = min(a_max_negative, abs(a));
        if(a < 0) negative_cnt++;
    }

    if(negative_cnt % 2 == 0) cout << a_sum << ln;
    else cout << a_sum - a_max_negative * 2 << ln;
    return 0;
}


Measured memory_bytes: 256
def main():
	n, *p = map(int, open(0).read().split())
	c = 40000
	a = [c * i for i in range(n)]
	b = [c * (n - i) for i in range(n)]
	for i, x in enumerate(p, start=1):
		a[x - 1] += i
	print(*a)
	print(*b)


if __name__=="__main__":
	main()


Measured memory_bytes: 6236
#include <iostream>
#include <vector>
#include <utility>

using Friend = std::pair<int, int>;
using Friends = std::vector<Friend>;
using Node = std::pair<Friends, int>;

int main(void){
    int N;
    std::vector<int> us, vs, ws;
    std::cin >> N;
    for(int i = 0; i < N-1; ++i){
        int u,v,w;
        std::cin >> u >> v >> w;
        us.push_back(u);
        vs.push_back(v);
        ws.push_back(w);
    }

    auto nodes = std::vector<Node>(N+1);
    for(int i = 0; i < N-1; ++i){
        auto u = us[i];
        auto v = vs[i];
        auto w = ws[i];
        nodes[u].first.emplace_back(v, w);
        nodes[v].first.emplace_back(u, w);
    }
    nodes[1].second = 0;

    using stack_t = std::pair<int, int>;
    std::vector<stack_t> stack({stack_t(1,-1)});

    while(stack.size() > 0){
        auto last = stack[stack.size()-1];
        auto node_id = last.first;
        auto parent_id = last.second;
        stack.pop_back();
        auto node = nodes[node_id];

        for(auto child: node.first){
            auto child_id = child.first;
            auto distance = child.second;
            if(child_id == parent_id){ continue; }
            auto& child_node = nodes[child_id];
            child_node.second = (node.second + distance) % 2;
            stack.push_back(std::make_pair(child_id, node_id));
        }
    }

    for(int i = 1; i < N+1; ++i){
        std::cout << nodes[i].second << std::endl;
    }

    return 0;
}


Measured memory_bytes: 8428
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;

  cout << (n / 3) << endl;

  return 0;
}


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

const int maxn = 1e5 + 7;

vector<int> E[maxn];
bool red[maxn];
int sz[maxn];
int f[maxn];
int dep[maxn];
int jmp[maxn];
int n;
bool fw;

void dfs(int x,int pi,int h) {
	red[x] = false; dep[x] = h; jmp[x] = -1;
	if (x == n) red[x] = true;
	sz[x] = 1;
	for (int i = 0; i < E[x].size(); i++) {
		if (E[x][i] == pi) continue;
		dfs(E[x][i],x,h+1); sz[x] += sz[E[x][i]];
		if (red[E[x][i]]) red[x] = true;
	}

	//cout<<x<<" : "<<red[x]<<" : "<<sz[x]<<endl;

	if (!red[x]) return;

	for (int i = 0; i < E[x].size(); i++) {
		int z = E[x][i];
		if (z == pi || (!red[z])) continue;
		jmp[x] = z;
	}

	f[x] = sz[x]; if (jmp[x] > 0) f[x] -= sz[jmp[x]];

	//cout<<x<<" : "<<f[x]<<" : "<<jmp[x]<<endl;

	if (x == 1 || x == n) f[x]--;
	
}
	
vector<int> v;		

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	fw = false;
	for (int i = 0; i <= n; i++) {
		red[i] = false;
	}

	for (int i = 1; i < n; i++) {
		int x,y; cin>>x>>y;
		E[x].pb(y); E[y].pb(x);
	}

	dfs(1,-1,0);
	
	int cur = 1; int sp = 0;

	while (true) {
		v.pb(f[cur]); sp += f[cur];
		//cout<<cur<<" : "<<f[cur]<<" = "<<jmp[cur]<<endl;
		if (jmp[cur] >0) { cur = jmp[cur]; } else break;
	}
	
	int l;

	/*cur = 0;

	for (int i = 0; i < m; i++) {
		cur += f[i];
		if (i - 0 >= m - i && f[i] > sp-cur) fw = true;
	}*/

	if (v.size()%2 == 0) {
		l = v.size()/2 - 1;
	} else {
		l = v.size()/2;
	}
	
	int s = 0;

	for (int i = 0; i <= l; i++) {
		s += v[i]; 
	}

	if (s > sp-s) { fw = true;} else { fw = false; }

	if (fw) {
		cout<<"Fennec"<<endl;
	} else {
		cout<<"Snuke"<<endl;
	}

}


Measured memory_bytes: 15868
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <map>
using namespace std;

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

typedef pair<int, int> P;

struct Point{
  int x, y;
  Point(int a, int b){
    x = a, y = b;
  }
};

const int MAX = 510;

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

char field[MAX][MAX];
bool found[26];
vector<Point> alpha[26];
int H, W;

bool checkH(int x1, int x2, int y, char c){
  if(x1 > x2) swap(x1, x2);
  for(int j = x1 ; j <= x2 ; j++){
    if(field[y][j] != '.' && field[y][j] != c) return false;
  }
  return true;
}

bool checkW(int y1, int y2, int x, char c){
  if(y1 > y2) swap(y1, y2);
  for(int i = y1 ; i <= y2 ; i++){
    if(field[i][x] != '.' && field[i][x] != c) return false;
  }
  return true;
}

int main(){
  while(cin >> H >> W){
    rep(i, H) cin >> field[i];
    
    memset(alpha, 0, sizeof(alpha));
    memset(found, 0, sizeof(found));
    
    rep(i, H){
      rep(j, W){
	if(isalpha(field[i][j])){
	  int c = field[i][j]-'A';
	  if(!found[c]){
	    found[c] = true;
	    alpha[c].push_back(Point(j, i));
	    //alpha[c].x1 = j, alpha[c].y1 = i;
	  }
	  else{
	    alpha[c].push_back(Point(j, i));
	    //alpha[c].x2 = j, alpha[c].y2 = i;
	  }
	}
      }
    }
    
    vector<Point> cross[26];
    rep(i, 26){
      if(found[i]){
	cross[i].push_back(Point(alpha[i][0].x, alpha[i][1].y));
	cross[i].push_back(Point(alpha[i][1].x, alpha[i][0].y));
	//cross[i].x1 = alpha[i].x1, cross[i].y1 = alpha[i].y2;
	//cross[i].x2 = alpha[i].x2, cross[i].y2 = alpha[i].y1;
      }
    }
    
    rep(i, H){
      rep(j, W){
	rep(k, 4){
	  int nx = j+dx[k], ny = i+dy[k];
	  if(nx < 0 || nx > W || ny < 0 || ny > H) continue;
	  if(field[i][j] == field[ny][nx]) found[field[i][j]-'A'] = false;
	}
      }
    }
    
    int ans = 0;
    for(; ;){
    Start:;
      bool flag = false;
      rep(i, 26){
	if(alpha[i].size() == 2 && found[i]){	  
	  int X1 = cross[i][0].x, Y1 = cross[i][0].y, X2 = cross[i][1].x, Y2 = cross[i][1].y;
	  int x1 = alpha[i][0].x, y1 = alpha[i][0].y, x2 = alpha[i][1].x, y2 = alpha[i][1].y;
	  char c = 'A'+i;
	  
	  if(x1 == x2){
	    flag = checkW(y1, y2, x1, c);
	  }
	  else if(y1 == y2){
	    flag = checkH(x1, x2, y1, c);	    
	  }
	  else{
	    if(((checkH(X1, x2, Y1, c) && (checkW(Y1, y1, X1, c)))) ||
	       ((checkH(X2, x1, Y2, c) && (checkW(Y2, y2, X2, c))))){
	      flag = true;
	    }
	  }
	  
	  if(flag){
	    //cout << c << endl;
	    found[i] = false;
	    ans += 2;
	    field[y1][x1] = '.', field[y2][x2] = '.';	    
	    goto Start;
	  }
	  
	}
      }
      if(!flag) break;
    }
    cout << ans << endl;
  }  
  return 0;
}

Measured memory_bytes: 1448
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll a,b,c,d;
    string S;
    in >> S;
    //vector<ll> X(N)

    SORT(S);
    if(S[0]==S[1] && S[1]!=S[2] && S[2]==S[3]){
        out << "Yes" << endl;
    }else{
        out << "No" << endl;
    }
    
 

}

Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=200005;
pp dp[405][405];
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
pair<ll,ll> go(ll l,ll r,vector<ll>& v){
	if(l>r)return make_pair(0,0);
	if(l==r)return make_pair(0,v[l]);
	if(dp[l][r]!=make_pair(-1LL,-1LL))return dp[l][r];
	dp[l][r]={inf,inf};
	rep(i,l,r){
		pp p1=go(l,i,v), p2=go(i+1,r,v);
		if(p1.fi+p2.fi+p1.se+p2.se<dp[l][r].fi){
			dp[l][r].first=p1.fi+p2.fi+p1.se+p2.se;
			dp[l][r].second=p2.se+p1.se;
		}
	}
	return dp[l][r];
}
void solve(){
	rep(i,0,405)
		rep(j,0,405)
			dp[i][j]={-1,-1};
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(auto &x : v)
		cin>>x;
	cout<<go(0,n-1,v).first;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> DP(H + 1e4);
  for (int i = 1; i <= H; i++) DP.at(i) = 1e9;
  for (int i = 0, A, B; i < N && cin >> A >> B; i++)
    for (int j = 0; j < H; j++)
      DP.at(min(j + A, H)) = min(DP.at(min(j + A, H)), DP.at(j) + B);
  cout << DP.at(H) << "\n";
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int S1 = 0;
	int S2 = 0;
	vector<int> W( N );
	for( auto& v: W ) {
		cin >> v;
		S2 += v;
	}

	int result = INT_MAX;
	for( int i = 0; i < N; ++i ) {
		S1 += W[i];
		S2 -= W[i];

		int a = abs( S1 - S2 );
		if( a < result ) {
			result = a;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int q = 0;
void remove(int ca[7][6], int a, int b, int c, int d){
	ca[a][b] = 0;
	ca[c][d] = 0;
	int s = 0;
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 4; j++){
			while(s<2 && ca[1+i+(j+s)/4][1+(j+s)%4] == 0) s++;
			ca[1+i][1+j] = ca[1+i+(j+s)/4][1+(j+s)%4];
		}
	}
}

int calc(int c[7][6], int m){
	int dx[]={1,1,1,0,0,-1,-1,-1};
	int dy[]={1,0,-1,1,-1,1,0,-1};
	int _m = m;
	for(int i = 1;_m && i <= 5; i++){
		for(int j = 1; j <= 4; j++){
			for(int k = 0; k < 8; k++){
				if(c[i][j] && c[i][j] == c[i+dx[k]][j+dy[k]]){
					int _c[7][6];
					memcpy(_c,c,sizeof _c);
					remove(_c,i,j,i+dx[k],j+dy[k]);
					_m = min(_m,calc(_c,m-2));
				}
			}
		}
	}
	return _m;
}

int main(){
	int n;
	cin >> n;
	while(n--){
		int c[7][6];
		memset(c,0,sizeof c);
		for(int i = 1; i <= 5; i++){
			for(int j = 1; j <= 4; j++){
				cin >> c[i][j];
			}
		}
		cout << calc(c,20) << endl;
	}
}

Measured memory_bytes: 0
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#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) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int dp[3], h[3];
	dp[0] = 0;
	dp[1] = 1e9;
	dp[2] = 1e9;
	h[0] = getint();
	h[1] = getint();

	int k1 = 0;
	int k2 = 1;
	int k3 = 2;
	rep(i, N - 2) {
		h[k3] = getint();
		chmin(dp[k2], dp[k1] + abs(h[k1] - h[k2]));
		chmin(dp[k3], dp[k1] + abs(h[k1] - h[k3]));
		dp[k1] = 1e9;
		swap(k1, k2);
		swap(k2, k3);
	}
	chmin(dp[k2], dp[k1] + abs(h[k1] - h[k2]));

	printf("%d", dp[k2]);

	Would you please return 0;
}

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

int n,a[100],dp[100][10001];
int DP(int idx,int s) {
	if(idx==n) return s%10 ? s : 0;
	
	int &ret=dp[idx][s];
	if(ret!=-1) return ret;

	return ret = max(DP(idx+1,s), DP(idx+1,s+a[idx]));
}

int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);

	memset(dp,-1,sizeof(dp));
	printf("%d\n",DP(0,0));
	
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}

int main()
{
	int n,i;
	scanf("%i",&n);
	int a,b;
	vector<pair<int,pair<int,int> > > v;
	ll ans=0;
	while(n--) scanf("%i %i",&a,&b),v.pb(mp(a+b,mp(a,b)));
	sort(v.begin(),v.end());
	int f=1;
	while(v.size())
	{
		ans+=v.back().second.first*f;
		ans-=v.back().second.second*(f^1);
		f^=1;
		v.pop_back();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1912
#include<iostream>
using namespace std;
int main()
{
  int w, a, b;
  cin >> w >> a >> b;
  if(b-a-w>0)
  {
    cout  << b-a-w << endl;
  }
  else if (a-b-w>0)
  {
    cout << a-b-w << endl;
  }
  else cout << "0" << endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


typedef long long ll;


ll partition(ll A[], ll l, ll r)
{
    ll pivot = A[r - 1];
    ll gather_i = l;
    for (ll i = l; i < r - 1; i++) {
        if (A[i] <= pivot) {
            ll tmp = A[gather_i];
            A[gather_i++] = A[i];
            A[i] = tmp;
        }
    }
    A[r - 1] = A[gather_i];
    A[gather_i] = pivot;
    return gather_i;
}


#define MAX 100000
ll A[MAX];


int main(void)
{
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> A[i];
    }
    ll p = partition(A, 0, n);
    for (ll i = 0; i < n; i++) {
        if (i == p)
            cout << "[";
        cout << A[i];
        if (i == p)
            cout << "]";
        if (i != n - 1)
            cout << " ";
    }
    cout << endl;
}



Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222


vll fac, inv, invfac;
void comb_set(ll x = MAX) {
  fac.resize(x + 1, 0);
  invfac.resize(x + 1, 0);
  inv.resize(x + 1, 0);
  fac[0] = inv[1] = invfac[0] = 1;
  FOR(i, 1, x + 1) (fac[i] = fac[i - 1] * i) %= mod;
  FOR(i, 2, x + 1) (inv[i] = (mod - mod / i) * inv[mod%i]) %= mod;
  FOR(i, 1, x + 1) (invfac[i] = invfac[i - 1] * inv[i]) %= mod;
}
ll comb(ll x, ll y) {
  if (x < y) return 1;
  return fac[x] * invfac[x - y] % mod * invfac[y] % mod;
}

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


  cin >> n;
  vpll v;
  pll p;
  comb_set();
  rep(i, n) {
	cin >> p.first;
	p.second = 0;
	v.pb(p);
  }
  rep(i, n) {
	cin >> p.first;
	p.second = 1;
	v.pb(p);
  }
  sort(all(v));
  ans = 1;
  ll acnt = 0, bcnt = 0;
  if (v[0].second) bcnt++;
  else acnt++;
  FOR(i, 1, 2 * n) {
	if (v[i].second != v[i - 1].second) {
	  if (v[i].second == 0) {
		if (bcnt >= acnt) {
		  (ans *= fac[acnt]) %= mod;
		  bcnt -= acnt;
		  acnt = 0;
		}
		else {
		  (ans *= comb(max(acnt, bcnt), min(acnt, bcnt))) %= mod;
		  m = min(acnt, bcnt);
		  (ans *= fac[m]) %= mod;
		  acnt -= m;
		  bcnt -= m;
		}
	  }
	  else {
		if (acnt >= bcnt) {
		  (ans *= fac[bcnt]) %= mod;
		  acnt -= bcnt;
		  bcnt = 0;
		}
		else {
		  (ans *= comb(max(acnt, bcnt), min(acnt, bcnt))) %= mod;
		  m = min(acnt, bcnt);
		  (ans *= fac[m]) %= mod;
		  acnt -= m;
		  bcnt -= m;
		}
	  }
	}
	if (v[i].second == 0) acnt++;
	else bcnt++;
	//cout << acnt << " " << bcnt << " " << ans << endl;
  }
  (ans *= fac[acnt]) %= mod;
  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

typedef pair<ull,ull> P;

int main() {
	ull N, M;
	cin >> N >> M;
	priority_queue <P> que;
	vector <ull> A(N, 0);
	for (int ii = 0; ii < N; ++ii){
		int A;
		cin >> A;
		que.push(P(A, 1));
	}
	for (int ii = 0; ii < M; ++ii){
		ull cnt, value;
		cin >> cnt >> value;
		que.push(P(value, cnt));
	}

	ull sum = 0;
	for (int ii = 0; ii < N; ++ii){
		P tmp = que.top();
		que.pop();
		sum += tmp.first;
		tmp.second--;
		if (tmp.second > 0){
			que.push(tmp);
		}	
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 7280
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  sort(data.begin(), data.end());
  int ks = 0;
  bool h = true;
  for (int i = data[0]; i <= data[n-1]; i++) {
    ks = 0;
    for (int j = 0; j < n; j++) {
      ks += (data[j]-i)*(data[j]-i);
    }
	if (h) {
		s = ks;
		h = false;
	}
    s = min(s, ks);
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main{
	String [][] table = {
			{"wa", "", "nn", "", "wo"},
			{"a", "i", "u", "e", "o"},
			{"ka", "ki", "ku", "ke", "ko"},
			{"sa", "si", "su", "se", "so"},
			{"ta", "ti", "tu", "te", "to"},
			{"na", "ni", "nu", "ne", "no"},
			{"ha", "hi", "hu", "he", "ho"},
			{"ma", "mi", "mu", "me", "mo"},
			{"ya", "", "yu", "", "yo"},
			{"ra", "ri", "ru", "re", "ro"},
			
	};
	String order = "TLURD";

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String s = sc.next();
			for(int i = 0; i < s.length(); i += 2){
				char c1 = s.charAt(i);
				char c2 = s.charAt(i + 1);
				int num1 = c1 - '0';
				int num2 = order.indexOf(c2 + "");
				System.out.print(table[num1][num2]);
			}
			System.out.println();
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 17376
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <set>

#define PI 3.1415926535897

typedef long long ll;

using namespace std;



int main() {
    ll n;
    cin >> n;
    set<string> s;
    string temp;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        s.insert(temp);
    }
    cout << s.size();



    return 0;
}

Measured memory_bytes: 19180
s=list(input())

i=1
ans=0
mode=2
con=1
anslist=[]
if s[0]==">":
  mode=0
else:
  mode=1


while i!=len(s):

  if s[i]==">":
    if mode==0:
      con+=1
    else:
      anslist.append([con,"<"])



      mode=0
      con=1
  else:
    if mode==1:
      con+=1
    else:
      anslist.append([con,">"])

      mode=1
      con=1
  i += 1

if s[-1]=="<":
  anslist.append([con, "<"])

else:
  anslist.append([con, ">"])

i=0
while i!=len(anslist):
  try:
    if anslist[i][1]=="<":
      if anslist[i][0]<=anslist[i+1][0]:
        anslist[i][0]=anslist[i][0]-1
    else:
      if anslist[i][0]<=anslist[i-1][0] and i!=0:
        anslist[i][0]=anslist[i][0]-1

  except:
    pass
  i+=1



i=0
ans=0
while i!=len(anslist):
  ans+=anslist[i][0]*(anslist[i][0]+1)/2
  i+=1

print(int(ans))

Measured memory_bytes: 32816
import java.util.Scanner;
public class Main {
  public static void main (String[]args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    int res1000 = -1;
    int res5000 = -1;
    int res10000 = -1;

    for(int a = 0; a<=N; a++){ //aについて0~Nまで調べる
      for(int b =0; b<=N-a; b++){ //bについて0~N-aまで調べる
        int c = N-a-b;             //cは確定する
        if(10000*a+5000*b+1000*c==Y){ //条件に合うか
          res10000 = a;
          res5000 = b;
          res1000 = c;
        }
      }
    }
    System.out.println(res10000+" "+res5000+" "+res1000);



  }
}


Measured memory_bytes: 23252
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N+1)
    for i in range(N,0,-1):
        tmp = 0
        for j in range(i,N+1,i):
            tmp += B[j]
        B[i] = (tmp % 2) ^ A[i]

    ans = []
    for i in range(N+1):
        if B[i] != 0:
            ans.append(i)

    print(len(ans))
    print(*ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 71260
n = input()
floor = []
for i in range(n):
    floor.append(map(int,raw_input().split()))

bill = [ [ [ 0 for c in range(10)] for b in range(3)] for a in range(4)]

for a in floor:
    bill[a[0]-1][a[1]-1][a[2]-1] = (bill[a[0]-1][a[1]-1][a[2]-1]) + (a[3])
flg = 0
for a in bill:
    if flg == 1:
        print "####################"
    for b in a:
        print " " + " ".join(map(str,b))
        flg = 1

Measured memory_bytes: 4248
n, w = map(int,input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[float("inf")] * (10**5+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
for i in range(1, n+1):
    for j in range(1, 10**5+1):
        if j-wv[i-1][1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-wv[i-1][1]] + wv[i-1][0])
        else:
            dp[i][j] = dp[i-1][j]
for i in reversed(range(10**5+1)):
    if dp[n][i] <= w:
        print(i)
        break

Measured memory_bytes: 398904
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = long long;

int main()
{
  int A, B, C; cin >> A >> B >> C;
  int tmp = A%B;
  for(int i=1;;++i) {
    if((A*i)%B == C) {
      cout << "YES" << endl;
      break;
    } else if(i>1 && (A*i)%B == tmp) {
      cout << "NO" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

const int mxsz = 3e3 + 5;
const int mod = 1e9 + 7;

string v;

int dp[mxsz][mxsz];
bool vis[mxsz][mxsz];

int d(int n, int k)
{
	if (k<0||k>n) return 0;
	if (!n) return 1;
	if (vis[n][k]) return dp[n][k];
	
	vis[n][k] = 1;
	int sum = v[n]=='<'? d(n, k-1): d(n, k+1);
	if (v[n-1]=='<') sum += d(n-1, k-1), sum %= mod;
	else sum += d(n-1, k), sum %= mod;
	
	return dp[n][k] = sum;
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int n; cin>>n;
	cin>>v;
	
	v.push_back('<');
	cout<<d(n-1, n-1)<<'\n';
}

Measured memory_bytes: 290560
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define x first
#define y second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = (int)1e5 + 10;

#define double long double
int n;
char d[N];
P pt[N];

double f(double till){
   double x[2], y[2];
   x[0] = 1e20;//min
   x[1] = -1e20;//max
   y[0] = 1e20;
   y[1] = -1e20;

   for (int i = 0; i < n; ++i)
   {
      double ptx = pt[i].x, pty = pt[i].y;
      if (d[i] == 'R'){
         ptx += till;
      }
      else if (d[i] == 'L'){
         ptx -= till;
      }
      else if (d[i] == 'U'){
         pty += till;
      }
      else{
         pty -= till;
      }
      smax(x[1], ptx);
      smin(x[0], ptx);
      smax(y[1], pty);
      smin(y[0], pty);
   }

   return (x[1] - x[0]) * (y[1] - y[0]);
}

double binary_search(double A, double B){
   double ans = 0;

   for (int i = 0; i < 300; ++i)
   {
      double m1 = (A * 2 + B) / 3.0;
      double m2 = (A + 2 * B) / 3.0;
      if (f(m1) > f(m2)){
         ans = m2;
         A = m1;
      }
      else{
         B = m2;
      }
   }

   return f(ans);
}

int32_t main(){_

   cout << fixed << setprecision(15);
   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>pt[i].x>>pt[i].y>>d[i];
   }   

   cout<<binary_search(0, 1e18);

   return 0;
}

Measured memory_bytes: 2048
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,d=0,x=0,y=0,z=0;
  double c = 0;
  string s="",t="";
  //

  // ここから
  IN(n);
  REP(i,n){
    z += i;
  }
  OUT(z);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] counts = new int[26];

        while (true) {
            String line = br.readLine();

            if (line == null) {
                break;
            }

            for (int i = 0; i < line.length(); i++) {
                char c = line.charAt(i);
                if (isUppercase(c)) {
                    counts[c - 'A']++;
                } else if (isLowercase(c)) {
                    counts[c - 'a']++;
                }
            }
        }

        for (int i = 0; i < 26; i++) {
            System.out.println((char) (i + 'a') + " : " + counts[i]);
        }
    }

    private static boolean isUppercase(char c) {
        return (c >= 'A' && c <= 'Z');
    }

    private static boolean isLowercase(char c) {
        return (c >= 'a' && c <= 'z');
    }
}

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

int main() {
	int x1,y1,x2,y2,x3,y3,x4,y4;
	cin >> x1 >> y1 >> x2 >> y2;
	int x21 = x2 - x1;
	int y21 = y2 - y1;
	x3 = x2 - y21;
	y3 = y2 + x21;
	x4 = x3 - x21;
	y4 = y3 - y21;
	cout << x3 << ' ' << y3 << ' ' 
	     << x4 << ' ' << y4 << endl;
	return 0;
}


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

using namespace std;

int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);

	int N;
	cin >> N;

	vector<int> v(N);
	for(auto &i : v) cin >> i;

	vector<int> dp(N);
	dp[N-1] = 0;
	dp[N-2] = abs(v[N-1]-v[N-2]);

	for(int i=N-3; i>=0; i--)
		dp[i] = min(dp[i+1] + abs(v[i] - v[i+1]), dp[i+2] + abs(v[i] - v[i+2]));
	cout << dp.front();
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1e13
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    ans = min(ans, abs(r)+abs(l-r))
    ans = min(ans, abs(l)+abs(r-l))
print(ans)


Measured memory_bytes: 14384
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	vector<int> vec1(3);
	vector<int> vec2(3);
	vector<int> vec3(3);


	for (int i = 0; i < 3; i++)
	{
		cin >> vec1[i];
	}
	for (int i = 0; i < 3; i++)
	{
		cin >> vec2[i];
	}for (int i = 0; i < 3; i++)
	{
		cin >> vec3[i];
	}

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int b;
		cin >> b;
		for (int i = 0; i < 3; i++)
		{
			if (vec1[i] == b) vec1[i] = 0;
			if (vec2[i] == b) vec2[i] = 0;
			if (vec3[i] == b) vec3[i] = 0;
		}
	}

	bool bingo = false;

	//yoko
	if (vec1[0] == 0 && vec1[1] == 0 && vec1[2] == 0) {
		bingo = true;
	}
	if (vec2[0] == 0 && vec2[1] == 0 && vec2[2] == 0) {
		bingo = true;

	}
	if (vec3[0] == 0 && vec3[1] == 0 && vec3[2] == 0) {
		bingo = true;

	}

	//tate
	if (vec1[0] == 0 && vec2[0] == 0 && vec3[0] == 0) {
		bingo = true;
	}
	if (vec1[1] == 0 && vec2[1] == 0 && vec3[1] == 0) {
		bingo = true;
	}
	if (vec1[2] == 0 && vec2[2] == 0 && vec3[2] == 0) {
		bingo = true;
	}

	if (vec1[0] == 0 && vec2[1] == 0 && vec3[2] == 0) {
		bingo = true;
	}
	if (vec1[2] == 0 && vec2[1] == 0 && vec3[0] == 0) {
		bingo = true;
	}

	if (bingo) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
	ll n, k; cin >> n >> k;
	ll res = 0;
	for (ll i = k; i < n + 2; i++) {
		res += i * (n - i + 1) + 1;
		res %= MOD;
	}
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int a[200010];
 
int main()
{
    int N,C;
    cin >> N >> C;
    vector<P> v[100010];
    for(int i = 0; i < N; i++){
        int s,t,c;
        cin >> s >> t >> c;
        v[c].emplace_back(s,t);
    }
    for(int i = 0; i < 100010; i++) sort(v[i].begin(),v[i].end());
    for(int i = 0; i < 100010; i++){
        for(int j = 0; j < v[i].size(); j++){
            if(j != 0 && v[i][j-1].second == v[i][j].first){
                a[2*v[i][j-1].second+2]++;
                a[2*v[i][j].second+1]--;
            }else{
                a[2*v[i][j].first-1]++;
                a[2*v[i][j].second+1]--;
            }
        }
    }
 
    int res = a[0];
    for(int i = 1; i < 200000; i++){
        a[i] += a[i-1];
        res = max(res,a[i]);
    }
    //for(int i = 0; i < 200; i++) cout << i << ' ' << a[i] << endl;
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 4608
x,k,d = map(int,input().split())
ax = abs(x)
ad = abs(d)
import sys
if x+d*k<0:
    print(-(x+d*k))
elif 0<x-d*k:
    print(x-d*k)
else:
    m1 = ax%ad
    m2 = d-m1
    mm = min(ax%ad,d-ax%ad)
    if mm == m1:
        if (ax//ad)%2==k%2:
            print(m1)
        else:
            print(m2)
        sys.exit()
    if mm == m2:
        if (ax//ad)%2==(k+1)%2:
            print(m2)
        else:
            print(m1)
        sys.exit()

Measured memory_bytes: 9220
import java.util.*;
class Main{
    int n,a,b;
    boolean[] N;
    void run(){
	Scanner sc =new Scanner(System.in);
	while(true){
	    n=sc.nextInt();
	    a=sc.nextInt();
	    b=sc.nextInt();
	    if((n|a|b)==0)break;
	    N=new boolean[n+1];
	    N[0]=true;
	    setNum();
	    int ans=0;
	    for(int i=1;i<=n;i++){
		if(!N[i])ans++;
	    }
	    System.out.println(ans);
	}
    }
    void setNum(){
	for(int i=0;i<=n;i++){
	    if(N[i]==true){
		if(i+a<=n)N[i+a]=true;
		if(i+b<=n)N[i+b]=true;
	    }
	}
    }
    public static void main(String[] args){
	new Main().run();
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 107;

void read() {
  string s;
  cin >> s;

  set<char> cont;
  map<char, char> p;
  
  p['N'] = 'S';
  p['S'] = 'N';
  p['E'] = 'W';
  p['W'] = 'E';

  for (char c : s)
    cont.insert(c);

  bool good = true;
  for (char c : s)
    good &= cont.find(p[c]) != cont.end();

  cout << (good ? "Yes" : "No") << endl;
}


void kill() {

}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


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

int main() {
 int R;
 double ans;
 cin >> R;
 ans = 2.0 * R * 3.14159265358979;
 cout << ans << endl;
}


Measured memory_bytes: 3804
N=int(input())
ans=100000000000
for a in range(1,N):
    b=N-a
    tempa=0
    tempb=0
    for i in range(len(str(a))):
        tempa+=a%10
        a=a//10
    for j in range(len(str(b))):
        tempb+=b%10
        b=b//10
    if tempa+tempb<ans:
        ans=tempa+tempb

print(ans)


Measured memory_bytes: 9100
N,Q=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
X=[0 for i in range(N)]
for i in range(Q):
    p,x=map(int,input().split())
    X[p-1]+=x
q=[0]
reached=[0 for i in range(N)]
ans=[0 for i in range(N)]
#print(X)
while(len(q)>0):
    r=q.pop()
    ans[r]+=X[r]
    reached[r]=1
    for p in G[r]:
        if reached[p]==0:
            ans[p]+=ans[r]
            q.append(p)
print(*ans)

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

using namespace std;

int main() {
    unsigned long long int H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
    }

    else {
        if ((H * W) % 2 == 0) {
            cout << (H * W) / 2 << endl;
        }

        if ((H * W) % 2 == 1) {
            cout << (H * W + 1) / 2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<int> s;

int main(){
  cin >> N;
  s.resize(N);
  int sum = 0;
  multiset<int> nten;
  rep(i,0,N - 1){
    cin >> s[i];
    sum += s[i];
    if(s[i] % 10 != 0){
      nten.insert(s[i]);
    }
  }

  if(sum % 10 == 0){
    if(nten.empty()){
      cout << 0 << endl;
    }
    else{
      cout << sum - *nten.begin() << endl;
    }
  }
  else{
    cout << sum << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Node {
	int pos;
	int flag;
	std::vector<int> connects;
};

Node nodes[200010];
int n, m;

int curFlag;
int maxCount;

int checkAround(int pos, int curFlag) {
	int count = 0;
	std::queue<int> q;
	q.push(pos);
	nodes[pos].flag = curFlag;
	count++;
	
	int newPos;
	while (!q.empty()) {
		int curPos = q.front();
		q.pop();
		if (nodes[curPos].flag != curFlag) {
			nodes[curPos].flag = curFlag;
			count++;
		}
		
		for (int j = 0 ; j < nodes[curPos].connects.size() ; j++) {
			int newPos = nodes[curPos].connects[j];
			
			if (nodes[newPos].flag == -1) {
				nodes[newPos].flag = curFlag;
				count++;
				q.push(newPos);
			}
		}
	}
	
	
	
	return count;
}

int main()
{
	scanf("%d%d", &n, &m);
	
	for (int i = 1 ; i <= n ; i++) {
		nodes[i].flag = -1;
		nodes[i].pos = i;
	}
	
	for (int i = 0 ; i < m ; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		
		nodes[u].connects.push_back(v);
		nodes[v].connects.push_back(u);
	}
	
	maxCount = 0;
	curFlag = 1;
	for (int i = 1 ; i <= n ; i++) {
		if (nodes[i].flag == -1) {
			int count = checkAround(i, curFlag);
			if (count > maxCount)
				maxCount = count;
			curFlag++;
		}
	}
		
	printf("%d\n", maxCount);

	return 0;
}




Measured memory_bytes: 16244
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	if (a[0] == a[1] && a[0] != a[2]) {
		cout << "Yes" << endl;
	}
	else if (a[1] == a[2] && a[0] != a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=2e5,MAX_K=1e18;
ll N,K,A[MAX_N],F[MAX_N];
bool C(ll x){
	ll ret=0;
	REP(i,N){
		ll a=A[i],f=F[i];
		ret+=max(a-x/f,0ll);
	}
	return ret<=K;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
	REP(i,N)cin>>A[i];
	REP(i,N)cin>>F[i];
	sort(A,A+N);
	sort(F,F+N);
	reverse(F,F+N);
	ll lb=-1,ub=1e12;
	while(ub-lb>1){
		ll m=ub-(ub-lb+1)/2;
		if(C(m)){
			ub=m;
		}else{
			lb=m;
		}
	}
	cout<<ub<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,d1,d2;
    cin>>n;
    vector<ll> x(n+1);
    for(ll i=0;i<n+1;i++){
        cin>>x[i];
    }
    sort(all(x));
    d1=x[1]-x[0];
    for(ll i=1;i<n;i++){
        d2=x[i+1]-x[i];
        d1=gcd(d1,d2);
    }
    cout<<d1<<endl;
    return 0;
}

Measured memory_bytes: 1024
import math

X,Y= list(map(int, input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


if((X+Y) % 3 != 0):
    print(0)
    exit()

s = (-X + 2 * Y) // 3
t = (-Y + 2 * X) // 3


#print(s,t)

ans = cmb(s+t, s, 10**9+7)

print(ans)

Measured memory_bytes: 127876
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    bool check = true;
    for(int i = n;i > 0;i--){
        if(i*108 / 100 == n){
            cout << i << endl;
            check = false;
        }
        else continue;
    }
    if(check) cout << ":(" << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val i = readLine()!!.toInt()
    if (i == 25) {
        print("Christmas")
    } else if (i == 24) {
        print("Christmas Eve")

    } else if (i == 23) {
        print("Christmas Eve Eve")

    } else if (i == 22) {
        print("Christmas Eve Eve Eve")
    }
}

Measured memory_bytes: 29976
#include<stdio.h>
#include<algorithm>
#include<queue>
#define pll pair<long long, long long>
using namespace std;
int n, Q, top;
long long st[101010], Res[101000];
priority_queue<pll>PQ;
int main(){
    int i, j;
    long long t;
    scanf("%d%d",&n,&Q);
    st[++top] = n;
    for(i=1;i<=Q;i++){
        scanf("%lld",&t);
        while(top && st[top] >= t)top--;
        st[++top] = t;
    }
    PQ.push(pll(st[top],1));
    pll tp;
    for(i=top-1;i>=1;i--){
        vector<pll>TP;
        while(!PQ.empty()){
            tp = PQ.top();
            if(tp.first <= st[i])break;
            TP.push_back(tp);
            PQ.pop();
        }
        long long s = 0;
        for(j=0;j<TP.size();j++){
            s += TP[j].second*(TP[j].first/st[i]);
            if(TP[j].first%st[i]){
                PQ.push(pll(TP[j].first%st[i],TP[j].second));
            }
        }
        PQ.push(pll(st[i], s));
    }
    
    while(!PQ.empty()){
        tp = PQ.top();
        Res[1]+=tp.second;
        Res[tp.first+1]-=tp.second;
        PQ.pop();
    }
    for(i=1;i<=n;i++){
        Res[i]+=Res[i-1];
        printf("%lld\n",Res[i]);
    }
}

Measured memory_bytes: 6248