akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s;
int32_t main(){
CODE_START;
//ifstream cin("input.in")
cin>>s;
if(s[0]==s[2]&&s[1]==s[3]&&s[1]!=s[2]){
    rc("Yes");
}
if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2]){
    rc("Yes");
}
if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]){
    rc("Yes");
}
cout<<"No";
return 0;}




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

int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  d = N % 10;
  c = (N % 100 - d) / 10;
  b = (N % 1000 - d - 10 * c) / 100;
  a = (N - d - 10 * c - 100 * b) / 1000;
  
  if (a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int W, H, N;
	cin >> W >> H >> N;
	vector<P>PO(N);
	rep(i, N) {
		cin >> PO[i].first >> PO[i].second;
	}
	int ans = 0;
	rep(i, N - 1) {
		if ((PO[i].first - PO[i+1].first) * (PO[i].second - PO[i+1].second) > 0) {
			ans+= max(abs(PO[i].first - PO[i + 1].first), abs(PO[i].second - PO[i + 1].second));
		}
		else {
			ans += abs(PO[i].first - PO[i + 1].first) + abs(PO[i].second - PO[i + 1].second);
		}
	}
	cout << ans << endl;
}


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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sull(x) scanf("%llu",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf
#define clean fflush(stdout)

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};
///ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; /// 8 Direction
///ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; /// Knight Direction

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll bigmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=bigmod(a,b/2)%mod;
    x=(x*x)%mod;
    if(b%2)x=(x*a)%mod;
    return x;
}

ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
        ...ENDING OF TEMPLATE...
*/

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    /** Use "long double"(%Lf) instead of double for precision safety*/
    ll tst,a,b,c,k,n,m,ans=0,t=0;
    double num;
    sl(a),sf(num);
    b=(ll)round(num*100);
    ll res = (a*b)/100;
//    cout<<a<<" "<<b<<" "<<res<<endl;
    cout<<res<<endl;



    return 0;
}


Measured memory_bytes: 3732
n = int(input())
A = list(map(int, input().split()))
total, nums = 0, {}
for n in A:
    total += n
    if n in nums:
        nums[n] += 1
    else:
        nums[n] = 1

for _ in range(int(input())):
    b, c = map(int, input().split())
    amt = 0
    if b in nums:
        amt = nums.pop(b)
        total -= amt * b
    
    if c in nums:
        nums[c] += amt
    else:
        nums[c] = amt
    total += amt * c
    print(total)

Measured memory_bytes: 23784
#include<stdio.h>
#include<math.h>
#include<string.h>

int main(){
	
	int s=1,max=0;
	int a;
	int i=0;

	for(i=0;i<3;i++){
		scanf("%d",&a);
		s*=a;
		if(a>max){
			max=a;
		}
	}

	s/=max;
	s/=2;
	
	printf("%d\n",s);
	
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
import math

X=int(input())

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
P=callIsPrime(2*10**5)

for i in range(len(P)):
    if P[i]>=X:
        print(P[i])
        break

Measured memory_bytes: 3716
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
ac,wa = 0,0
for i in range(m):
    p,S = input().split()
    if dic[p] != -1:
        if S == 'AC':
            wa += dic[p]
            ac += 1
            dic[p] = -1
        else:
            dic[p] += 1
print(ac,wa)


Measured memory_bytes: 23244
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var K = vals[1];
        var sunukes = new int[N];
        for (int i = 0; i < K; i++)
        {
            var d = int.Parse(Console.ReadLine());
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            foreach (var v in vals)
            {
                sunukes[v - 1]++;
            }
        }

        Console.WriteLine(sunukes.Count(v => v == 0));
    }
}

Measured memory_bytes: 28356
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

