akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 2005;

int n, m;
char mat[N][N];
int row[N][N];
int col[N][N];

void pre() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      row[i][j] = (mat[i][j] == '.');
      if (j > 0) row[i][j] += row[i][j - 1];
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      col[i][j] = (mat[i][j] == '.');
      if (i > 0) col[i][j] += col[i - 1][j];
    }
  }
}

int colsum(int c, int r1, int r2) {
  return col[r2][c] - (r1 > 0 ? col[r1 - 1][c] : 0);
}

int rowsum(int r, int c1, int c2) {
  return row[r][c2] - (c1 > 0 ? row[r][c1 - 1] : 0);
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> mat[i];
  }
  pre();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '#') continue;
      int up = -1, lef = -1, down = -1, rig = -1;
      int l = 1, r = i;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (colsum(j, i - mid, i - 1) == mid) {
          up = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      l = 1; r = j;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (rowsum(i, j - mid, j - 1) == mid) {
          lef = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      l = 1; r = n - 1 - i;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (colsum(j, i + 1, i + mid) == mid) {
          down = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      l = 1; r = m - 1 - j;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (rowsum(i, j + 1, j + mid) == mid) {
          rig = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      int here = (lef == -1 ? 0 : lef) + (rig == -1 ? 0 : rig) +
                 (down == -1 ? 0 : down) + (up == -1 ? 0 : up) + 1;
      ans = max(ans, here);
      //cout << i << " " << j << " " << up << " " << lef << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
'use strict'
 
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const targets = [];
  const result = [];
  
  for(let i = 0; i<input.length; i++){
    if(i === 0) continue
    const line = input[i].split(" ");
    targets.push({name: line[0], score: parseInt(line[1], 10)});
  }
  
  targets.sort((a, b) => {
      	if (a.name < b.name) return -1;
      	if (a.name > b.name) return 1;
      	if (a.score > b.score) return -1;
      	if (a.score < b.score) return 1;
    	return 0;
	});
      
  for(let j = 0; j < targets.length; j++){
  	for(let k = 0; k < input.length; k++){
	  if(k===0) continue;
      const line = input[k].split(" ");
      if(line[0] === targets[j].name && parseInt(line[1], 10) === targets[j].score){
        result.push(k)
      }
    }
  }
  
  for(let l = 0; l < result.length; l++){
  	console.log(result[l]);
  }
 
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8496
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int main() {
	int W, H;
	cin >> W >> H;
	
	Vec< lint > p(W+1), q(H+1);
	for_(i,0,W) cin >> p[i];
	for_(i,0,H) cin >> q[i];
	
	p[W] = q[H] = (lint)1e9;
	
	sort(allof(p));
	sort(allof(q));
	
	int i = 0, j = 0;
	lint ans = 0;
	while (i < W || j < H) {
		if (p[i] < q[j]) {
			ans += p[i] * (H+1-j);
			++i;
		} else {
			ans += q[j] * (W+1-i);
			++j;
		}
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        List<Integer> list = new ArrayList<>();
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int r = sc.nextInt();
            
            if (n == 0 && r == 0) break;
            list.clear();
            
            for (int i = 0; i < n; i++) {
                list.add(i+1);
            }
            
            for (int i = 0; i < r; i++) {
                int p = sc.nextInt();
                int c = sc.nextInt();
                for (int j = 0; j < c; j++) {
                    list.add(list.remove(n-p-c+1));
                }
            }
            
            System.out.println(list.get(n-1));
        }
    }
}

Measured memory_bytes: 36844
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0]*n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def unit(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    elif self.rank[x]<self.rank[y]:
      self.par[x] = y
    elif self.rank[y]<self.rank[x]:
      self.par[y] = x
    else:
      self.par[y] = x
      self.rank[x] += 1
      
  def same(self, x, y):
    return self.find(x)==self.find(y)

from collections import defaultdict
N,M,*L = map(int, open(0).read().split())
A = L[:N]
U = UnionFind(N)
for x,y in zip(*[iter(L[N:])]*2):
  U.unit(x,y)
ans = 0
rest = []
dic = defaultdict(list)
for i in range(N):
  dic[U.find(i)].append(A[i])
for k in dic.keys():
  dic[k].sort()
  ans += dic[k][0]
  rest.extend(dic[k][1:])
if N-1==M:
  print(0)
  exit()
if N<2*(N-M-1):
  print('Impossible')
  exit()

rest.sort()
remain = 2*(N-M-1)-len(dic.keys())
ans += sum(rest[:remain])
print(ans)


Measured memory_bytes: 37220
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[N];
int pre[N];
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=n;i>=1;i--)
	{
		pre[i]=pre[i+1]+a[i];
	}
	int ans=0;
	for(int i=1;i<=n-1;i++)
	{
		int k=pre[i+1];
		k%=MOD;
		ans+=(k*a[i])%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;


}

Measured memory_bytes: 6736
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

S = list()
zero = 0
one = 0
line = readline()

for i in line:
  if i == '\n':
    break
  n = int(i)
  S.append(n)
  if n == 0:
    zero += 1
  else:
    one += 1

if zero > one:
  print(one * 2)
else:
  print(zero * 2)


Measured memory_bytes: 4248
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int n, m, c;
	cin >> n >> m >> c;
	vector < int > b(m);
	for (auto &el: b) {
		cin >> el;
	}
	int cnt = 0;
	while (n--) {
		int tot = 0;
		for (int i = 0; i < m; ++i) {
			int x;
			cin >> x;
			tot += b[i] * x;
		}
		if (tot + c > 0) {
			++cnt;
		}
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, m);
    Cin(int, d);
    Cout(((d >= m) ? m : m-1));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };


int main() {
	int pred;
	scanf("%d", &pred);

	int up = pred / 100;
	int down = pred % 100;

	if (up >= 1 && up <= 12 && down >= 1 && down <= 12)printf("AMBIGUOUS");
	else if ((up > 12 || up == 0) && (down > 12 || down == 0))printf("NA");
	else if (up > 0 && up <= 12)printf("MMYY");
	else printf("YYMM");



}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;

const int MAX = 1e6 + 5;
int factorial[MAX];
bool ok=false;

void fac(ll k)
{
    if(ok)
    {
        return;
    }
    for(ll i=1; i<=sqrt(k); i++)
    {
        if(k%i==0)
        {
            ll a = k/i;
            ll b = i;

            if(a==b)
            {
                b=1;
            }

            if(a!=1)
            {
                if(factorial[a])
                {
                    ok=true;
                    return;
                }
                factorial[a]++;
            }
            if(b!=1)
            {
                if(factorial[b])
                {
                    ok=true;
                    return;
                }
                factorial[b]++;
            }
        }
    }
}


int main()
{
    SYNC
    //clock_t tStart = clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n; in(n);
    vl v(n);
    l(i,0,n)
    {
        in(v[i]);
    }
    ll check = v[0];
    l(i,1,n)
    {
        fac(v[i]);
        check = __gcd(check,v[i]);
    }
    if(!ok)
    {
        o("pairwise coprime");
    }
    else if(check==1)
        o("setwise coprime");
    else
        o("not coprime");








    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);   
}


Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<int> A(N+1),B(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        B.at(i) = 0;
    }
    A.at(N) = 0;
    for(int i=0;i<N;){
        B.at(0) +=A.at(i);
        i++;
        B.at(0) -= A.at(i);
        i++;
    }
    //　これでベースのB.at(0)は完成
    for(int i=1;i<N;i++){
        B.at(i) = B.at(i-1)*(-1) + A.at(i-1)*2;
    }
    for(int i=0;i<N;i++){
        cout << B.at(i) <<endl;
    }
}


