akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int M, K; cin >> M >> K;

    if(M <= 1){
        if(K > 0){
            cout << -1 << endl;
        }
        else {
            rep(i, M+1){
                cout << (i ? " ":"") << i << " " << i;
            }
            cout << endl;
        }
    }
    else {
        if(K < 0 or bit(M) <= K){
            cout << -1 << endl;
        }
        else {
            vi tbl;
            rep(i, bit(M)){
                if(i != K){
                    tbl.emplace_back(i);
                }
            }
            tbl.emplace_back(K);
            rrep(i, bit(M)){
                if(i != K){
                    tbl.emplace_back(i);
                }
            }
            tbl.emplace_back(K);

            rep(i, tbl.size()){
                cout << (i ? " ":"") << tbl[i];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2932
using System;
using System.Linq;
using System.Collections.Generic;
 
class P{
    static void Main(){
        int N=int.Parse(Console.ReadLine());
        long[] a=new long[N];
        for(int i=0;i<N;i++){
            a[i]=long.Parse(Console.ReadLine());
        }
      Console.WriteLine(a.All(x=>x%2==0)?"second":"first");
    }
}


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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            Console.WriteLine((double)(N - N / 2) / N);

        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

vector<int> getpath(int s, int t, vector<vector<int> > v)
{
	vector<int> prev(v.size(), -1);
	prev[s] = s;
	queue<int> qu;
	qu.push(s);
	while(!qu.empty()){
		int now = qu.front();
		qu.pop();
		for(int i = 0; i < v[now].size(); i++){
			if(prev[v[now][i]] != -1) continue;
			qu.push(v[now][i]);
			prev[v[now][i]] = now;
		}
	}
	vector<int> result;
	result.push_back(t);
	int now = t;
	while(now != s){
		result.push_back(prev[now]);
		now = prev[now];
	}
	reverse(result.begin(), result.end());
	return result;
}

int main()
{
	int n;
	cin >> n;
	vector<vector<int> > v(n);
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> path = getpath(0, n - 1, v);
	vector<bool> ischecked(n, false);
	ischecked[0] = ischecked[n - 1] = true;
	vector<bool> isinpath(n, false);
	for(int i = 0; i < path.size(); i++){
		isinpath[path[i]] = true;
	}
	queue<int> fq, sq;
	for(int i = 0; i < v[0].size(); i++){
		if(!isinpath[v[0][i]]) fq.push(v[0][i]);
	}
	for(int i = 0; i < v[n - 1].size(); i++){
		if(!isinpath[v[n - 1][i]]) sq.push(v[n - 1][i]);
	}
	int f = 0, s = path.size() - 1;
	for(int i = 0; i < n; i++){
		if(i % 2 == 0){
			// fennec turn
			if(!ischecked[path[f + 1]]){
				f++;
				int tmp = path[f];
				ischecked[tmp] = true;
				for(int j = 0; j < v[tmp].size(); j++){
					if(!isinpath[v[tmp][j]] && !ischecked[v[tmp][j]]) fq.push(v[tmp][j]);
				}
			} else if(!fq.empty()){
				int tmp = fq.front();
				ischecked[tmp] = true;
				for(int j = 0; j < v[tmp].size(); j++){
					if(!isinpath[v[tmp][j]] && !ischecked[v[tmp][j]]) fq.push(v[tmp][j]);
				}
				fq.pop();
			} else {
				cout << "Snuke" << endl;
				break;
			}
		} else {
			// snuke turn
			if(!ischecked[path[s - 1]]){
				s--;
				ischecked[path[s]] = true;
				for(int j = 0; j < v[path[s]].size(); j++){
					if(!isinpath[v[path[s]][j]] && !ischecked[v[path[s]][j]]) sq.push(v[path[s]][j]);
				}
			} else if(!sq.empty()){
				int tmp = sq.front();
				ischecked[tmp] = true;
				for(int j = 0; j < v[tmp].size(); j++){
					if(!isinpath[v[tmp][j]] && !ischecked[v[tmp][j]]) sq.push(v[tmp][j]);
				}
				sq.pop();
			} else {
				cout << "Fennec" << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 12160
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <utility>
using namespace std;

using ll = long long int;
using P = pair<string, int>;
char st_name[10][51], ar_name[10][51];
int st_time[10], ar_time[10];
int main() {
	int N, T;
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int h1, m1, h2, m2;
		scanf("%d:%d %s %d:%d %s", &h1, &m1, st_name[i], &h2, &m2, ar_name[i]);
		st_time[i] = h1 * 60 + m1;
		ar_time[i] = h2 * 60 + m2;
	}
	vector<P> ans;
	for (int i = 1; i < N; i++) {
		if (st_time[i] - ar_time[i - 1] >= T) {
			ans.emplace_back(st_name[i], st_time[i] - ar_time[i - 1]);
		}
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  else if (A + B <= C + D){
    cout << "Right" << endl;
  }
  else if (A + B >= C + D){
    cout << "Left" << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int N; cin >> N;
  string S; cin >> S;

  for (int i = 0; i < S.length(); ++i){
    if (S[i] + N <= 'Z') S[i] += N;
    else S[i] = 'A' + (N - ('Z' - S[i]) - 1);
  }
  cout << S << endl;
}


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

int n,h;
vector<string> s;
vector<int> t;

char toup(char c){
  if(c >= 'A' && c <= 'Z') return c + 'a' - 'A';
  return c;
}

int main(){
  cin >> n >> h;
  for(int i=0;i<n;i++){
    string str;
    int tt;
    cin >> str >> tt;
    s.push_back(str);
    t.push_back(tt);
  }
  cout << "? " << s[0] << endl;


  int pos = 0;
  int nows = 0;
  int suc = 0, sum = 0, fail=0;
  char ch;
  while(cin >> ch){
    if(toup(s[nows][pos]) == toup(ch)){
      s[nows][pos] = '_';
      suc++;
      sum++;
      pos++;
      if(pos == s[nows].size()){
        pos = 0;
        nows++;
        fail = 0;      
        if(nows == n){
            double ans = (double)suc/(double)sum * 100.0;
            ans *= 10;
            int ians = ans;
            ans = (double)ians / 10.0;
          printf("! Game Clear %.1lf", ans);
          break;
        }
      }
      cout << "? " << s[nows] << endl;
      
    } else {
      sum++;
      fail++;
      if(fail > t[nows]){
        h--;
        if(h == 0) {
          cout << "! Game Over" << endl;
          break;
        } else {
          pos = 0;
          fail = 0;
          nows++;
          if(nows == n){
            double ans = (double)suc/(double)sum * 100.0;
            ans *= 10;
            int ians = ans;
            ans = (double)ians / 10.0;
            printf("! Game Clear %.1lf", ans);
            fflush(stdout);
            break;
          }
        }
      }
      cout << "? " << s[nows] << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

void solve() {
  char c; cin >> c;
  if(c >= 'a') cout << 'a' << '\n';
  else cout << 'A' << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  while(t--) solve();
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

char win_janken( char x ){
    char ans;
    if( x=='r' ) ans = 'p';
    if( x=='s' ) ans = 'r';
    if( x=='p' ) ans = 's';
    return ans;
}

int score( char x, int R, int S, int P ){
    int s = 0;
    if( x=='r' ) s = R;
    if( x=='s' ) s = S;
    if( x=='p' ) s = P;
    return s;
}

int main(){
    // input
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    // calc
    lint ans = 0;
    vector<char> Takahashi(T.length());
    for (int i=0; i<N; i++){
        char i_th_t = win_janken( T[i] );
        if( i < K ){
            // i < K -> win-hand
            ans += score( i_th_t, R, S, P );
        }else{
            // if Takahashi can use win-hand
            if( i_th_t != Takahashi[i-K] ){
                // win
                ans += score( i_th_t, R, S, P );
            }else{
                // if not, Takahashi use s-hand of the next K
                i_th_t = T[i+K];
            }
        }
        Takahashi[i] = i_th_t;
    }
    
    // out
    cout << ans << endl;;
} 

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
  int n;
  std::cin >> n;
  vector<ll> a(n);
  ll all = 0;
  for(int i=0; i<n; i++){
    std::cin >> a[i];
    all += a[i];
  }

  ll min = LLONG_MAX;
  ll sum = 0;
  for(int i=0; i<n; i++){
    sum += a[i];
    if( min > abs(all - 2*sum) ){
      min = abs(all - 2*sum);
    }
  }
  std::cout << min << '\n';
  return 0;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const int INF = 1001001001;
const ll mod = 998244353;
const ll INFL = 1001001001001001000;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int) -1;
}

int v;

bool f(int x) {
    return x < v;
}


int main() {
    int n, q; cin >> n >> q;
    segtree<int, op, e> seg(n+1);
    for (int i = 1; i <= n; i++) {
        int a; cin >> a;
        seg.set(i, a);
    }
    rep(qq, q) {
        int t; cin >> t;
        if (t == 1) {
            int x, v; cin >> x >> v;
            seg.set(x, v);
        } else if (t == 2) {
            int l, r; cin >> l >> r;
            cout << seg.prod(l, r+1) << endl;
        } else {
            int x; cin >> x >> v;
            cout << seg.max_right<f>(x) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i!=n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      System.out.println( shellSort(seq, n) );

      StringBuilder str = new StringBuilder(n*4);
      for (int i : seq)
        str.append(i).append("\n");

      str.setLength(str.length()-1);
      System.out.println(str);
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int[] aG = new int[100];
    for (int g=1,max=n+1; g < max; g=(g*3+1)) {
      aG[m++] = g;
    }
    StringBuilder str = new StringBuilder(m*5);
    str.append(m).append("\n");

    for(int i=(m-1); i!=-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], final int max, final int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j-=g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


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

using namespace std;

int main(void) {
  int N, W; cin >> N >> W;
  long long dpa[W+1], dpb[W+1];
  memset(dpa, 0, sizeof(dpa));

  for (int i = 0; i < N; i++) {
    memcpy(dpb, dpa, sizeof(dpb));
    int w, v; cin >> w >> v;
    for (int j = w; j <= W; j++) {
      dpa[j] = max(dpb[j-w] + v, dpb[j]);
    }
  }

  cout << dpa[W] << endl;

  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();
    sc.close();
    System.out.println((n + x - 1) / x * t);
  }
}

Measured memory_bytes: 35636
def isPrime(x):
    if(x % 2 == 0):
        return False
    for i in range(3, min(x,236), 2): #root55555=235.8...
        if(x % i == 0):
            return False
    return True

n, a, p = int(input()), [], 11
while(n):
    if(isPrime(p)):
        a.append(str(p))
        n -= 1
    p += 10
print(" ".join(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()0
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!


void solve(){
    ll k,n;
    cin>>k>>n;
    
    vll arr(n);
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    if(n==0){
        cout<<"0"<<endl;
        return ;
    }
    
    ll sum=k-arr[n-1]+arr[0];
    ll maxm=sum;
    for(ll i=1;i<n;i++){
        sum+=arr[i]-arr[i-1];
        maxm=max(maxm,arr[i]-arr[i-1]);
    }
    cout<<sum-maxm<<endl;
}

 
int main() {
    faster;
    int t=1;
    // cin>>t;
    
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 4764
#include <iostream>

using namespace std;

int main()
{
    char s[100001] = {};
    cin >> s;

    bool alp[26] = {};
    for (int i = 0; i < 26; ++i) {
        alp[i] = false;
    }

    for (int i = 0; s[i] != '\0'; ++i) {
        alp[s[i] - 'a'] = true;
    }
    for (int i = 0; i < 26; ++i) {
        if (!alp[i]) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 384
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

//foreach ($data as &$line) {
//    $line = array_map(function($val) { return (int)$val; }, $line);
//}

$S = $data[0][0];
$T = $data[1][0];

$pattern = '/^' . $S . '[a-z]/';

$s_cnt = strlen($S);
$t_cnt = strlen($T);



$ans = preg_match($pattern, $T) && ($t_cnt - $s_cnt) === 1 ? 'Yes' : 'No';

printf('%s', $ans);



Measured memory_bytes: 16284
/* Filename: ABC045B.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			String[] S = new String[3];
			
			for(int i = 0; i < S.length; ++i){
				S[i] = input.next();
			}
			
			int[] head = new int[3];
			int turn = 0;
			
			while(head[turn] < S[turn].length()){
				int next = S[turn].charAt(head[turn]) - 'a';
				++head[turn];
				turn = next;
			}
			
			System.out.println((char)(turn + 'A'));
		}
	}

}


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

int main(){
    int n;


    while(cin >> n, n != 0){
        vector<int> a(n);
        for(int i=0; i<n; i++){
            cin >> a[i];
        }

        int minimum = 0;
        int x = 0;
        int maximum = -9999999;
        for(int i=0; i<a.size(); i++){
            x += a[i];
            maximum = max(maximum, x-minimum);
            minimum = min(minimum, x);
        }

        cout << maximum << endl;

    }

    return 0;
}

Measured memory_bytes: 0
{-# LANGUAGE BangPatterns #-}
import Data.Word
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U

-- Input: s t
-- Output: arr
--   (arr ! i) ! j == length of lcs of (drop i s, drop j t)
lcsTable :: BS.ByteString -> BS.ByteString -> V.Vector (U.Vector Word16)
lcsTable s t = V.scanr' (\ !x !v ->
                           -- for some i (0 <= i < m),
                           --   x = BS.index s i :: Char
                           --   v = arr ! (i+1) :: U.Vector Word16
                           U.scanr (\(!y,!w,!u) !l ->
                                      -- for some j (0 <= j < n)
                                      --   y = BS.index t j :: Char
                                      --   w = (arr ! (i+1)) ! j :: Word16
                                      --   u = (arr ! (i+1)) ! (j+1) :: Word16
                                      --   l = (arr ! i) ! (j+1) :: Word16
                                      if x == y
                                      then u + 1
                                      else max w l
                                   ) 0 (U.zip3 t' (U.init v) (U.tail v))
                        ) (U.replicate (n+1) 0) (V.fromListN m $ BS.unpack s)
  where !m = BS.length s
        !n = BS.length t
        !t' = U.fromListN n (BS.unpack t)

solve :: BS.ByteString -> BS.ByteString -> BS.ByteString
solve s t = let !table = lcsTable s t
                !m = BS.length s
                !n = BS.length t
                recon !i !j | i >= m || j >= n = Nothing
                            | x == y = let !i' = i+1 ; !j' = j+1
                                       in Just (x, (i', j'))
                            | (table V.! (i+1)) U.! j >= (table V.! i) U.! (j+1) = recon (i+1) j
                            | otherwise = recon i (j+1)
                  where x = BS.index s i
                        y = BS.index t j
                (result, _) = BS.unfoldrN (fromIntegral $ (table V.! 0) U.! 0) (\(!i,!j) -> recon i j) (0,0)
            in result

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  if BS.length s <= BS.length t
    then BS.putStrLn (solve s t)
    else BS.putStrLn (solve t s)


Measured memory_bytes: 25468
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL m;
	cin >> m;
	LL sum = 0, len = 0;
	inc(i, m) {
		LL d, c;
		cin >> d >> c;
		sum += d * c;
		len += c;
	}
	
	cout << (sum - 1) / 9 + (len - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
r,c=list(map(int,input().split()))
l=[]
for i in range(r):
	a=list(map(int,input().split()))
	a.append(sum(a))
	l.append(a)
b=[]
for i in range(c+1):
	c=0
	for j in range(r):
		c+=l[j][i]
	b.append(c)
l.append(b)

for i in l:
	print(" ".join(list(map(str,i))))

Measured memory_bytes: 7716
import java.util.HashSet;
import java.util.Scanner;

/**
 * Created by Reopard on 2014/06/05.
 */
public class Main{
    static Scanner sc = new Scanner(System.in);
    static HashSet<String> set = new HashSet<String>();

    public static void main(String[] args){
        int n, p;
        String line;
        char[] train, forward, back;
        n = sc.nextInt();
        while(n > 0){
            set.clear();
            line = sc.next();
            train = line.toCharArray();
            for(int i = 1; i < train.length; i++){
                forward = new char[i];
                back = new char[train.length - i];
                for(p = 0; p < i; p++) forward[p] = train[p];
                for(; p < train.length; p++) back[p - i] = train[p];
                addTrainPair(forward, back);
                addTrainPair(back, forward);
            }
            System.out.println(set.size());
            n--;
        }

    }

    static void addTrainPair(char[] f, char[] b){
        int i, p;
        char[] tmp = new char[f.length + b.length], f_reverse = reversalLine(f), b_reverse = reversalLine(b);
        for(p = 0; p < f.length; p++) tmp[p] = f[p];
        for(i = p; i < b.length + p; i++) tmp[i] = b[i - p];
        set.add(new String(tmp));
        for(p = 0; p < f.length; p++) tmp[p] = f_reverse[p];
        for(i = p; i < b.length + p; i++) tmp[i] = b[i - p];
        set.add(new String(tmp));
        for(p = 0; p < f.length; p++) tmp[p] = f[p];
        for(i = p; i < b.length + p; i++) tmp[i] = b_reverse[i - p];
        set.add(new String(tmp));
        for(p = 0; p < f.length; p++) tmp[p] = f_reverse[p];
        for(i = p; i < b.length + p; i++) tmp[i] = b_reverse[i - p];
        set.add(new String(tmp));
    }

    static char[] reversalLine(char[] a){
        char[] tmp = new char[a.length];
        for(int i = 0; i < a.length; i++) tmp[i] = a[a.length - i - 1];
        return tmp;
    }
}

Measured memory_bytes: 54312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    string S;
    cin >> S;
    if(S.back() == 's'){
        S.push_back('e');
    }
    S.push_back('s');
    cout << S << endl;
}


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

int main() {
  long long int N;
  cin >> N;
  vector<int> A(N);
  vector<int> sum(N);
  for( int i= 1 ; i < N ; i++ ){
    cin >> A.at(i);
    sum.at((A.at(i) - 1))++;
  }
  
  for( int i= 0 ; i < N ; i++ ){
    cout << sum.at(i) << endl;
  }
}


Measured memory_bytes: 4776
N = int(input())
An = list(map(int, input().split()))
M = sum([0 if a >=0 else 1 for a in An])
An = [abs(a) for a in An]
if M % 2 == 0:
  print(sum(An))
else:
  print(sum(An) - 2*min(An))


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

#define int long long
using P = pair<int, int>;
const int INF = 1e9;

string s;
vector<vector<P> > dp;

P dfs(int l, int r) {
  if ( dp[l][r] != P(-INF, INF) ) {
    return dp[l][r];    
  }
  if ( l == r ) {
    return P(s[l]-'0', s[l]-'0');    
  }

  P ret = {-INF, INF};
  if ( s[l] == '(' && r-l >= 3 ) {
    P res = dfs(l+1, r);
    ret.first = max(ret.first, res.first);
    ret.second = min(ret.second, res.second);    
  }
  
  if ( s[r] == ')' && r-l >= 3 ) {
    P res = dfs(l, r-1);
    ret.first = max(ret.first, res.first);
    ret.second = min(ret.second, res.second);    
  }
  
  for ( int i = l+1; i < r; i++ ) {
    if ( s[i] == '+' ) {
      P res1 = dfs(l, i-1);
      P res2 = dfs(i+1, r);      
      ret.first = max(ret.first, res1.first+res2.first);
      ret.second = min(ret.second, res1.second+res2.second);      
    }
    if ( s[i] == '-' ) {
      P res1 = dfs(l, i-1);
      P res2 = dfs(i+1, r);      
      ret.first = max(ret.first, res1.first-res2.second);
      ret.second = min(ret.second, res1.second-res2.first);      
    }
  }

  return dp[l][r] = ret;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> s;

  int n = s.size();
  dp = vector<vector<P> >(n+1, vector<P>(n+1, P(-INF, INF)));

  cout << dfs(0, n-1).first << endl;  
  
  return 0;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    int ans = d[n/2]-d[n/2-1];
    cout << ans << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

using Graph = vector<vector<int>>;

vector<ll> col(202020, -1);

void dfs(ll now, ll par, ll dist, Graph &G){
	col[now] = dist%2;
	for(auto next: G[now]){
		if(next == par) continue;
		dfs(next, now, dist+1, G);
	}
	return;
}

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

    ll N;
    cin >> N;
    Graph G(N);
    REP(i, N-1){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    }
    dfs(0, -1, 0, G);

    vector<ll> res(N, -1);
    
    vector<vector<ll>> w(2);
    REP(i, N){
    	w[col[i]].push_back(i);
    }

    ll mi, ma;
    if((int)w[0].size() <= (int)w[1].size()){
    	mi = 0, ma = 1;
    }else{
    	mi = 1, ma = 0;
    }

    ll one = N/3;
    ll two = N/3;
    ll three = N/3;
    if(N%3==1){
    	one++; 
    }
    if(N%3==2){
    	one++;
    	two++;
    }

    if((int)w[mi].size()<two){
    	REP(i, w[mi].size()){
    		res[w[mi][i]] = 3;
    	}
    	three -= w[mi].size();
    }else{
    	REP(i, w[mi].size()){
    		if(two>0){
    			res[w[mi][i]] = 2;
    			two--;
    		}else{
    			res[w[mi][i]] = 3;
    			three--;
    		}
    	}
    }

    /*
    REP(i, N){
    	cerr << col[i] << " ";
    }
    cerr << endl;
    */

    REP(i, N){
    	if(res[i]==-1){
    		if(one>0){
    			res[i] = 1;
    			one--;
    		}else if(two>0){
    			res[i] = 2;
    			two--;
    		}else if(three>0){
    			res[i] = 3;
    			three--;
    		}
    	}
    }

    ll aa = 1, bb=2, cc=3;
    REP(i, N){
    	if(res[i]%3==1){
    		res[i] = aa;
    		aa += 3;
    	}else if(res[i]%3==2){
    		res[i] = bb;
    		bb += 3;
    	}else{
    		res[i] = cc;
    		cc += 3;
    	}
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 24556
#include <bits/stdc++.h>
using namespace std;
// 내 뒤에있지만 더 작은거 세면, 그게 k, k-1, ... 1번 나타나고 (k+1)*k/2
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	ll ans = 0;
	for(int i=0; i<n; i++) {
		ll cnt = 0;
		for(int j=i+1; j<n; j++) {
			if(v[i] > v[j])
				cnt++;
		}
		ans += (((k+1)*k/2)%MOD) * cnt;
		cnt = 0;
		for(int j=0; j<i; j++) {
			if(v[i] > v[j])
				cnt++;
		}
		ans += ((k*(k-1)/2)%MOD)*cnt;
		ans %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n;
  cin >> n;
  vector<int> W(n);
  for(int i=0; i<n; i++) cin >> W[i];
  int sum=0;
  for(int i=0; i<n; i++) sum+=W[i];

  int lsum=0, rsum=sum;
  int ans =10101;
  for(int i=0; i<n; i++){
    lsum+=W[i];
    rsum-=W[i];
    ans=min(ans, abs(lsum-rsum));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,pre[300005],nex[300005],a[300005];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)
		if ((a[i]^i)&1) { printf("No\n");return 0; }
	pre[0]=0,nex[n+1]=1000000000;
	for (int i=1;i<=n;i++) pre[i]=max(pre[i-1],a[i]);
	for (int i=n;i>=1;i--) nex[i]=min(nex[i+1],a[i]);
	for (int i=1;i<=n-1;i++)
		if (((a[i]==i)==(a[i+1]==i+1)) && pre[i]!=i) { printf("No\n");return 0; }
	for (int i=2;i<n;i++)
		if (a[i]!=i && nex[i+1]<a[i] && pre[i-1]>a[i]) { printf("No\n");return 0; }
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3840
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    # YouTubeの通り
    dn, s = MI()
    dd = LI()
    qn = II()
    qq = LI()
    qi = [(q - 1, i) for i, q in enumerate(qq)]
    # pos[i]...dd[i]の移動前の位置
    pos = [s]
    for d in dd:
        pos.append(min(pos[-1], abs(d - pos[-1])))
    # print(pos)
    # bb[i]...dd[i]の移動前にこの距離以上の位置にいればゴールに届かないという境目
    bb = [1] * (dn + 1)
    for i in range(dn - 1, -1, -1):
        d = dd[i]
        if d < bb[i + 1] * 2:
            bb[i] = bb[i + 1] + d
        else:
            bb[i] = bb[i + 1]
    # print(bb)
    #    dd0   dd1   dd2   dd3
    # po0   po1   po2   po3   po4
    # bb0   bb1   bb2   bb3   bb4
    # という前後関係なのでq番目(0-origin)のddに魔法をかけるときは
    # pos[q]>=bb[q+1]であるなら妨害可能(YES)
    ans = [""] * qn
    for q, ai in qi:
        if pos[q] >= bb[q + 1]: ans[ai] = "YES"
        else: ans[ai] = "NO"
    print(*ans, sep="\n")

main()


Measured memory_bytes: 152056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <cstdio>
using namespace std;

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;
using qll = queue<ll>;
using vqll = V<qll>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin() 
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a) //
/*vvll v(n,vll(m)) n行m列  continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aのv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
priority_queue<ll> pque; pque.push(ai); pque.top()→max(ai) 
vqll q(3);  q[0].push(0); q[0].push(2); q[0].push(1);
q[0].front()→0 q[0].back()→1 q[0].pop(); q[0].front()→2
que.pop() que.sz while(!que.empty())
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow_mod(ll a,ll n,ll m){
  ll res=1;
  for(;n>0;n/=2){
    if(n%2==1)res=(res*a)%m;
    a=(a*a)%m;
  }
  return res;
}

int main(){
  str s;
  cin>>s;
  ll n=s.sz;
  vvll dp(100001,vll(13));
  if(s[0]=='?'){
    FOR(i,0,10){
      dp[0][i]=1;
    }
  }
  else{
    dp[0][s[0]-'0']=1;
  }
  FOR(i,1,n){
    if(s[i]=='?'){
      FOR(j,0,13){
        FOR(k,0,10){
          dp[i][(10*j+k)%13]+=dp[i-1][j]%MOD;
        }
      }
    }
    else{
      FOR(j,0,13){
        dp[i][(10*j+(s[i]-'0'))%13]+=dp[i-1][j]%MOD;
      }
    }
    /*FOR(j,0,13){
      if(j==12)co(dp[i-1][j]);
      else cout<<dp[i-1][j]<<" ";
    }*/
  }
  co(dp[n-1][5]%MOD);
}


Measured memory_bytes: 13696
using System;
using System.Linq;
using System.Xml.Schema;

namespace ABC099D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] ints = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = ints[0];
            int c = ints[1];

            int[][] ds = new int[c][];
            for (int i = 0; i < c; i++)
            {
                int[] dline = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                ds[i] = dline;
            }

            int[][] cs = new int[n][];
            for (int i = 0; i < n; i++)
            {
                int[] cline = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                cs[i] = cline;
            }

            int[][] scores = new int[3][];
            for (int i = 0; i < 3; i++)
            {
                scores[i] = score(cs, ds, i, n, c);
            }

            int[] patterns = new int[c * c * c];
            for (int i = 0; i < c; i++)
            {
                for (int j = 0; j < c; j++)
                {
                    for (int k = 0; k < c; k++)
                    {
                        if (i == j || i == k || j == k)
                        {
                            patterns[i + c*j + c*c*k] = Int32.MaxValue;
                            continue;
                        }

                        patterns[i + c * j + c * c * k] = scores[0][i] + scores[1][j] + scores[2][k];
                    }
                }
            }
            Console.WriteLine(patterns.Min());
        }

        public static int[] score(int[][] cs, int[][] ds, int offset, int n, int c)
        {
            int space = n * n;

            int[] scores = new int[c];
            for (int colorIndex = 0; colorIndex < c; colorIndex++)
            {
                for (int i = 0; i < space; i++)
                {
                    int ndiv = i / n;
                    int ndiva = i % n;
                    if ((ndiv + ndiva) % 3 != offset)
                    {
                        continue;
                    }

                    int currentColorIndex = cs[ndiv][ndiva] - 1;
                    int score = ds[currentColorIndex][colorIndex];
                    scores[colorIndex] += score;
                }
            }

            return scores;
        }
    }
}

Measured memory_bytes: 18260
#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 mod = 1000000007;
int N , M ;
cin >> N >> M ;
vector<int> A(M) ;
queue<int> pq ;
rep(i,M) cin >> A.at(i) ;
rep(i,M) pq.push(A.at(i))  ; 
int dp[1000100] ; 
dp[1] = 1 ;
dp[2] = 2 ;
  if( pq.front() == 1 ){
  dp[1] = 0 ;
  pq.pop() ;
  }
  if( dp[1] == 0 ) dp[2] = 1;
  if( pq.front() == 2 ){
  dp[2] = 0 ;
  pq.pop() ;
  }
  for(int i = 1 ; i <= N-1 ;i++ ){
    dp[i+2] = dp[i+1] + dp[i] ;
    dp[i+2] %=mod ;
    if( i+2 == pq.front() ){
      dp[i+2] = 0 ;
      pq.pop() ;
    }
  }
  //for(int i = 1 ; i<=N ;i++ ) cout << dp[i] <<endl;
  cout << dp[N] << endl;
  }

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

int n, a[200003], all=0;

int main(){
	cin >> n;
	for (int i=0;i<n;i++){
		cin >> a[i];
		all^=a[i];
	}
	for (int i=0;i<n;i++) cout << (a[i]^all) << " ";
	cout << "\n";
}

Measured memory_bytes: 4328
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2]-a[0] << endl;
	return 0;
}

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repl(i,n) for(long long i = 0; i < (long long)(n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrpel(i,n) for(long long i = (long long)(n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); srand(time(NULL));
    char c;
    cin >> c;
    c++;
    cout << c << endl;
    return 0;
};


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    // 処理
    int e, f;
    e       = max(a, c);
    f       = min(b, d);
    int ans = max(f - e, 0);

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(double x){
  printf("%.15f",x);
}
int main(){
  double res;
  int N, V[50], i;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(V[Lj4PdHRW]);
    }
  }
  sort(V, V+N);
  res = V[0];
  for(i=(1);i<(N);i++){
    res = (res + V[i]) / 2;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190820-1

// --- original code ---
// {
//   int N, V[50];
//   double res;
//   rd(N,V(N));
//   sort(V, V+N);
//   res = V[0];
//   rep(i,1,N) res = (res + V[i]) / 2;
//   wt(res);
// }


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
   
fast;

ll n;
cin>>n;

ll a[n];
ll tot=0;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    tot=tot xor a[i];
}

for(ll i=0;i<n;i++)
cout<<(tot xor a[i])<<" ";

}


Measured memory_bytes: 5148
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	s := ReadString()
	c := len(s)
	f := -1
	for i := 0; i < len(s); i++ {
		if s[i] == 'C' && i < c {
			c = i
		}
		if s[i] == 'F' && i > f {
			f = i
		}
	}
	if c < f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
const main = (N,D,X) => {
    var count = 0

    for(var i =0;i<N;i++) {
        for(var k=i+1;k<N;k++) {
            var tmp = 0
            for(var j = 0;j<D;j++) {
                tmp+=Math.pow(X[i][j] - X[k][j],2)
            }

            if(Number.isInteger(Math.sqrt(tmp))) {
                count++
            }
        }
    }
    return count
}




const input = require('fs').readFileSync('/dev/stdin','utf8')
                           .split("\n")
                           .filter(i => i !== '')
const lst = input.map(i => i.split(" ").map(x => Number(x)))
const N = lst[0][0]
const D = lst[0][1]
const X = lst.slice(1,lst.length)
console.log(main(N,D,X))

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

int main() {
	string S;
	cin >> S;
	string T;
	cin >> T;

	bool ans = true;
	rep(i, S.size()) {
		if(S[i] != T[i]) ans = false;
	}

	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3628