akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int dp[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int main(){
	int H,W;
	char S[25][25];
	scan(H>>W);
	rep(i,H){
		scanf("%s",S[i+1]+1);
	}
	rep(j,W+2){
		S[0][j]='#';
		S[H+1][j]='#';
	}
	rep(i,H+2){
		S[i][0]='#';
		S[i][W+1]='#';
	}

	int ans=0;
	rep1(i,H){
		rep1(j,W){
			if(S[i][j]=='.'){
				int dis[25][25];
				fill(dis[0],dis[24],INF);
				dis[i][j]=0;
				vpint record;
				record.push_back({i,j});
				rep1(count,INF){
					vpint before=record;
					record.clear();
					for(auto z:before){
						int y=z.first,x=z.second;
						rep(k,4){
							int nexty=y+dp[k][0],nextx=x+dp[k][1];
							if(S[nexty][nextx]=='.'&&dis[nexty][nextx]>count){
								dis[nexty][nextx]=count;
								ans=max(ans,count);
								record.push_back({nexty,nextx});
							}
						}
					}
					if(record.empty()) break;
				}

			}
		}
	}
	prin(ans);
	return 0;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int a[3][3];
    rep(i, 3)
    {
        rep(j, 3)
        {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    rep(i, n)
    {
        int num;
        cin >> num;

        rep(i, 3)
        {
            rep(j, 3)
            {
                if (a[i][j] == num)
                {
                    a[i][j] = 0;
                }
            }
        }
    }
    bool pass = false;
    rep(i, 3)
    {
        if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0)
        {
            pass = true;
        }
    }
    rep(i, 3)
    {
        if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0)
        {
            pass = true;
        }
    }
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
        pass = true;
    if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0)
        pass = true;

    if (pass)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    ~A_Pessimist~:)
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int mx=1e5+10;
ll ar[mx],dp[mx],n,k;

ll find_min(int index)
{
    if(index>=n-1) return 0;

    if(~dp[index]) return dp[index];

    ll ans=1e18;

    for(int i=1;i<=k;i++)
    {
        if(index+i>=n) break;

        ans=min(ans, find_min(index+i)+ abs(ar[index+i]-ar[index]));
    }

    return dp[index]=ans;
}

void solve()
{
    cin>>n>>k;;
    memset(dp, -1, sizeof dp);

    for(int i=0;i<n;i++) cin>>ar[i];

    cout<<find_min(0)<<endl;
}

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

    int t=1;
   // cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 11368
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979
 
void mul_mod(ll& a, ll b){
    a *= b;
    a %= MOD;
}
 
void add_mod(ll& a, ll b){
    b += MOD;
    a += b;
    a %= MOD;
}

int h,w,final;
string s[15],t[15];

void copy(int x, int y){
	int i;
	for(i=0; i<h; ++i){
		t[i][y] = s[i][x];
	}
}

bool check(){
	int i,j,k,cnt=0;
	bool done[15],flag;
	fill(done,done+15,false);
	for(i=0; i<h; ++i){
		if(done[i]){
			continue;
		}
		for(j=(i+1); j<h; ++j){
			if(done[j]){
				continue;
			}
			flag = true;
			for(k=0; k<w; ++k){
				if(t[i][k] != t[j][w-k-1]){
					flag = false;
					break;
				}
			}
			if(flag){
				done[i] = true;
				done[j] = true;
				break;
			}
		}
	}
	for(i=0; i<h; ++i){
		if(!done[i]){
			k = i;
			++cnt;
		}
	}
	if(cnt > 1){
		return false;
	}else if(!cnt){
		return true;
	}
	flag = true;
	i = 0; j = (w-1);
	while(i < j){
		if(t[k][i] != t[k][j]){
			flag = false;
			break;
		}else{
			++i; --j;
		}
	}
	return flag;
}