Measured memory_bytes: 2048
N,K = map(int,input().split())
P = list(map(int,input().split()))
for i in range(N):
  P[i] = (P[i]+1)/2
now = sum(P[:K])
ans = now
for j in range(N-K):
  now = now - P[j] + P[j+K]
  ans = max(ans,now)
print(ans)


Measured memory_bytes: 24812
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }



void solve() {
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) cnt += (s[i] != t[i]);
    cout << cnt << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 
int main() 
{ 

 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,k;
    cin>>n>>k;
    if(k==1){cout<<0;return 0;}
    cout<<n-k;







	return 0; 
} 

// This code is contributed by rathbhupendra 


Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int,input().split()))

minus = 0

minim = 100000000

for i,v in enumerate(A):
    if v < 0 :
        minus += 1
        A[i] = -v
    minim = min(minim,A[i])

if minus % 2 == 0:
    print(sum(A))
else:
    print(sum(A) - 2 * minim)

Measured memory_bytes: 23268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, n) for(ll i=0;i<n;i++)
#define r(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
int main()
{

    string s;
    cin>>s;
    int j=s.length()-1;
    ll ans=0;
    for(int i=0;i<j;i++,j--){
        if(s[i]!=s[j])
        ans++;

    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define f first
#define s second

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<int> ar(n);
	for(auto &it : ar){
		cin >> it;
	}
	ll sum = 0;
	for(int i=1;i<n;i++){
		if(ar[i-1] > ar[i]){
			sum += ar[i-1]-ar[i];
			ar[i] = ar[i-1];
		}
	}
	cout << sum << '\n';
	
	return 0;
}

Measured memory_bytes: 3988
//https://atcoder.jp/contests/dp/tasks/dp_b
//29-02-2020
#include <bits/stdc++.h>
using namespace std;

const int INF = 1000000010;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // #ifndef ONLINE_JUDGE
  // freopen ("input.txt", "r", stdin);
  // freopen ("output.txt", "w", stdout);
  // #endif 
  int n, k;
  cin >> n >> k;
  vector <int> h (n), dp (n, INF);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= k && i + j < n; ++j) {
      dp[i + j] = min (dp[i] + abs (h[i + j] - h[i]), dp[i + j]);
    }
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using static System.Console;

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   public static void Main(string[] args) {
      var a = ReadLine().ToInt(); // 500yen
      var b = ReadLine().ToInt(); // 100yen
      var c = ReadLine().ToInt(); //  50yen
      var total = ReadLine().ToInt();

      int ctr = 0;
      for (int i = 0; i <= a; i++) {
         for (int j = 0; j <= b; j++) {
            for(int k = 0; k <= c; k++) {
               if (i*500 + j*100 + k*50 == total) ctr++;
               else if (i*500 + j*100 + k*50 > total) break;
            }
         }
      }

      WriteLine(ctr);
   }
}