const int maxN = 20; int n;
int mat[3][maxN];

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < 3; i ++)
    for (int j = 0; j < n - (i == 2); j ++)
      scanf("%d", &mat[i][j]);


  int ans = 0;
  for (int i = 0; i < n; i ++)
    ans += mat[1][mat[0][i] - 1];

  for (int i = 0; i < n - 1; i ++)
    if (mat[0][i + 1] == mat[0][i] + 1)
      ans += mat[2][mat[0][i] - 1];

  printf("%d\n", ans);

  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (6e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];
    vector<ll> tx = x, ty = y;
    SORT(tx);SORT(ty);
    ll ans = MAXINF;
    REP(x1, N)REP(x2, x1)REP(y1, N)REP(y2, y1){
            ll minx = min(tx[x1],tx[x2]);
            ll maxx = max(tx[x1],tx[x2]);
            ll miny = min(ty[y1],ty[y2]);
            ll maxy = max(ty[y1],ty[y2]);
            int k = 0;
            REP(l, N)if(minx<=x[l]&&x[l]<=maxx&&miny<=y[l]&&y[l]<=maxy)k++;
            if(k>=K){
                chmin(ans, (maxx-minx)*(maxy-miny));
            }
    }
    pr(ans);
}

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

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    vector<ll> A(N);
    for(ll i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    ll ans = 1;
    ll inc = 0;//1=inc--2=dec
    for(ll i = 0; i < A.size() - 1; i++) {
        if (A.at(i) == A.at(i + 1)) {
            A.erase(A.begin() + i + 1);
            i--;
        }
    }
    N = A.size();
    for(ll i = 1; i < N - 1; i++) {
        if((A.at(i - 1) - A.at(i))*(A.at(i) - A.at(i + 1)) < 0) {
            ans++;
            A.at(i) = A.at(i + 1);
            //cout << i << ':' << ((A.at(i - 1) - A.at(i))*(A.at(i) - A.at(i + 1)) < 0) << endl;
        }
    }

    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 4060
import java.util.Scanner;

public class Main{
public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a<b){
        System.out.println("a < b");
    }else if(a>b){
        System.out.println("a > b");
    }else if(a==b){
        System.out.println("a == b");
    }

    sc.close();
}
}


Measured memory_bytes: 26392
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>
#include <cmath>
using namespace std;
using ll = long long;

struct Corr {
    ll y;
    ll x;
    ll depth;
};

ll N, M;  
ll s_y, s_x, g_y, g_x;  
ll y, x, depth;  
vector<string> vec,orig;  
queue<Corr> q;

vector<ll> y_vec = {0, 0, -1, +1};  
vector<ll> x_vec = {-1, +1, 0, 0};  

ll bfs() {
    while (!q.empty()) {
        Corr now = q.front(); q.pop();  
        y = now.y, x = now.x, depth = now.depth;  

        
        if (y == g_y && x == g_x) return depth;

        
        for (ll i = 0; i < 4; ++i) {
            Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
            if (0 <= next.y && next.y <= N-1 && 0 <= next.x && next.x <= M-1 && vec[next.y][next.x] == '.') {
                vec[next.y][next.x] = 'x';  
                q.push(next);
            }
        }
    }
    return 0;
}