bool solve(int status){
	int i,cnt=0,u,d;
	bool flag=true,ret=false;
	if(status == final){
		return check();
	}else if((!status) && w%2){
		for(i=0; i<w; ++i){
			copy(i,(w/2));
			if(solve((1<<i))){
				ret = true;
				break;
			}
		}
		return ret;
	}
	for(i=0; i<w; ++i){
		if((status&(1<<i))){
			++cnt;
		}
	}
	u = cnt/2;
	d = w-u-1;
	for(i=0; i<w; ++i){
		if(!(status&(1<<i))){
			if(flag){
				status += (1<<i);
				copy(i,u);
				flag = false;
			}else{
				copy(i,d);
				if(solve(status+(1<<i))){
					ret = true;
					break;
				}
			}
		}
	}
	return ret;
}

int main(void){
	int i,j;
	cin >> h >> w;
	final = (1<<w)-1;
	for(i=0; i<h; ++i){
		cin >> s[i];
		t[i] = s[i];
	}
	cout << ((solve(0))?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define len(x) ((int)(x).size())
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> l(N, 0);
  for (size_t i = 0; i < N; i++) {
    cin >> l[i];
  }

  int ans = 0;

  // for (size_t i = 0; i < N; i++) {
  //   for (size_t j = i + 1; j < N; j++) {
  //     for (size_t k = j + 1; k < N; k++) {
  //       int a = l[i], b = l[j], c = l[k];
  //       if(a!=b && b != c && c != a) {
  //         if(abs(a-b) < c && c < a + b) {
  //           ans++;
  //         }
  //       }
  //     }
  //   }
  // }

  for (size_t i = 0; i < N; i++) {
    for (size_t j = i + 1; j < N; j++) {
      for (size_t k = j + 1; k < N; k++) {
        int a = l[i];
        if (a == l[j]) continue;
        int b = l[j];
        if (a == l[k] || b == l[k]) continue;
        int c = l[k];
        if(abs(a-b) < c && c < a + b) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3572
// CODE FESTIVAL 2016 qual B
// 

#include <cstdio>
#include <cstring>
using namespace std;


char buff[256];
char correct[256] = "CODEFESTIVAL2016";
int ans;

int main() {

  scanf("%s", buff);
  ans = 0;
  for (int i = 0; i < (int)strlen(buff); i++) {
    if (buff[i] != correct[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);

  return 0;

}




Measured memory_bytes: 128
def ED(s1,s2):
    m,n = len(s1),len(s2)
    """
    方針：DP
    s1,s2のどちらかが空白文字列ならもう一方の長さ
    s1のi文字目,s2のj文字目まで読み,
    最後が一致していたらその直前までの操作で十分
    一致していなかったら3種の操作のどれかを行う
    """
    dp = [[None for _ in range(n+1)] for _ in range(m+1)]
    for i in range(m+1):
        dp[i][0] = i
    for j in range(n+1):
        dp[0][j] = j

    for i in range(1,m+1):
        for j in range(1,n+1):
            if s1[i-1] == s2[j-1]:
                dp[i][j] = dp[i-1][j-1]
            else:
                dp[i][j] = min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1

    return dp[m][n]

s1 = input()
s2 = input()

ans = ED(s1,s2)
print(ans)



Measured memory_bytes: 42900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    IOS

    int n;
    cin>>n;

    if(n%1000==0)
        cout<<"0";
    else
    {
        int x=1000-n%1000;
        cout<<x;
    }

    return 0;
}


Measured memory_bytes: 3652
N,T = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
ret = T
# for ind in range (1, N):
#     ret += min(T,ts[ind]-ts[ind-1])
for diff in [ts[ind+1]-ts[ind] for ind in range(N-1)]:
    ret += T if T<diff else diff
print(ret)


Measured memory_bytes: 25196
import           Control.Monad
import           Data.Array
import qualified Data.ByteString.Char8         as BS
import           Data.List
import           Data.Maybe
import           Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  (a : b : _) <- readInts
  print $ solve a b

solve :: (Integral a1, Num a2, Ord a2) => a2 -> a1 -> a1
solve a b | 13 <= a   = b
          | 6 <= a    = b `div` 2
          | otherwise = 0


Measured memory_bytes: 380
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
 
#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool field[21][21];
 
int main() {
	int ju_n,order_n;
	int x,y;
	while(cin >> ju_n, ju_n){
		fill_n((bool*)field, 21*21, false);
		REP(i, ju_n){
			cin >> x >> y;
			field[y][x]=true;
		}
		x=10;y=10;
		cin >> order_n;
		REP(i, order_n){
			char order;
			int l;
			cin >> order >> l;
			int dx=0,dy=0;
			switch(order){
				case 'N':
					dy=1;
					break;
				case 'S':
					dy=-1;
					break;
				case 'W':
					dx=-1;
					break;
				case 'E':
					dx=1;
					break;
			}
			REP(i, l){
				x+=dx;y+=dy;
				if(field[y][x]){
					ju_n--;
					field[y][x]=false;
				}
			}
		}
		cout << (ju_n==0?"Yes":"No") << endl;
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long int
using namespace std;
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b,a % b);
}
int combination(int n, int k){
    int spaceOptimize[k+1];
    memset(spaceOptimize, 0, sizeof(spaceOptimize));
    spaceOptimize[0] = 1;
    for(int i=1;i<=n; i++){
        for(int j= min(i,k);j>0;j--){
            spaceOptimize[j] = spaceOptimize[j] + spaceOptimize[j-1];
        }
    }
    return spaceOptimize[k];
}
signed main(){
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r", stdin);
#endif
    fastIO

    int n;
    cin >> n;
    string s;
    cin >> s;
    string abc = "ABC";
    int counter = 0;
    for(int i=0;i<n-2;i++){
        string temp = s.substr(i, 3);
        if(temp == abc){
            counter++;
        }
    }
    cout << counter;


    return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
answer = 0

def is_prime(N):
  prime = []
  prime.append(1)
  prime.append(c)
  for i in range(1,N//2 + 1):
    if N % i == 0:
      prime.append(i)
  return prime

for i in range(a,b+1):
  if i in is_prime(c):
    answer += 1
print(answer)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  
  vector<int>left(N,0);
  vector<int>right(N,0);
  for(int i=1;i<N;i++)left[i]=max(left[i-1],A[i-1]);
  for(int i=N-2;i>=0;i--)right[i]=max(right[i+1],A[i+1]);
  
  for(int i=0;i<N;i++){
    cout<<max(left[i],right[i])<<endl;
  }

}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int a, b;
    cin >> a >> b;

    if (a % b == 0 || b == 1) {
      cout << -1 << endl;
    }
    else {
      cout << a * b - a << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    long long num,x = 0;
    long long h1 = 0,h2 = 0;

    scanf("%llu", &num);

    h1 = num/500;

    num = num - h1*500;

    h2 = num/5;

    long long total = h1*1000 + h2*5;

    printf("%llu\n", total);

    return 0;
}


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

template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}

main(void) {
  int n, K;
  read(n); read(K);
  vector <int> a(n);
  for (int i = 0; i < n; i ++)
    read(a[i]);
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i : a) {
    if ((K -= i) >= 0) ++ ans;
  }
  if (K > 0) -- ans;
  cout << ans << "\n";
}


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

void eratosthenes(int n, vector<int64_t>& f) {
    vector<int> chk(n, 0);
    for (int64_t i = 2; i < n; i++) {
        f[i] = (i - 1) - chk[i];
        for (int64_t j = 2 * i; j < n; j += i) chk[j] += f[i];
        f[i] += f[i - 1];
    }
}

int main(){
    int t; cin >> t;
    vector<int64_t> f(1000001, 0); eratosthenes(1000001, f);

    for (auto i = 0; i < t; i++) {
        int n; cin >> n;
        cout << f[n] + 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 14448
#include <stdio.h>

void trace ( int A[], int N ) {
  for ( int i = 0; i < N; i++ ) {
    printf ( "%d", A[i] );
    if ( i == N - 1 )
      break;
    printf( " " );
  }
  putchar ( '\n' );
}

void insertion ( int A[], int N ) {
  for ( int i = 1; i < N; i++ ) {
    int key = A[i]; int j;
    j = i - 1;
    while ( j >= 0 && A[j] > key ) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    trace ( A, N );
  }
}

int main ( void ) {
  int N, i;
  int A[100];
  scanf ( "%d", &N );
  for ( i = 0; i < N; i++ ) {
    scanf ( "%d", &A[i] );
  }
  trace ( A, N );
  insertion ( A, N );
}



Measured memory_bytes: 2080
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        A_RedOrNot();
    }

    private static void A_RedOrNot() {

        final Scanner sc = new Scanner(System.in);
        final int a = sc.nextInt();
        final String s = sc.next();
        final String output;

        if (a >= 3200) {
            output = s;
        } else {
            output = "red";
        }

        System.out.println(output);
    }
}


Measured memory_bytes: 23124
/*
  A - Remaining Time
  Contest 057
  Rakesh Kumar --> 20/08/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int a = 0, b = 0;
    std::cin >> a >> b;
    std::cout << (a + b) % 24 << std::endl;

    return 0;
}


Measured memory_bytes: 3640
N=int(input())
F=[[0]*10 for j in range(N)]

for i in range(N):
    F[i]=list(map(int,input().split()))

P=[]

for i in range(N):
    P.append(list(map(int,input().split())))

L=[]
l=[0]*10

temp=""
c=0
while c>=0:
    if c==10:
        L.append(temp)
        temp=temp[:-1]
        c -= 1
    if l[c]==0:
        temp+="0"
        l[c]+=1
        c+=1
    elif l[c]==1:
        temp+="1"
        l[c]+=1
        c+=1
    elif l[c]==2:
        temp=temp[:-1]
        l[c]=0
        c-=1

CL=[]
mx=-1000000000000
for d in L[1:]:
    temp=0
    for i in range(N):
        C=[0]*N
        for j in range(10):
            if F[i][j]*int(d[j])==1:
                C[i]+=1
        temp+=P[i][C[i]]
        CL.append(C[i])

    mx=max(mx,temp)
CL=set(CL)
print(mx)

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll a;
  string s;
  cin >> a >>s;
  int n = s.size();
  if(n <= a){
    cout<<s<<"\n";
  }else{
    for(int i=0;i<a;i++){
      cout<<s[i];
    }
    cout<<"...\n";
  }
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool flg = true;
  for(int i =0; i < s.size(); i++){
    // cerr << s[i] << endl;
    if(i == a){
      if(s[i] != '-'){
        flg = false;
        break;
      }
    } else { 
      if( !( s[i] - '0' >= 0 && '9' - s[i] >= 0) ){
        flg = false;
        break;
      }
    }
  }
  
  if(flg && s.size() == a + b + 1){
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
	var str = input;
	str = str.split("\n")[0];
    var x = Number(str%10);
    var y = Number(Math.floor(str/10)%10);
    var z = Number(Math.floor(str/100)%10);
   	if(x===7|| y===7|| z===7){
 		console.log("Yes");
   	}else{
   			console.log("No");
   	}
}
 //*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29500
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;

int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int x;
	cin>>x;
	if(x<=599)cout<<"8";
	else if(x<=799)cout<<"7";
	else if(x<=999)cout<<"6";
	else if(x<=1199)cout<<"5";
	else if(x<=1399)cout<<"4";
	else if(x<=1599)cout<<"3";
	else if(x<=1799)cout<<"2";
	else if(x<=1999)cout<<"1";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
  int main () {
  int a , b;
  
  cin >> a >> b;
    
   if ( (a+b)%2==0 ) {
    cout <<  (a+b)/2  << endl;  
   }
     
   else { 
  cout << (a+b)/2+1 << endl;
   }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,M;
int deg[MAXN];
void Solve() {
    read(N);read(M);
    int a,b;
    for(int i = 1 ; i <= M ; ++i) {
	read(a);read(b);
	++deg[a];++deg[b];
    }
    for(int i = 1 ; i <= N ; ++i) {
	if(deg[i] & 1) {puts("NO");return;}
    }
    puts("YES");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

int n, ans = 0;

int GCD(int a, int b)
{
    return b == 0 ? a : GCD(b, a % b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(a, n)
    {
        for1(b, n)
        {
            for1(c, n)
            {
                ans += GCD(GCD(a, b), c);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3704
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		out.println(x<1200?"ABC":"ARC");
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
ll gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	while (y) {
		ll r = x % y; x = y; y = r;
	}
	return x;
}
ll t[100];
int main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> t[i];
	}
	if (n == 1) {
		cout << t[0] << endl;
	}
	else {
		ll g = gcd(t[0], t[1]);
		ll out = (t[0] / g)*t[1];
		Rep(i, 2, n) {
			g = gcd(out, t[i]);
			out = (out / g)*t[i];
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 256
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = scan!(i64, i64);
    let half = m / 2;
    if m - 2 * n >= 0 {
        println!("{}", (n + (m - 2 * n) / 4))
    } else {
        println!("{}", min(n, half));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int H , W ;
  cin >> H >> W ;
  int h , w ;
  cin >> h >> w ;
  cout << H*W - h*W -w*H +h*w << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
int r;

  scanf("%d",&r);
  
  if(r<1200){
  printf("ABC");
  }
  else if(r>=1200&&r<2800){
  printf("ARC");
  }
  else{
  printf("AGC");
  }
  
return 0;
}

Measured memory_bytes: 128
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

bool a[200005] = {};
bool b[200005] = {};

void solve()
{
    IN(n, k, c);
    string s; cin >> s;
    ll i = 0;
    ll count = 0;
    while (i < n)
    {
        if (i >= n) break;
        if (s[i] == 'x')
        {
            ++i;
            continue;
        }
        a[i] = 1;
        ++count;
        i += c + 1;
    }
    if (count != k)
    {
        return;
    }
    i = n - 1;
    while (i >= 0)
    {
        if (i < 0) break;
        if (s[i] == 'x')
        {
            --i;
            continue;
        }
        b[i] = 1;
        i -= c + 1;
    }
    for(int i = 0; i < n; ++i)
    {
        if (a[i] && b[i]) cout << i+1 << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 2196
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
/*
  void CountingSort(int * ,int *,int);
  int C[VMAX+1];
  int n;
*/
int main()
{
  unsigned short *A, *B;
  int C[VMAX+1];
  int n,i,j,k=0;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++)
    {
      scanf("%hd",&A[i]);
    }

  for(i=1;i<=n;i++)
    {
      if(A[i]>=k)
	{
	  k=A[i];
	}
    }
  // printf("%d\n",k);
  for(j=0;j<=k+1;j++)
    {
      C[j] = 0;
    }
  //C[i] に i の出現数を記録する
  for(i=1;i<=n;i++)
    {
      C[A[i]]++;
    }
  /*
    for(i=0;i<n;i++)
    {
    printf("%d",C[i]);
    }
    printf("\n");
  */
  //C[i] に i 以下の数の出現数を記録する(各要素の出現回数の和を取っていく。累積和)
  for(i=1;i<=k+1;i++)
    {
      C[i]=C[i]+C[i-1];
    }
  // printf("%d\n",C[6]);
  for(j=n;j>=1;j--)
    {
      B[C[A[j]]]=A[j];
      C[A[j]]--;
    }
  for(i=1;i<=n;i++)
    {
      if(i==n)
	{
	  printf("%d",B[i]);
	}
      else
	{
	  printf("%d ",B[i]);
	}
    }
  printf("\n");
  
  return 0;
}

/*
void CountingSort(A, B, k)
{
  int i,j;
  for(i=0;i<=k+1;i++)
    {
      C[i] = 0;
    }
  //C[i] に i の出現数を記録する
  for(j=0;j<n;j++)
    {
      C[A[j]]++;
    }
    for(i=0;i<n;i++)
    {
      printff("%d",C[i]);
    }
  //C[i] に i 以下の数の出現数を記録する(各要素の出現回数の和を取っていく。累積和)
  for (i = 1 to k)
    {
      C[i] = C[i] + C[i-1];
    }
  //
  for (j = n downto 1)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
}
*/



Measured memory_bytes: 9560
N = int(input())
X = list(map(int, input().split()))
X.sort()
maxP = X[-1]
#print(maxP)
total = 1000000000000
for P in range(maxP + 1):
    tmpTotal = 0
    for tmpX in X:
#        print("{} {} {}".format(tmpX, N, (N-int(tmpX))**2))
        tmpTotal = tmpTotal + (P - int(tmpX))** 2
    if tmpTotal < total:
        total = tmpTotal

if total == 1000000000000:
    total = 0
print(total)


Measured memory_bytes: 3060
N,W=map(int,input().split())

dp=[[W+1 for _ in range(10**5+1)] for _ in range(N+1)]
w,v=map(int,input().split())
dp[1][v]=w
dp[1][0]=0
for i in range(1,N):
    w,v=map(int,input().split())
    for j in range(10**5+1):
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])
        if j+v<=10**5:
            dp[i+1][j+v]=min(dp[i][j+v],dp[i][j]+w)
out=0
for i in range(10**5+1):
    if dp[N][i]<=W:
        out=i
print(out)

Measured memory_bytes: 171508
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    
    for i in range(H):
        for j in range(W):
            if i%2==0 and j%2==0 or i%2==1 and j%2==1:
                print("#",end='')
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7008
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = list(range(1,N+1))
AB = np.array((A,B))
ABsort = AB[:,np.argsort(AB[0,:])]

output = ""
for i in range(N-1):
    output += "{} ".format(ABsort[1,i])
output += str(ABsort[1,-1])
print(output)


Measured memory_bytes: 25432
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> east(N + 1, 0), west(N + 1, 0);
    // i-1番目までの人の東西の和
    REP(i, N) {
        if(S[i] == 'E') {
            east[i + 1] = east[i] + 1;
            west[i + 1] = west[i];
        } else {
            west[i + 1] = west[i] + 1;
            east[i + 1] = east[i];
        }
    }
    int ans = 9900000;
    // print(east);
    // print(west);
    for(int i = 0; i + 1 <= N; i++) {
        ans = min(ans, west[i] + east[N] - east[i + 1]);
        // cout << west[i] + (east[N] - east[i + 1]) << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int f(int a, int b, int c, int d) {
    int ab = a * b;
    int cd = c * d;
    if (ab > cd) {
        return ab;
    }
    return cd;
}

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int result = f(a, b, c, d);
    cout << result << endl;

    return 0;
}


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

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define N

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch;
int n,x,mn=INF,sum;

inline void read(int &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}

int main(void)
{
	read(n);
	rep(i,1,n)
	{
		read(x),sum+=x;
		if(x%10>0)mn=min(mn,x);
	}
	if(sum%10>0)printf("%d",sum);
	else if(mn%10>0&&mn!=INF)printf("%d",sum-mn);
	else printf("0");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt(), m = scan.nextInt();

    int[] arr = new int[n];
    for(int i = 0; i < n; i++) arr[i] = 1;
    int nowR = 0;
    boolean[] flag = new boolean[n];
    flag[0] = true;

    for(int loop = 0; loop < m; loop++) {
      int a = scan.nextInt()-1;
      int b = scan.nextInt()-1;

      if(flag[a]) flag[b] = true;

      if(a==nowR) {
        if(arr[a]>1) {
          if(arr[b]>0) {
            flag[b] = true;
          }
        }else {
          flag[a]=false;
        }
      }
      arr[a]--;
      arr[b]++;
      if(arr[a]==0) flag[a] = false;
    }

    int count = 0;
    for(boolean _f : flag) count += (_f)?1:0;
    System.out.println(count);
  }
}