Measured memory_bytes: 13140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;

    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
        S = new string[0];
    }

    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}

public class Magatro
{
    private Scanner Sc = new Scanner();
    public void Scan()
    {

    }

    public void Solve()
    {
        while (true)
        {
            int N = Sc.NextInt();
            if (N == 0) return;
            int ascore=0,bscore=0;
            for(int i = 0; i < N; i++)
            {
                int a = Sc.NextInt();
                int b = Sc.NextInt();
                if (a > b)
                {
                    ascore += a + b;
                }
                else if (a < b)
                {
                    bscore += a + b;
                }
                else
                {
                    ascore += a;
                    bscore += b;
                }
            }
            Console.WriteLine("{0} {1}", ascore, bscore);
        }
    }

}

Measured memory_bytes: 9108
#include <iostream>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
	int w,d;
	int sum;

	while(1){
		cin>>w>>d;
		if(w+d==0) break;

		sum=0;
		map<int,int> mw;
		map<int,int> md;
		int temp;
		for(int i1=0;i1<w;i1++){
			cin>>temp;
			mw[temp]++;
			sum+=temp;
		}

		for(int i1=0;i1<d;i1++){
			cin>>temp;
			md[temp]++;
			sum+=temp;
		}

		map<int,int>::iterator itw=mw.begin();
		map<int,int>::iterator itd=md.begin();
		while(itw!=mw.end() && itd!=md.end()){
			if((*itw).first==(*itd).first){
				sum-=((*itw).first*min((*itw).second,(*itd).second));
				itw++;
				itd++;
			}
			else if((*itw).first>(*itd).first) itd++;
			else itw++;
		}

		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int x;
  cin >> x;
  int p;
  int max_p = 0;
  int ans = 0;
  REP(i,x){
    cin >> p;
    ans += p;
    max_p = max(max_p, p);
  }
  cout << ans-max_p/2 << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
int a[101010];
vector<int> G[101010];
int ans = 0;

int dfs(int v, int p) {
	int ret = 0;
	REP(i, G[v].size()) {
		ret = max(ret, dfs(G[v][i], v));
	}
	if (ret + 1 == k) {
		if (p != 1)ans++;
		return 0;
	}
	return ret + 1;

}


int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i == 1) {
			if (a[i] != 1)ans++;
		}
		else {
			G[a[i]].emplace_back(i);
		}
	}
	dfs(1, 1);
	cout << ans << endl;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define id(i,j) ((i) * 3000 + (j))