int main() {
    // input
    cin >> N >> M ;
    int ans=0,fin=0;
    g_y=4;g_x=5;
    s_y--, s_x--, g_y--, g_x--;  
    vec.resize(N); for (ll i = 0; i < N; ++i) cin >> vec[i];
    orig.resize(N);
    orig=vec;


    Corr start = {2-1, 2-1, 0};

    for (int i = 0; i < N; ++i) {
        for (int ii = 0; ii < M; ++ii) {
            if (orig[i][ii]=='.'){
                s_y=i;
                s_x=ii;
                for (int j = 0; j < N; ++j) {
                    for (int jj = 0; jj < M; ++jj) {
                        if (orig[j][jj]=='.'){
                            g_y=j;
                            g_x=jj;
                            vec=orig;
                            start = {s_y, s_x, 0}; 
                            while (!q.empty()) q.pop();
                            q.emplace(start);  
                            ans=bfs();
                            //cout<<s_y<<" "<<s_x<<" "<<g_y<<" "<<g_x<<" :"<<ans<<endl;
                            fin=max(ans,fin);
                        } else{
                            continue;
                        }
                    }
                }
            } else{
                continue;
            }
        }
    }

    cout<<fin<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
char c[101];
int main() 
{
	cin>>c;
	int n=strlen(c);
	bool b=0;
	for(int i=0;i<n;i++)
	{
		if(c[i]=='C')
		{
			b=1;
		}
		if(b&&c[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = [0] + list(map(int, input().split())) + [0]
s = 0
for i in range(n+1):
    s += abs(A[i+1]-A[i])
for i in range(1, n+1):
    print(s-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 66284
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}



signed main(){
	int N;
	cin>>N;
	cout<<ceil2(N,2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> P;
struct edge {int to, cost;};
const int INF = 1001001001;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<edge>> g(10);
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++) {
			int c;
			cin >> c;
			g[j].push_back(edge{i, c});
		}
	int d1[10];

	fill(d1, d1+10, INF);
	d1[1] = 0;
	priority_queue<P, vector<P>, greater<P>> pque;
	pque.push(P(0, 1));
	while (!pque.empty()) {
		P p = pque.top(); pque.pop();
		int v = p.second;
		if (p.first > d1[v]) continue;
		for (edge e : g[v]) {
			if (d1[e.to] > d1[v] + e.cost) {
				d1[e.to] = d1[v] + e.cost;
				pque.push(P(d1[e.to], e.to));
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			if (a == -1) continue;
			ans += d1[a];
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int x; cin >> x;
    int rem = x % 100;
    if (0 <= x % 100 && rem <= 5 * (x / 100)) cout << 1 << endl;
    else cout << 0 << endl;
}

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

using namespace std;

#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int N;
	bool F[100][10];
	llong P[100][11];
	llong ret = -inf;
	cin >> N;
	for(int i = 0; i < N; i++)
		for(int j = 0; j < 10; j++)
			cin >> F[i][j];

	for(int i = 0; i < N; i++)
		for(int j = 0; j <= 10; j++)
			cin >> P[i][j];

	for(int i = 1; i < 1<<10; i++){
		bitset<10> check(i);
		llong res = 0;
		for(int j = 0; j < N; j++){
			int cnt = 0;
			for(int k = 0; k < 10; k++){
				if(check[k] && F[j][k])
					cnt++;
			}
			res += P[j][cnt];
		}
		ret = max(ret, res);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] str = S.toCharArray();
        int[] num = new int[26];
        for(int i = 0;i < S.length();i++){
            num[str[i] - 'a'] ++;
        }
        for(int i = 0;i < 26;i++){
            if(num[i] > 0){
                continue;
            }
            else{
                System.out.println((char)('a' + i));
                return;
            }
        }
        System.out.println("None");
    }
}


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

int r[31];
int main(){
	int w,n;
	cin >> w >> n;
	for(int i = 1 ; i <= w ; i++) r[i] = i;
	for(int i = 0 ; i < n ; i++){
		int a,b;
		scanf("%d,%d",&a,&b);
		swap(r[a],r[b]);
	}
	for(int i = 1 ; i <= w ; i++)
		cout << r[i] << endl;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,a,b;
  cin>>n>>a>>b;
  int64_t count=n/(a+b);
  int64_t rest=n%(a+b);
  int64_t ans=a*count;
  ans+=min(a,rest);
  cout<<ans<<endl;
  return 0;
}

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

void printer(int *, int);
void CountingSort(int *, int *, int, int);

int main(){
  int i, n, k=0;
  int *A, *B;

  // input
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
    if(k < A[i]) k = A[i];
  }

  CountingSort(A, B, k, n);

  printer(B, n);

  return 0;
}

void printer(int *array, int n){
  int i;
  for(i=0; i<n; i++){
    printf("%d",array[i]);
    if(i != n-1) printf(" ");
    else printf("\n");
  }
}

void CountingSort(int *A, int *B, int k, int n){
  int i, j, *C;

  C = (int *)malloc(sizeof(int) * k+1);
  memset(C, 0, sizeof(int) * k+1);

  for(i=0; i<n; i++)  C[A[i]] ++;

  for(i=1; i<=k; i++)  C[i] += C[i-1];

  for(i=n-1; i>=0; i--){
    B[C[A[i]]-1] = A[i];
    C[A[i]] --;
  }

}



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

main(){
  int N,M;
  cin >> N >> M;
  priority_queue<int> A;
  int tmp;
  for(int ii=0;ii<N;ii++){
    cin >> tmp;
    A.push(tmp);
  }
  for(int ii=0;ii<M;ii++){
    tmp=A.top();
    A.pop();
    A.push(tmp/2);
  }
  long ans=0;
  for(int ii=0;ii<N;ii++){
    ans+=A.top();
    A.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
public class Main {

	static final int[] nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

	public static void main(String[] args) {

		StringBuilder sb = new StringBuilder();
		for (int i : nums) {
			for (int j : nums) {
				sb.append(i + "x" + j + "=" + i * j + "\n");
			}
		}
		System.out.print(sb.toString());
	}
}

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

int main(){
    long long a, b;
    cin >> a >> b;
    if (a * b < 0) cout << "Zero" << endl;
    else if (a > 0 && b > 0) cout << "Positive" << endl;
    else {
        if (abs(a - b) % 2) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}

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

static const int N = 100;

int main(){
  int M[N][N];
  int n,u,k,v;

  cin >> n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j] = 0;
    }
  }

  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }
  return 0;
}



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

int main() { 
  int N;
  cin >> N;
  int alice=0, bob=0;
  
  vector<int> card(N);
  for(int i=0; i<N; i++){
    cin >> card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  for(int i=0; i<N; i+=2){
    alice+=card.at(i);
  }
  for(int i=1; i<N; i+=2){
    bob+=card.at(i);
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int l = (n - 1) * (n - 2) / 2;
    if (k > l) {
        cout << -1 << endl;
        return 0;
    }
    cout << n - 1 + l - k << endl;
    for (int i = 0; i < n - 1; ++i) {
        cout << 1 << " " << i + 2 << endl;
    }
    int i = 2, j = 3;
    for (int m = l - k; m > 0; --m) {
        cout << i << " " << j << endl;
        if (++j > n) {
            ++i;
            j = i + 1;
        };
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define MP make_pair
#define rep(i, n) for(int i = 0; i < n; i ++)
#define rep1(i, a, b) for(int i = a; i < b; i ++)
#define per1(i, a, b) for(int i = a; i >= b; i --)
typedef long long LL;
int main(void){
	int n; scanf("%d", &n);
	bool gg = 1;
	rep1(i, 1, n+1){
		int v; scanf("%d", &v);
		if(v % 2 == 1) gg = 0;
	}
	puts(gg ? "second" : "first");
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	long long N;

	cin >> N;

	long long ans = 0;
	int ok = 1;
	long long m = 1000000009;
	for(long long i = 0; i<N; i++){
		long long x;
		cin >> x;
		if(x < 0) ok *= -1;
		else if( x == 0) ok = 1;
		ans += abs(x);
		m = min(m, abs(x));
	}
	if(ok < 0){
		ans -= abs(m) * 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
x1, y1, x2, y2 = map(int, input().split())
length1 = x2 - x1
length2 = y2 - y1
x3 = x2 - length2
y3 = y2 + length1
x4 = x3 - length1
y4 = y3 - length2
print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))


Measured memory_bytes: 2940
#include <iostream>
#define F(i,n) for(int i=0;i!=n;i++)
long long M=1e9+7,n,k,dp[102][9999],si=1;
int main(){
std::cin>>n>>k,k++;
F(i,n-1) si=si*k%M;
si=si*n*k*(k-1)/2%M;
dp[n+1][0]=1;
F(i,n) F(a,k) F(h,4000) if(dp[h]>0)
if(a<=n-i) dp[n-i][h+(h+a)/(n-i)]=(dp[n-i][h+(h+a)/(n-i)]+dp[n-i+1][h])%M;
else dp[n-i][h]=(dp[n-i][h]+dp[n-i+1][h])%M;
F(i,4000) si=(si-dp[1][i]*i);
std::cout<<(si%M+M)%M;
}


Measured memory_bytes: 6144
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int n, m;
	get(n, m);
	printf("%d\n", (n - 1) * (m - 1));
}


Measured memory_bytes: 3708
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

bool numlist[1000001];
bool is_not_ans[1000001];
bool is_double[1000001];

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> a_sort(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		a_sort[i] = a[i];
		if (numlist[a[i]] == false){
			numlist[a[i]] = true;
		}else{
			is_double[a[i]] = true;
		}
	}

	sort(a_sort.begin(), a_sort.end());
	a_sort.erase(unique(a_sort.begin(), a_sort.end()), a_sort.end());

	for (int i = 0; i < a_sort.size(); i++){
		if (is_not_ans[a_sort[i]]) continue;
		for (int j = 2; j*a_sort[i] <= 1000000; j++){
			is_not_ans[j*a_sort[i]] = true;
		}
	}

	int coun = 0;
	for (int i = 0; i < n; i++){
		if (!is_not_ans[a[i]] && !is_double[a[i]]){
			coun++;
		}
	}
	cout << coun << endl;
	return 0;
}


Measured memory_bytes: 7724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {

    int N;
    cin >>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) {
        cin >>A[i];
    }
    sort(A.begin(),A.end());
    cout <<(A[N-1]-A[0]);
    
    return 0;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int sum = 0;
  cin >> N;
  int tmp = N;
  while (tmp > 0) {
    sum += tmp % 10;
    tmp /= 10;
  }
  if (N % sum == 0) 
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  for(int i=A;i<B+1;i++){
    if(i%N==0){
      cout<<"OK"<<endl;
    break;}
     else if(i%N!=0&&i==B){
       cout<<"NG"<<endl;}
    
  }
}
    

Measured memory_bytes: 3636
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif (N == 1 and M >= 2) or (M == 1 and N >= 2):
    print(max(N, M) - 2)
else:
    print((N - 2) * (M - 2))


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
	int N;
	long int K;
	int Q;
	int i;
	scanf("%d%ld%d",&N,&K,&Q);
	int A[Q];
	for(i=1;i<Q+1;i++){
		scanf("%d\n",&A[i]);
	}
	long int B[N];
	for(i=1;i<N+1;i++){
		B[i]=K-Q;
	}
	for(i=1;i<Q+1;i++){
		B[A[i]]++;
	}
	for(i=1;i<N+1;i++){
		if(B[i]>0){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
}	

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int visited[100][100],s1,s2;
char m[100][100];
void dfs(int x,int y,char c)
{
 //   cout<<x<<y<<endl;
    visited[x][y]=1;
    if(x-1>=0&&m[x-1][y]==c&&visited[x-1][y]==0)
    {
        dfs(x-1,y,c);
    }
    if(y-1>=0&&m[x][y-1]==c&&visited[x][y-1]==0)
    {
        dfs(x,y-1,c);
    }
    if(x+1<s1&&m[x+1][y]==c&&visited[x+1][y]==0)
    {
        dfs(x+1,y,c);
    }
    if(y+1<s2&&m[x][y+1]==c&&visited[x][y+1]==0)
    {
        dfs(x,y+1,c);
    }
}
int main()
{
    while(scanf("%d%d",&s1,&s2)!=EOF)
    {
        memset(visited,0,sizeof(visited));
        int ans=0;
        getchar();
        if(s1==0&&s2==0)
            break;
        for(int i=0;i<s1;i++)
        {
            for(int j=0;j<s2;j++)
            {
                scanf("%c",&m[i][j]);
            }
            getchar();
        }
        for(int i=0;i<s1;i++)
        {
            for(int j=0;j<s2;j++)
            {
                if(visited[i][j]==0)
                {
               //     cout<<'!'<<endl;
                    ans++;
                    dfs(i,j,m[i][j]);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



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

using static Input;
using static Util;
class Program
{
    static int[][] N;

    static void INPUT()
    {
        N = new int[3][];
        N[0] = LineInt();
        N[1] = LineInt();
        N[2] = LineInt();
    }
    static void OUT()
    {
        for (var y = 0; y < 3; y++)
        {
            var m = N[y].Min();
            for (var x = 0; x < 3; x++)
                N[y][x] -= m;
        }
        for (var x = 0; x < 3; x++)
        {
            var m = new int[]{ N[0][x], N[1][x], N[2][x] }.Min();
            for (var y = 0; y < 3; y++)
                N[y][x] -= m;
        }

        var b =
        N[0].Max() == 0 &&
        N[1].Max() == 0 &&
        N[2].Max() == 0;

        Console.WriteLine(b ? "Yes":"No");

    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        //INPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13524
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

int main(){
  
  int n;
  cin>>n;
  
  vector<int> dp(45);
  dp[0]=dp[1]=1;
  
  for(int i=2;i<=44;i++){
    dp[i]=dp[i-1]+dp[i-2];
  }
  
  cout<<dp[n]<<endl;
      
  return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int>a(3),dp(3),dp_new(3,0);

  for(int x = 1;x<=n;x++){
        cin>>a[0]>>a[1]>>a[2];
    for(int i =0;i<3;i++){
        for(int j =0;j<3;j++){
            if(i!=j){
                dp_new[j] = max(dp_new[j], dp[i]+a[j]);
               // cout<<dp_new[j]<<"...";
            }
        }
    }
    dp = dp_new;
  }
  cout<<max(dp[0],max(dp[1],dp[2]))<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int N = 410;
const ll inf = 1e18+10;
ll a[N];
ll ps[N];
ll dp[N][N];
int n,k;
ll sum(int i,int j){
    if(i==0)return ps[j];
    else return ps[j]-ps[i-1];
}
int main(){
  scanf("%d",&n);
  for(int i=0;i<=n;++i){
      for(int j=0;j<=n;++j){
          if(i==j)dp[i][j] = 0;
          else dp[i][j] = inf;
      }
  }a[0] = 0;
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  ps[0] = a[0];
  for(int i=1;i<=n;++i){
      ps[i] = ps[i-1]+a[i];
  }
  for(int L=n-1;L>=0;--L){
      for(int R=L;R<n;++R){
          if(L==R){
              dp[L][R] = 0;
          }else{
              dp[L][R] = inf;
              for(int i=L;i<=R-1;++i){
                dp[L][R] = min(dp[L][R],dp[L][i]+dp[i+1][R]+sum(L,R));  
              }
          }
      }
  }
  cout<<dp[0][n-1]<<endl;
//   for(int l = 1;l<=n;++l){
//       for(int i=0;i<n;++i){
//           int j = i+l-1;
//           for(int k=i;k<=min(j,n);++k){
//               dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+a[i]+a[k]+a[j]);
//           }
//       }
//   }
//   cout<<dp[0][n-1]<<endl;
  return 0;
}

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

int A, B, C, D, E, F;
bool chk1[3010], chk2[3010];

int main() {
    scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F);
    chk1[0] = chk2[0] = 1;
    for (int i = 1; i <= F; i++) {
        if (i >= A * 100) chk1[i] |= chk1[i - A * 100];
        if (i >= B * 100) chk1[i] |= chk1[i - B * 100];
        if (i >= C) chk2[i] |= chk2[i - C];
        if (i >= D) chk2[i] |= chk2[i - D];
    }
    double ans = 0;
    int tmp1 = 0, tmp2 = 0;
    for (int i = 1; i <= F; i++) {
        for (int j = 0; i + j <= F; j++) {
            if (1.0 * j / i > 1.0 * E / 100) continue;
            if (chk1[i] && chk2[j] && 1.0 * j / (i + j) >= ans) {
                ans = 1.0 * j / (i + j);
                tmp1 = i + j, tmp2 = j;
            }
        }
    }
    printf("%d %d\n", tmp1, tmp2);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	bool prime[1000000];
	for(int i=0;i<=1000000;i++)
		prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000000;i++)
		if(prime[i])
			for(int j=2*i;j<=1000000;j+=i)
				prime[j]=false;
	int sum[10001]={0};
	int index=1;
	for(int i=0;i<=1000000;i++){
		if(index>10000)
			break;
		if(prime[i])
			sum[index]=sum[index-1]+i,index++;
	}
	int N;
	while(cin >> N,N)
		cout << sum[N]	<<endl;
	return 0;
}	

Measured memory_bytes: 2184
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main(){
ll n,m;
  cin>>n;
  m=1e9+7;
  ll a[n],s=0;
  for(int i=0;i<n;i++){
  cin>>a[i];
    s+=(a[i]%m);
  }
ll ans=0;
  for(int i=0;i<n;i++){
  s-=a[i];
    ans= (ans%m + ((s%m)*(a[i]%m)%m))%m;
  }
  cout<<ans;
}

Measured memory_bytes: 5108
def readinput():
    x,k,d=map(int,input().split())
    return x,k,d

def main(x,k,d):
    x=abs(x)
    q=x//d
    r=x%d
    if k<q:
        ans=x-k*d
    else:
        if (k-q)%2==0:
            ans=r
        else:
            ans=d-r
    return ans

if __name__=='__main__':
    x,k,d=readinput()
    ans=main(x,k,d)
    print(ans)


Measured memory_bytes: 9184
N = int(input())
A = list(map(int,input().split()))
acu = []
acu.append(A[0])
acu_r = []
acu_r.append(A[-1])
for i in range(1,N-1):
  acu.append(acu[-1] + A[i])
for i in range(N-2,0,-1):
  acu_r.append(acu_r[-1] + A[i])
#print(acu)
#print(acu_r)
ans = float("inf")
for i in range(N-1):
  ans = min(ans,abs(acu[i] - acu_r[N - (i + 2)]))
print(ans)



Measured memory_bytes: 28600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000010;
unordered_map<int,int> m;

int main(){
    int n;
    cin >> n;
    bool st[n + 1];
    int ans = 0;
    int x = (int)sqrt(n);
    for(int i = 2;i<=x;i++){
        for(int j = 2;i * j <= n;j++){
            if(j > x) m[i*j] += 2;
            else m[i*j] += 1;
        }
    }
    for(int i = 2;i<n;i++){
        ans += m[i];
    }
    cout << ans + n * 2 - 3 << endl;
    return 0;
}

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

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main(){
    int N , D;
    cin >> N >> D;
    int start = 1; 
    FOR(i, 1 , N/3 + 2){
        start = start + 2 * D;
        if(N <= start){
            cout << i;
            break;
        }  
        if(N > start){
            start += 1;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c, vector<int>(c)), col(n, vector<int>(n));
    rep(i, c)rep(j, c)cin >> d[i][j];
    rep(i, n)rep(j, n)cin >> col[i][j];
    vector<map<int, int>> mp(3);
    rep(i, n)rep(j, n){
        mp[(i+j)%3][col[i][j]-1]++;
    }

    int ans = 1001001001;
    rep(i, c)rep(j, c)rep(k, c){
        if(i==j || j==k || k==i)continue;
        int sum = 0;
        rep(l, 3){
            for(auto it = mp[l].begin(); it != mp[l].end(); it++){
                int color = it->first;
                int num = it->second;
                if(l == 0)sum += d[color][i] * num;
                else if(l == 1)sum += d[color][j] * num;
                else sum += d[color][k] * num;
            }
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

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

    cout << N - M + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;


fn main() {
    let s = read_one::<String>().chars().collect::<Vec<char>>();
    let mut diff = 1000000;
    for i in 0..s.len() - 2 {
        let x = s[i].to_digit(10).unwrap() * 100 + s[i + 1].to_digit(10).unwrap() * 10 + s[i + 2].to_digit(10).unwrap();
        if ((x as isize) - 753).abs() <= diff {
            diff = ((x as isize) - 753).abs();
        }
    }
    println!("{}", diff);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

constexpr int MAXN = 3e3 + 1;
int table[MAXN][MAXN];
// table[i][j] = length of lcs in s[..i], t[..j]

int main(void)
{
    string s, t;
    cin >> s >> t;
    int a = s.length();
    int b = t.length();
    s = " " + s;
    t = " " + t;

    for (int i = 0; i < MAXN; i++)
        table[0][i] = table[i][0] = 0;

    for (int i = 1; i <= a; i++)
        for (int j = 1; j <= b; j++)
        {
            if (s[i] == t[j])
                table[i][j] = 1 + table[i - 1][j - 1];
            else
                table[i][j] = max(table[i - 1][j], table[i][j - 1]);
        }

    stack<char, vector<char>> lcs;
    int n = table[a][b];

    while (n)
    {
        if (s[a] == t[b])
        {
            lcs.push(s[a]);
            a--;
            b--;
            n--;
        }
        else if (a > 1 && table[a - 1][b] == table[a][b])
            a--;
        else
            b--;
    }

    while (!lcs.empty())
    {
        cout << lcs.top();
        lcs.pop();
    }
    cout << "\n";
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N,Y;cin>>N>>Y;
  // N毎のうち、10000が出せるパターンを全パターン列挙
  // 5000と1000を残りで分割
  int max_cnt=min(N,Y/10000);

  REP(i,max_cnt+1) {
    int max_cnt2=min(N-i,(Y-10000*i)/5000);
    REP(j,max_cnt2+1) {
      if (10000*i+5000*j+1000*(N-i-j)==Y) {
        cout<<i<<' '<<j<<' '<<(N-i-j)<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;

  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

int main(void){
    int H, W; cin >> H >> W;
    vector<int> alpha(30, 0);
    for(int i = 0; i < H; i++){
        string s; cin >> s;
        for(int j = 0; j < W; j++){
            char c = s[j];
            alpha[c - 'a']++;
        }
    }
    int mul4 = 0;
    int mul2 = 0;
    int mod2is1 = 0;
    for(int i = 0; i < alpha.size(); i++){
        if(alpha[i] == 0) continue;
        if(H%2 == 0 && W%2 == 0){
            if(alpha[i] % 4 != 0){
                cout << "No" << endl;
                return 0;
            }
        }else if((H%2 == 1 && W%2 == 0) || (H%2 == 0 && W%2 == 1)){
            if(alpha[i] % 4 == 0) continue;
            else if(alpha[i] % 2 == 0) mul2++;
            else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(alpha[i] % 4 == 0) continue;
            else if(alpha[i]%2 == 0) mul2++;
            else{
                mod2is1++;
            }
        }
    }
    if(H%2 == 0 && W%2 == 0){
        cout << "Yes" << endl;
        return 0;
    }else if((H%2 == 1 && W%2 == 0)){
        if(mul2 <= W/2){
            cout << "Yes" << endl;
            return 0;
        }
    }else if(H%2 == 0 && W%2 == 1){
        if(mul2 <= H/2){
            cout << "Yes" << endl;
            return 0;
        }
    }else{
        if(mod2is1 == 1 && mul2 <= W/2 + H/2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[200001],b[200001],c[200001];
inline long long read()
{
   long long sum=0,x=1;
   char ch=getchar();
   while (ch<'0'||ch>'9')
   {
       if (ch=='-')
	     x=-1;
	   ch=getchar();
   }
   while (ch>='0'&&ch<='9')
   {
   	   sum=sum*10+ch-'0';
	   ch=getchar();
   }
   return sum*x;
}
inline void write(long long x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }
    if (x>9)
      write(x/10);
    putchar(x%10+'0');
    return;
}
long long find(long long k)
{
    int l=1,r=n+1;
    while (l<r)
	{
        int mid=(l+r)/2;
        if (c[mid]>=k)
		  r=mid;else
		  l=mid+1;
    }
    return l;
}
int main()
{
    n=read();
    for (register int i=1;i<=n;++i)
	  a[i]=read();
    for (register int i=1;i<=n;++i)
	  b[i]=read();
    long long ans=0;
    for (register int k=1;k<30;++k)
	{
        long long x=(1<<k)-1;
        for (register int i=1;i<=n;++i)
		  c[i]=b[i]&x;
        sort(c+1,c+1+n);
        long long s=0; 
        for (register int i=1;i<=n;++i)
          s+=n-find((1<<(k-1))-(a[i]&x))+1;
        for (register int i=1;i<=n;++i)
          s-=find((1<<k)+(1<<(k-1))-(a[i]&x))-find((1<<k)-(a[i]&x));
        if (s%2==1)
		  ans+=(1<<(k-1));
    }
    write(ans);
    return 0;
}

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

int sum_(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B, sum = 0;
  cin >> N >> A >> B;

  rep(i, N) {
    if (A <= sum_(i+1) && sum_(i+1) <= B) sum += i+1;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w;
    cin >> h >> w;
    vector<string> M(h);
    for (int i = 0; i < h; ++i) {
        cin >> M[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (M[i][j] == '#') {
                row[i] = col[j] = true;
            }
        }
    }

    vector<string> res;
    for (int i = 0; i < h; ++i) {
        string s;
        for (int j = 0; j < w; ++j) {
            if (row[i] && col[j]) {
                s += M[i][j];
            }
        }
        if (s.length() > 0) {
            res.push_back(s);
        }
    }

    for (auto& s : res) {
        cout << s << "\n";
    }
    return 0;
}

Measured memory_bytes: 256