Measured memory_bytes: 23792
#include <stdio.h>
int main(void){
    // Your code here!
    int N,i,j,tmp;
    scanf( "%d" , &N );
    int a[N];
    int cnt = 0;
    
    for( i = 0 ; i < N ; i++ ){
        scanf( "%d" , &a[i] );
    }
    
    for( i = 0 ; i < N ; i++ ){
        for( j = N - 1 ; i < j ; j-- ){
            if( a[j] < a[j-1] ){
                tmp    = a[j];
                a[j]   = a[j-1];
                a[j-1] = tmp;
                cnt++;
            }
        }
    }

    printf( "%d" , a[0] );
    for( i = 1 ; i < N ; i++ ){
            printf( " %d" , a[i] );
    }
    printf( "\n" );
    
    printf( "%d\n" , cnt );
    
}



Measured memory_bytes: 2112
#include<stdio.h>
int main(void){
  int i,n,input;
  int ave=0;
  double average;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&input);
    ave+=input/n;
  }
  printf("%d\n",ave);
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
using namespace std;
int main(){
	char a[100000];
	int n;
	int c=0;

	for (int i = 0; i < 100000; i++){
		a[i] = 0;
	}
		scanf("%s", a);
		n = strlen(a);
	for (int i = 1; i < n; i++){
		if (a[i - 1] != a[i])c++;
	}

	printf("%d", c);

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = []
for _ in range(K):
    l, r = map(int, input().split())
    S.append((l, r))

mod = 998244353
        
table = [0]*N
table[0] = 1
TABLE = [0]*N
TABLE[0] = 1

for i in range(1, N):
    TABLE[i] = TABLE[i-1]
    for L, R in S:
        l = i-L
        r = i-R-1
        if r >= 0:
            table[i] += TABLE[l] - TABLE[r]
            table[i] %= mod
            TABLE[i] += TABLE[l] - TABLE[r]
            TABLE[i] %= mod
        elif l >= 0 and r < 0:
            table[i] += TABLE[l]
            table[i] %= mod
            TABLE[i] += TABLE[l]
            TABLE[i] %= mod
            
print(table[N-1]%mod)

Measured memory_bytes: 71256
N,K=map(int,input().split())
check=[0]*(N+1)
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for j in A:
    check[j]+=1
ans=0
for i in range(1,N+1):
  if check[i]==0:
    ans+=1
print(ans)


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

int solve_testcase() {
    int N; cin >> N;
    if(N == 0) return 1;

    int ans = 0;
    for(int l=0; l<=N; l++) {
        for(int r=l+2; r<=N; r++) {
            int vr = r * (r + 1) / 2;
            int vl = l * (l + 1) / 2;
            if(vr - vl == N) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



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

const int DIM = 1e5 + 5;

string str;
bool ans[DIM];

int main( void ) {
    
    int n;
    cin >> n >> str;
    
    for( char &ch : str )
        ch = ( ch == 'x' );
    
    bool ok = false;
    for( int v0 = 0; v0 <= 1 && ok == false; v0 ++ ) {
    for( int v1 = 0; v1 <= 1 && ok == false; v1 ++ ) {
        ans[0] = v0; ans[1] = v1;
        
        for( int i = 2; i < n; i ++ )
            ans[i] = ( ans[i - 2] ^ ans[i - 1] ^ str[i - 1] );
        
        if( ( ans[n - 2] ^ ans[n - 1] ^ str[n - 1] ) == ans[0] &&
            ( ans[1] ^ ans[0] ^ str[0] ) == ans[n - 1] ) ok = true;
    } }

    if( ok == false )
        cout << -1 << endl;
    else {
        for( int i = 0; i < n; i ++ )
            cout << ( ans[i] == 0 ? 'S' : 'W' );
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
def main():
    a, b, c, d = (int(i) for i in input().split())
    ans = max(a * c, b * d, a * d, b * c)
    if ans < 0 and (a <= 0 <= b or c <= 0 <= d):
        ans = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    if(n % k) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Globalization;
using System.Text;
using System.Threading;

namespace TaskC
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
            var a = ConsoleReader.Read<decimal>();
            var b = ConsoleReader.Read<decimal>();
            Console.WriteLine((ulong)(a * b));
        }
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

Measured memory_bytes: 27628
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define frr(i,s,n) for(int i=s;i<=n;i++)
#define fr(i,s,n) for(int i=s;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

void loop()
{
    int x;
    cin>>x;
    cout<<(x^1);
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //fast;
    int t = 1;
    //cin>>t;
    while(t--)
        loop();
}   

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int now = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'L' && i-1 >= 0 && s[i-1] == 'L') ++now;
        if(s[i] == 'R' && i+1 < n && s[i+1] == 'R') ++now;
    }
    cout << min(n-1, now + k * 2) << "\n";
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in();
	vector<ll>a(n);
	REPC(&i, a)i = in();
	sort(ALL(a), greater<ll>());
	deque<ll>first(a.begin(), a.begin() + n - n / 2), second(a.end() - n / 2, a.end());
	ll ans = 0;
	if (n % 2 == 0) {
		REPC(i, first)ans += i * 2;
		ans -= first.back();
		REPC(i, second)ans -= i * 2;
		ans += second.front();
	} else {
		REPC(i, first)ans += i * 2;
		ans -= *(first.end() - 1);
		ans -= *(first.end() - 2);
		REPC(i, second)ans -= i * 2;
		ll foo = 0;
		second.push_front(first.back());
		first.pop_back();
		REPC(i, first)foo += i * 2;
		REPC(i, second)foo -= i * 2;
		foo += *(second.begin());
		foo += *(second.begin() + 1);
		ans = max(ans, foo);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define DD 10000

long dp[2][2505][DD+5];
long acc[DD+5];

int main(){
  long n,k,x;
  cin>>n>>k>>x;
  vector<long> s(k);
  rep(i,k) cin>>s[i];

  fill(dp[0][0], dp[2][0], 0);

  // dp[same?][left-value][length]

  dp[1][x][1] = 1;

  for(int vl=x-1; vl>=0; vl--){
    for(int bl=0; bl<=1; bl++){
      acc[0] = 0;
      for(int d=0; d<=DD; d++) acc[d+1] = acc[d] + dp[!bl][vl+!bl][d];
      for(int d=1; d<=DD; d++){
        if((d+!bl)/2+vl <= x) dp[bl][vl][d]=1;
        // prev[max(d-2*(x-vl),1) ... d-1]
        dp[bl][vl][d] += acc[d] - acc[max<int>(1, d-2*(x-vl))];
        dp[bl][vl][d] %= MOD;
      }
    }
  }

  long ans = 1;
  rep(i,k-1){
    ans *= dp[0][i][s[i+1]-s[i]];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 391936
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc152/tasks/abc152_d>
 問題文============================================================
 D - Handstand 2
 =================================================================
 解説=============================================================
 1..Nの全ての数字で、先頭と末尾の値のペアの個数を数え上げる。
 その後、先頭と末尾の値を決め打ちする。
 （先頭と末尾の値のペア数）*（末尾と先頭の値のペア数）の総和が答え
 ================================================================
 */

map<pll,ll> mp;
template<class Type>
Type solve(Type res = Type()){
    // test();
    ll N; cin >> N;

    if(N < 10) return N;

    for(ll n = 1; n <= N; n++){
        ll r = n%10;

        ll l = n;
        while(l >= 10) l /= 10;
        
        mp[pll(l,r)]++;
    }
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            res += mp[pll(i,j)]*mp[pll(j,i)];
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let r: i64 = tr.read();
    println!("{}", (r as f64) * 2. * std::f64::consts::PI);
}


Measured memory_bytes: 2176