using namespace std;
typedef long long LL;
typedef pair<LL, int> PLI;
const int INF = 0x3f3f3f3f;
const LL LINF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 2e5 + 10;
int N, M, S;
struct edge
{
    int v, c;
};
vector<edge> g[maxn];
bool vis[maxn];
LL dist[maxn];
void Dijkstra(int s)
{
    memset(dist, 0x3f, sizeof(dist));
    priority_queue<PLI, vector<PLI>, greater<PLI> > q;
    dist[s] = 0;
    q.push(make_pair(dist[s], s));
    while(!q.empty())
    {
        int u = q.top().second;
        q.pop();
        if(vis[u])
            continue;
        else
            vis[u] = true;
        for(auto e : g[u])
        {
            int v = e.v, c = e.c;
            if(!vis[v] && dist[u] + c < dist[v])
            {
                dist[v] = dist[u] + c;
                q.push(make_pair(dist[v], v));
            }
        }
    }
}
int main()
{
    scanf("%d %d %d", &N, &M, &S);
    for(int i = 1; i <= M; i++)
    {
        int A, B, U, V;
        scanf("%d %d %d %d", &U, &V, &A, &B);
        for(int j = A; j <= 2500; j++)
        {
            g[id(U, j)].push_back(edge{id(V, j - A), B});
            g[id(V, j)].push_back(edge{id(U, j - A), B});
        }
    }
    for(int i = 1; i <= N; i++)
    {
        int C, D;
        scanf("%d %d", &C, &D);
        for(int j = 0; j < C; j++)
            for(int k = j + C; k <= 2500; k += C)
                g[id(i, k - C)].push_back(edge{id(i, k), D});
    }
    Dijkstra(id(1, min(S, 2500)));
    for(int i = 2; i <= N; i++)
    {
        LL ans = LINF;
        for(int j = 0; j <= 2500; j++)
            ans = min(ans, dist[id(i, j)]);
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 19960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll a[n];
    rep(0,i,n)cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0];
    
}


Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
        cout<<"hon"<<endl;
    }
    if(n%10==0||n%10==1||n%10==6||n%10==8){
        cout<<"pon"<<endl;
    }
    if(n%10==3){
        cout<<"bon"<<endl;
    }
    
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int N; cin >> N;
    int a[N+10];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a,a+N);
    cout << a[N-1]-a[0] << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int mx = 100005;
int n, m, a[mx];
bool ans = true, t = true;
int main(){
	scanf("%d", &n);
	if(n%3) ans = false;
	rep(i,n){
		scanf("%d", a+i);
		if(a[i]) t = false;
	}
	sort(a,a+n);
	rep(i,n-1) if(i != n/3-1 && i != n/3*2-1 && a[i] != a[i+1]) ans = false;
	if((a[0] ^ a[n/3]) != a[n/3*2]) ans = false;
	if(t) ans = true;
	puts(ans ? "Yes" : "No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

const int MAX_N = 3*1e3 + 100;
const i64 NaN = 1e16;
//(l,r)=> 前からl個, 後ろからr個が無い時の最適X-Y
i64 dp[MAX_N][MAX_N];
int N;
vector<i64> a;
i64 recursive(int l, int r) {
    if(dp[l][r] != NaN) return dp[l][r];
    if(l + r >= N) return 0;
    i64 L = recursive(l + 1, r), R = recursive(l, r + 1);
    if( (l + r) % 2 == 0 ) { // 太郎
        dp[l][r] = max(L + a[l], R + a[N - 1 - r]);
    } else { // 次郎
        dp[l][r] = min(L - a[l], R - a[N - 1 - r]);
    }
    return dp[l][r];
}
int main() {
    cin >> N;
    a = vector<i64>(N);
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            dp[i][j] = NaN;
        }
    }
    for(auto &x : a) cin >> x;
    cout << recursive(0, 0) << endl;
    return 0;
}

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

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] s = stdR.readLine().split(" ");
        int N = Integer.parseInt(s[0]);
        int X = Integer.parseInt(s[1]);
        int sum = 0;
        int count = 1;
        s = stdR.readLine().split(" ");
        for(int i = 0 ; i < N ; i++) {
            sum += Integer.parseInt(s[i]);
            if(sum <= X) {
                count++;
            }else {
                break;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21332
#include <stdio.h>
const int N=100050;
int a[N];
int main()
{
	int n,k,i;
	scanf("%i %i",&n,&k);
	for(i=1;i<=n;i++) scanf("%i",&a[i]);
	int sol=1;
	for(i=k;i<n;i+=k-1)
	{
		sol++;
	}
	printf("%i\n",sol);
	return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		ArrayList<Integer>difficulty=new ArrayList<>();
		
		//問題数
		int N=sc.nextInt();
		
		int halfLine;
		
		//問題の難易度
		for(int i=0;i<N;i++) {
			difficulty.add(sc.nextInt());
		}
		
		Collections.sort(difficulty);	
		halfLine=difficulty.size()/2;
	
		int result=
				difficulty.get(halfLine)-difficulty.get(halfLine-1);
		
		
		System.out.println(result);
	}
 
}

Measured memory_bytes: 64552
#include<stdio.h>

#define MAX 50 //最大桁数

void func_init(int array[]); //初期化関数
void func_cal_fact(int array[], int n); //階乗を計算する関数
void func_output(int array[]); //出力を行う関数

main()
{
	int array[MAX]; //50桁まで表示可能
	int n = 0; //コマンドラインからの入力
	
	scanf("%d", &n); //入力の取得
	
	func_init(array); //初期値を1にするために初期化
	func_cal_fact(array, n); //階乗の計算
	func_output(array);
	
	return 0;
}
void func_init(int array[]) //初期化関数
{
	int i = 0; //ループ制御変数
	for(i = 0; i < MAX; i++)
	{
		if(i == 0) //最初の要素には0を代入
		{
			array[i] = 1;
		}
		else //それ以外の要素には1を代入
		{
			array[i] = 0;
		}
	}
}
void func_cal_fact(int array[], int n)
{
	int i = 1, j = 0; //ループ制御
	int up = 0; //繰上げ桁変数
	for(i = 1; i <= n; i++) //乗算する数を制御する
	{
		up = 0; //桁数は乗算する数が変化するごとにリセットする
		for(j = 0; j < MAX; j++) //配列の要素番号を制御
		{
			array[j] = (array[j] * i) + up; //array[j]の要素を桁上げ等を無視してとりあえず代入
			up = array[j] / 10; //繰上げする桁を変数upに代入
			array[j] = array[j] % 10; //実際に代入されるべき値は1桁なので10で除算した余りを代入
		}
	}
}
void func_output(int array[]) //出力を行う関数
{
	int i = MAX - 1;
	while(array[i] == 0) //0以外の要素が出るまでデクリメント
	{
		i--;
	}
	for(i; i >= 0; i--) //このループで表示
	{
		if(i == 0) //要素番号0は最後の要素なので改行
		{
			printf("%d\n", array[i]);
		}
		else //それ以外はそのまま出力
		{
			printf("%d", array[i]);
		}
	}
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,l[N*2],r[N*2];
long long ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		l[N+y]++; r[N+x]++;
	}
	l[N]++; r[N]++;
	for (int i=1;i<2*N;i++)
		l[i]+=l[i-1];
	for (int i=2*N-2;i>=0;i--) 
		r[i]+=r[i+1];
	for (int i=0;i+1<2*N;i++)
		ans+=min(l[i],r[i+1])*2;
	printf("%lld\n",ans); 
}

Measured memory_bytes: 1920
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = list(map(int, input().split()))
    X.append(x)
    Y.append(y)
    
points = []
for x, y in zip(X, Y):
    points.append((
        x + y,
        x - y
    ))
print(max(max(dim) - min(dim) for dim in zip(*points)))

Measured memory_bytes: 66144
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  string s;
  cin >> s ;
  for(int i=0;i< s.size();i +=2)
    cout << s[i] ;
  cout << endl;
}

Measured memory_bytes: 512
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int N;
    cin>>N;
    vector<vector<ll>> d(N,vector<ll>(N,INF));
    REP(i,N){
        string S;
        cin>>S;
        REP(j,S.size()){
            if(S[j]=='1') d[i][j]=1;
        }
    }

    REP(i,N) d[i][i]=0;
    REP(i,N){
        REP(j,N){
            REP(k,N){
                d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }

    ll ans=0;
    REP(i,N){
        REP2(j,i+1,N){
            if(d[i][j]==INF) continue;
            ans=max(ans,d[i][j]);
        }
    }

    bool ng=false;
    REP(i,N){
        REP(j,N){
            REP(k,N){
                if(d[j][k]==INF||d[j][i]==INF||d[i][k]==INF) continue;
                if(j==k||j==i||i==k) continue;
                if(((d[j][i]+d[i][k])-d[j][k])%2==1) ng=true;
            }
        }
    }
    if(ng){
        cout<<-1<<endl;
    }else{
        cout<<ans+1<<endl;
    }
    
    

    

}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll res = 0;
    res += min(k, a);
    k -= a;
    k -= b;
    if (k > 0) res -= min(k, c);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3648
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n:u32 = read();
    let mut v:Vec<i32> = Vec::new();
    for i in 0..n {
        v.push(read::<i32>())
    }
    v.sort();
    v.dedup();
    let ans = v.len();
    println!("{}",ans);
}


Measured memory_bytes: 4352
N,M = map(int,input().split())

p_list = [0]*N
cor_list = [0]*N 

cor_ans = 0
pen_ans = 0

for i in range(M):
    p,s = input().split()
    p = int(p)
    if (s == "AC") and (cor_list[p-1]) == 0:
        cor_ans += 1
        pen_ans = pen_ans + p_list[p-1]
        cor_list[p-1]  = 1
    elif s == "WA":
        p_list[p-1] += 1


print(cor_ans,pen_ans)

Measured memory_bytes: 4596
h,w = map(int,input().split())
resp = h*w//2
if h == 1 or w == 1:
    print(1)
else:
    if (h * w) % 2 != 0:
        resp += 1
        print(resp)

    elif (h*w) % 2 == 0:
        print(resp)


Measured memory_bytes: 2940
#include <iostream>

int main(){
    using namespace std;
    int H, W ;
    cin >> H >> W ;
    while( !(H==0) | !(W==0) ){
        for(int i{0}; i<H; i++){
            for(int j{0}; j<W; j++){
                if( ((i%2==0)&&(j%2==0)) || (i%2==1)&&(j%2==1) ){cout << "#";}
                else {cout << ".";}
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
}


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

int n,t,ans;

int main() {
	cin>>n;
	for (int i=0;i<n;i++) {
		if (!i) cin>>ans;
		else cin>>t;
		if (i) ans=ans/__gcd(ans,t)*t;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstring>
using namespace std;
int n;
struct data
{
	char c;
	int x;
}data1[40],data2[40],temp;

void print(const data data[])
{
	cout << data[1].c << data[1].x;
	for(int i = 2; i <= n; ++i)
		cout << ' ' << data[i].c << data[i].x;
	cout << endl;
	return ;
}

bool operator==(data x1,data x2)
{
	return (x1.c == x2.c) && (x1.x == x2.x);
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		cin >> data1[i].c >> data1[i].x;
		data2[i].c = data1[i].c;
		data2[i].x = data1[i].x;
	}
	for(int i = 1; i <= n; ++i)
	{
		int minj = i;
		for(int j = i; j <= n; ++j)
		{
			if(data1[minj].x > data1[j].x)
				minj = j;
		}
		temp = data1[i];
		data1[i] = data1[minj];
		data1[minj] = temp;
	}
	bool flag = true;
	while(flag)
	{
		flag = false;
		for(int i = n; i >= 2; --i)
		{
			if(data2[i].x < data2[i-1].x) 
			{
				temp = data2[i];
				data2[i] = data2[i-1];
				data2[i-1] = temp;
				flag = true;
			}
		}
	}
	flag = true;
	for(int i = 1; i <= n; ++i)
	{
		if(!(data1[i] == data2[i]))
			flag = false;
	}
	print(data2);
	cout << "Stable" << endl;
	print(data1);
	cout << (flag ? "Stable" : "Not stable") << endl;
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#define lli long long int
#define pb pushback
#define vec vector

using namespace std;

void dfs(vector <vector <int> >& adjList, vector <bool>& explored, int src);
void bfs(vector <vector <int> >& adjList, vector <bool>& explored, int src);

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

    string s;
    cin >> s;
    int len = s.size();
    int sum = 0;
    for (int i = 0; i < len; i++)
    {
        sum += int(s[i]) - 48;
    }
    if (sum % 9 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

void dfs(vector <vector <int> >& adjList, vector <bool>& explored, int src)
{
    explored.at(src - 1) = true;
    for (int i = 0, j = adjList.at(src - 1).size(); i < j; i++)
    {
        if (!explored.at(adjList.at(src - 1).at(i) - 1))
        {
            dfs(adjList, explored, adjList.at(src - 1).at(i));
        }
    }
    return;
}

void bfs(vector <vector <int> >& adjList, vector <bool>& explored, int src)
{
    explored.at(src - 1) = true;
    queue <int> q;
    q.push(src);
    while (!q.empty())
    {
        int temp = q.front();
        q.pop();
        for (int i = 0, j = adjList.at(temp - 1).size(); i < j; i++)
        {
            if (!explored.at(adjList.at(temp - 1).at(i) - 1))
            {
                explored.at(adjList.at(temp - 1).at(i) - 1) = true;
                q.push(adjList.at(temp - 1).at(i));
            }
        }
    }
}


Measured memory_bytes: 3720
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
        ll n,k;
	
		cin>>n>>k;
		ll dp[n+5]={0};
		for(int tt=1;tt<=k;tt++)
		{
			ll d;
			cin>>d;
			ll a[d];
			for(int i=0;i<d;i++)
			{
				cin>>a[d];
				dp[a[d]]++;
			}
			
		}
		ll count=0;
			for(int i=1;i<=n;i++)
			{
				if(dp[i]==0)
				count++;
			}
			cout<<count<<endl;
		
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int ans;
  int real;
  
  cin>>n;
  for (int i=0;i<n;i++){
    int q;
    cin>>q;
    ans=0;
    while (q%2==0){
      ans+=1;
      q/=2;
    }
   
    if (i==0)
      real=ans;
    else
      real=min(real,ans);
  }
  cout<<real<<endl;
}
    


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
mod = int(1E9+7)

B = Counter(A)
c = (N+1)%2
#print(B, c)
ans = 1
for k, v in B.items():
    if k%2 != c or (k!=0 and v != 2):
        ans = 0
        break
    ans = ans * v % mod

print(ans)

Measured memory_bytes: 56108
S=input()
s=list(S)
if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
	print("Yes")
elif s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]:
	print("Yes")
elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	char s[100010];
	cin >> s;
	int ans = 0;
	rep(i, strlen(s)) {
		if (i != 0) {
			if (s[i - 1] != s[i]) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#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 DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  }
  else {
    cout << "red" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b, x;
  std::cin >> a >> b >> x;

  int nokori = x - a;

  if(b >= nokori && nokori >= 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }


    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

fn main() {
    let (_n, m): (usize, usize) = util::get2();
    let a: Vec<usize> = util::gets::<usize>().into_iter().map(|x| x - 1).collect();

    let mut to: Vec<Vec<usize>> = vec![Vec::new(); m];
    for v in a.windows(2) {
        to[v[1]].push(v[0]);
    }

    let mut imos = vec![0i64; m];
    for v in a.windows(2) {
        if v[0] < v[1] {
            imos[v[0] + 1] += 1;
            imos[v[1]] -= 1;
        } else {
            if v[0] + 1 != m {
                imos[v[0] + 1] += 1;
            }
            imos[0] += 1;
            imos[v[1]] -= 1;
        }
    }
    for i in 1..imos.len() {
        imos[i] += imos[i - 1];
    }

    let zero = a.windows(2)
        .map(|v| min((v[1] + m - v[0]) % m, 1 + (v[1] + m - 0) % m))
        .sum::<usize>();

    let mut sum = zero as i64;
    let mut v = vec![zero as i64];

    for i in 1..m {
        let inc = to[i - 1]
            .iter()
            .map(|&from| (i - 1 + m - from) % m - 1)
            .sum::<usize>();
        let dec = imos[i - 1];
        sum = sum + inc as i64 - dec;
        v.push(sum);
    }

    println!("{}", v.iter().min().unwrap());
}


Measured memory_bytes: 14588