akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

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

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


string grid[2222];
ll up[2222][2222], low[2222][2222],ri[2222][2222], le[2222][2222];


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


  ll h, w;
  cin >> h >> w;
  rep(i, w + 2) s += '#';
  grid[0] = s;
  grid[h + 1] = s;
  rep(i, h) {
    cin >> s;
    grid[i + 1] = "#" + s + "#";
  }

  FOR(x, 1, w + 1) {
    FOR(y, 0, h + 2) {
      if (grid[y][x] == '#') up[y][x] = y;
      else up[y][x] = up[y - 1][x];
    }
    RFOR(y, 0, h + 2) {
      if (grid[y][x] == '#') low[y][x] = y;
      else low[y][x] = low[y + 1][x];
    }
  }

  FOR(y, 1, h + 1) {
    FOR(x, 0, w + 2) {
      if (grid[y][x] == '#') le[y][x] = x;
      else le[y][x] = le[y][x - 1];
    }
    RFOR(x, 0, w + 2) {
      if (grid[y][x] == '#') ri[y][x] = x;
      else ri[y][x] = ri[y][x + 1];
    }
  }

  FOR(y, 1, h + 1) FOR(x, 1, w + 1) {
    if (grid[y][x] == '#') continue;
    tmp = 0;
    tmp += low[y][x] - up[y][x] - 1;
    tmp += ri[y][x] - le[y][x] - 1;
    tmp--;
    ma = max(ma, tmp);
  }
  cout << ma << endl;


  return 0;
}

Measured memory_bytes: 153600
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,D;
    cin >> N >> D;
    ll X[N][D];
    rep(i,N){
        rep(j,D) cin >> X[i][j];
    }
    ll out = 0;
    rep(i,N){
        rep(j,N){
            ll dist = 0;
            if(i==j) break;
            else{
                rep(k,D) dist += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
                rep(l,401){
                    if(l*l==dist){
                        out++;
                        break;
                    }
                }
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;


int main(void){
  string s;
  cin >> s;
  ll n = s.size();
  
  reverse(s.begin(), s.end());
  
  ll res = 0;

  for (int i = 0; i < 1 << (n - 1); i++){
    ll t = 1;
    res += s[0] - '0';
    for (int j = 0; j < n - 1; j++){
      if (((i >> j) & 1))
        t = 1;
      else 
        t *= 10;
      res += (s[j + 1] - '0') * t;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left,bisect_right
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))

ans = 0
for x in b:
    ans += bisect_left(a,x)*(n-bisect_right(c,x))
print(ans)

Measured memory_bytes: 23232
#深さ優先探索
def dfs(Graph, Start, pl, parent, Visited=None):
    if (Visited==None):  Visited = [] #開始点のときに探索済みリストをつくる
    Visited.append(Start)  #現在の頂点を探索済みリストに加える
    pre[Start] = pl
    low[Start] = pl
    pl += 1
    for Next in Graph[Start]:  #次に探索する頂点の候補
        if Next == parent:
            continue
        if ( Next in Visited ):
            low[Start] = min(low[Start], low[Next])
            continue  #訪問済みリストにある頂点は飛ばす
        loww = dfs(Graph, Next, pl,Start, Visited)  #再帰
        low[Start] = min(low[Start], loww)
    return low[Start]


N, M = (int(i) for i in input().split())

inp = [[int(i) for i in input().split()] for i in range(M)]

pre = [0 for _ in range(N+1)]
low = [0 for _ in range(N+1)]

# 隣接リスト
l = [[] for i in range(N+1)]
for pi in inp:  #0-originedに注意
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])

dfs(l, 1, 1, 0)

cnt = 0
for i in range(2,N+1):
    if pre[i]==low[i]:
        cnt += 1
print(cnt)


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


using namespace std;

int main()
{
int n;
scanf("%d",&n);
int S4=0,S2=0,S1=0;
for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a%4==0)
        S4++;
    else if(a%2==0)
        S2++;
    else
        S1++; 

}
//cout<<S4<<' '<<S2<<' '<<S1<<endl;
if(S2>=1)
    S1+=1;
if(S1-1<=S4){
    puts("Yes");
}
else
    puts("No");
return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MAXN = 100005;

vector<pii> KV;

int B[16];
int A[MAXN];

int N, Ans;

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

	cin >> N;
	for(int i = 1, a, b, c; i < N; i++) {
		cin >> a >> b >> c;
		a++; b++;
		A[a] ^= c;
		A[b] ^= c;
	}
	for(int i = 1; i <= N; i++) B[A[i]]++;

	Ans = B[0]; B[0] = 0;
	for(int i = 1; i <= 15; i++) {
		Ans += B[i]/2;
		B[i] &= 1;
	}

	int master = 0;
	for(int i = 0; i < 15; i++) B[i] = B[i+1];
	for(int i = 0; i < 15; i++) if(B[i]) master |= 1<<i;

	for(int key = 1; key <= master; key++) {
		if((key & master) != key) continue;
		int sum = 0, cnt = 0;
		for(int i = 0; i < 15; i++) if(key & (1<<i)) {
			cnt++; sum ^= i+1;
		}
		if(sum) continue;
		KV.eb(cnt, key);
	}

	sorv(KV);

	int used = 0;
	for(auto &p : KV) {
		if(used & p.second) continue;
		used |= p.second;
		Ans++;
	}

	cout << (N - Ans) << endl;
	return 0;
}

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

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

#define COST_MAX (40*100+1)
#define MIN(a,b)    ( ((a)<(b))?(a):(b) )

int main(){
    int N,Ma,Mb;
    int a[40],b[40],c[40],min_cost=COST_MAX;
    int Table[41][401][401];

    scanf("%d %d %d%*c",&N,&Ma,&Mb);
    for(int i=0;i<N;i++)
        scanf("%d %d %d%*c",a+i,b+i,c+i);
    
    for(int i=0;i<=40;i++){
        for(int j=0; j<=400; j++){
            for(int k=0; k<=400; k++){
                Table[i][j][k]=COST_MAX;
            }
        }
    }
    Table[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0; j<i*10+1; j++){
            for(int k=0; k<i*10+1; k++){
                if(Table[i][j][k]!=COST_MAX){
                    Table[i+1][j][k] =
                        MIN(Table[i][j][k], Table[i+1][j][k]);
                    Table[i+1][j+a[i]][k+b[i]] =
                        MIN(Table[i][j+a[i]][k+b[i]], Table[i][j][k]+c[i]);
                }
            }
        }
    }

    for(int i=1; i*Ma<= 400 && i*Mb<= 400; i++){
        if(min_cost > Table[N][i*Ma][i*Mb])
            min_cost=Table[N][i*Ma][i*Mb];
    }
    printf("%d\n",(min_cost==COST_MAX)?(-1):min_cost);
    
    return 0;
}

Measured memory_bytes: 25856
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>

using namespace std;

int main(){

	int ans=0;
	int n,m;
	cin>>n>>m;

	int k;
	if(n<m){
		for(int i=0;i<m;i++){
			cout<<n;
		}
	}
	else {
		for(int i=0;i<n;i++){
			cout<<m;
		}
	}

	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <deque>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define mp make_pair
#define fname ""
#define fi first
#define se second
#define sz(a) (int)a.size()
#define pb push_back
#define fo(i,k,n) for(int i=k; (int)i<n; ++i)
#define rep(i,n,k) for(int i=n; (int)i>=k; --i)
#define all(v) v.begin(), v.end()
#define it ::iterator
#define forit(it,v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 100100;


int main(){
    
    int a,b,c;
    cin>>a>>b>>c;
    
    if(abs(a-b) <= abs(a-c)){
        printf("A");
    } else {
        printf("B");
    }



    return 0;
}


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

typedef long long ll;
ll s;

int main() {
    cin >> s;

    // 1回で超える場合
    if (s <= 6) {
        cout << 1 << endl;
        return 0;
    } 

    ll tmp = s / 11;
    int mod = s % 11;

    if (mod == 0) {
        cout << tmp * 2 << endl;
    } else if (mod <= 6) {
        cout << tmp * 2 + 1 << endl;
    } else {
        cout << tmp * 2 + 2 << endl;
    }
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //



int main(){

  ll N, M;
  cin >> N >> M;

  // n頂点 0辺の有向グラフをつくるコンストラクタ O(n)
  scc_graph graph(N);

  // from -> to へ有向辺を張る 0-indexed ならしO(1)
  rep(i, M){
    int from = ii();
    int to = ii();
    graph.add_edge(from, to); 
  }

  // vector[i] := トポロジカルソートして i 番目の 頂点リスト（内部の順番は未定義）
  // O(V+E)
  vector<vector<int> > tsorted = graph.scc();

  cout << SZ(tsorted) << endk;
  for (vector<int> component : tsorted){
    cout << SZ(component) << " ";
    cout << component << endk;
  }


}



Measured memory_bytes: 40076
#include <iostream>
#include <string>

using namespace std;

int main() {
  int m = 0, i = 0;
  string s, t;
  cin >> s >> t;
  for (auto ch=s.begin(); ch!=s.end(); ++ch, ++i) {
    int c = 0, j = 0;
    for (auto b = t.begin(), d = ch; b != t.end(); ++d, ++b, ++j) {
      if (i > j && (s.length() - i) < t.length()) {
        break;
        c = 0;
      }
      if (*b == *d) {
        ++c;
      }
    }
    if (c > m) {
      m = c;
    }
  }
  if (m <= t.length()) {
    cout << t.length() - m << '\n';
  } else { 
    cout << 0 << '\n';
  }
  return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    long long num = (N - 1) * (N - 2) / 2;
    if (K > num)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << N - 1 + num - K << endl;
    for (int i = 2; i <= N; i++)
        cout << 1 << ' ' << i << endl;

    long long curr = num;
    for (int i = 2; i <= N; i++)
        for (int j = i + 1; curr > K and j <= N; j++)
        {
            cout << i << ' ' << j << endl;;
            curr --;
        }
    return 0;
}

Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
import           Data.Vector.Algorithms.Search
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO
import qualified Data.Set                      as S

main = do
    [aA, aB, aC, aD] <- getIL

    let s = div aC aB + if mod aC aB == 0 then 0 else 1
    let k = div aA aD + if mod aA aD == 0 then 0 else 1

    putStrLn $if s <= k then "Yes" else "No"

getVUIL :: IO (VU.Vector Int)
getVUIL = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readI :: BSC8.ByteString -> Int
readI = fst . fromJust . BSC8.readInt
readIL :: BSC8.ByteString -> [Int]
readIL = map readI . BSC8.words
readIT2 :: BSC8.ByteString -> (Int, Int)
readIT2 bs =
    let words = BSC8.words bs in (readI $ head words, readI $ last words)
getI :: IO Int
getI = readI <$> BSC8.getLine
getIL :: IO [Int]
getIL = readIL <$> BSC8.getLine
getIT2 :: IO (Int, Int)
getIT2 = readIT2 <$> BSC8.getLine

getNIS :: Int -> IO [(Int, BSC8.ByteString)]
getNIS 0 = return []
getNIS n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getNIS (n - 1))
    return ((readI aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

modNum = 10 ^ 9 + 7
newtype Mint = M Int
instance Num Mint where
    (M a) + (M b) = M $ mod (a + b) modNum
    (M a) - (M b) = M (a - b)
    (M a) * (M b) = M $ mod (a * b) modNum
    fromInteger a = M $ mod (fromInteger a) modNum
    abs (M a) = M $ abs a
    signum (M a) = M $ signum a
instance Show Mint where
    show (M a) = show (mod a modNum)

int2MInt :: Int -> Mint
int2MInt a = M (mod a modNum)


Measured memory_bytes: 4188
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 15:08:19
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int a, b;
    cin >> a >> b;

    int x, y, z;
    x = a + b;
    y = a - b;
    z = a * b;

    cout << max({x, y, z}) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;


int main()
{
    int64_t a;
    cin>>a;
    int b,c;
    scanf("%d.%d",&b,&c);
    int64_t s;
    s=a*b*100+a*c;
    s=s/100;
    printf("%lld",s);
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n, k; cin >> n >> k;
  k++;
  Vll a(n); 
  rep(i, n) cin >> a[i];
  const int m = 42;

  VVll cnt(m, Vll(2));
  rep(i, m) rep(j, n) {
    if (a[j] % 2 == 0) ++cnt[i][0];
    if (a[j] % 2 == 1) ++cnt[i][1];
    a[j] /= 2;
  }

  Vll score(m+1);
  rep(i, m) {
    score[i+1] += score[i] + (max(cnt[i][0], cnt[i][1])) * (1ll<<i);
  }

  ll d = 1ll<<m;
  ll scr_now = 0;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    int x = (k / (1ll<<i)) % 2;
    if (x == 1) {
      chmax(ans, scr_now + cnt[i][1] * (1ll<<i) + score[i]);
    }
    scr_now += cnt[i][1-x] * (1ll<<i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
<?php
define( "TOP", 0 );
define( "FRONT", 1 );
define( "RIGHT", 2 );
define( "LEFT", 3 );
define( "BACK", 4 );
define( "BOTTOM", 5 );
class Dice
{
	private $labels;
	public function __construct( $labels )
	{
		$this->labels = $labels;
	}
	public function roll( $cmds )
	{
		$len = strlen( $cmds );
		for( $i=0; $i<$len; $i++ ) {
			if( 'E' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[LEFT];
				$this->labels[LEFT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $t;
			} else if( 'S' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[BACK];
				$this->labels[BACK] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[FRONT];
				$this->labels[FRONT] = $t;
			} else if( 'W' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[LEFT];
				$this->labels[LEFT] = $t;
			} else if( 'N' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[FRONT];
				$this->labels[FRONT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[BACK];
				$this->labels[BACK] = $t;
			} else if( 'M' == $cmds[$i] ) {
				$t = $this->labels[FRONT];
				$this->labels[FRONT] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $this->labels[BACK];
				$this->labels[BACK] = $this->labels[LEFT];
				$this->labels[LEFT] = $t;
			}
		}
	}
	public function getLabel( $face )
	{
		return $this->labels[ $face ];
	}
}
	
	$labels = explode( " ", trim( fgets( STDIN ) ) );
	$dice = new Dice( $labels );
	$q = trim( fgets( STDIN ) );
	$cmds = "NEEENMMMM";
	$len = strlen( $cmds );
	$output = [];
	while( $q-- ) {
		$num = explode( " ", trim( fgets( STDIN ) ) );
		$top = $num[0];
		$front = $num[1];
		for( $i=0; $i<=5; $i++ ) {
			if( $top == $dice->getLabel( TOP ) ) {
				for( $j=5; $j<$len; $j++ ) {
					if( $front == $dice->getLabel( FRONT ) ) {
						array_push( $output, $dice->getLabel( RIGHT ) );
						break; 
					}
					$dice->roll( $cmds[$j] );
				}
				break;
			}
			$dice->roll( $cmds[$i] );
		}
	}
	print implode( PHP_EOL, $output );
?>

Measured memory_bytes: 15620
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int lli;
typedef pair<int,int> pii;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

bool Compare(const pair<double,string>& a,const pair<double,string> &b){
	if(a.first<b.first) return true;
	else if(a.first>b.first) return false;
	else{
		if(a.second>b.second) return true;
		else return false;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while(true){
		cin >> N;
		if(!N) break;
		vector<pair<double,string>> x(N);
		REP(i,0,N){
			string l;
			double p,a,b,c,d,e,f,s,m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			x[i]=MP((f*s*m-p)/(a+b+c+(d+e)*m),l);
		}
		sort(x.rbegin(),x.rend(),Compare);
		REP(i,0,N){
			cout << x[i].second << endl;
		}
		cout << '#' << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
a,b,c,d = gets.chomp.split(' ').map(&:to_i)

for count in 1..100 do
  count += 1
  if(c-b > 0)
    c = c-b
    if(a-d > 0)
      a = a-d
    else
      str = "No"
      break
    end
  else
    str = "Yes"
    break
  end
end

puts str


Measured memory_bytes: 14340
#include <iostream>
using namespace std;
int main(void){
    int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<v[k-1];
}


Measured memory_bytes: 256
n = gets.to_i
ans = 0
tmp = 0

row_one = gets.chomp.split.map(&:to_i)
row_two = gets.chomp.split.map(&:to_i)

(1..n-1).each do |i|
  row_one[i] += row_one[i-1]
end

(1..n-1).each do |i|
  row_two[i] += row_two[i-1]
end

ans = row_one[0] + row_two[n-1]

(1..n-1).each do |i|
  tmp = row_one[i] + row_two[n-1] - row_two[i-1]
  ans = [ans,tmp].max
end

puts ans

Measured memory_bytes: 1788
def main():
    n = int(input())
    t = [int(i) for i in input().split()]
    t_sum = sum(t)
    m = int(input())
    for j in range(m):
        p,x = (int(i) for i in input().split())
        ans = t_sum - t[p-1] + x
        print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  long long a[n], b[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  long long button = 0;
  for(int i = n - 1; i >= 0; i--) {
    if((a[i] + button) % b[i] != 0) {
      button += b[i] - ((a[i] + button) % b[i]);
    }
  }

  cout << button << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define InF 1000000000000
#define MOD 1000000007
using ll = long long;

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

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

  ll res = 0;
  vector<ll> r(n),g(n),b(n);
  rep(i,n){
    if(i!=0){
      r.at(i)=r.at(i-1);
      g.at(i)=g.at(i-1);
      b.at(i)=b.at(i-1);
    }
    if(S.at(i)=='R')r.at(i)++;
    if(S.at(i)=='G')g.at(i)++;
    if(S.at(i)=='B')b.at(i)++;
  }
  for(int i = 1; i <= n-2; i++){
    if(S.at(i)=='R'){
      res+= g.at(i-1)*(b.at(n-1)-b.at(i));
      res+= b.at(i-1)*(g.at(n-1)-g.at(i));
    }else if(S.at(i)=='B'){
      res+= r.at(i-1)*(g.at(n-1)-g.at(i));
      res+= g.at(i-1)*(r.at(n-1)-r.at(i));
    }else{
      res+=r.at(i-1)*(b.at(n-1)-b.at(i));
      res+=b.at(i-1)*(r.at(n-1)-r.at(i));
    }
    for(int j = 0; j <= i && i+j < n; j++ ){
      if(S.at(i+j)!=S.at(i-j)&&S.at(i+j)!=S.at(i)&&S.at(i-j)!=S.at(i))res--;
    }
  }
  cout<<res<<endl;
}

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

using namespace std;

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;

#define INF (1e9)

// テンプレート関数
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans;
    char huku = '0';

    ans = (W * H) / 2.0;

    // x, yが長方形の中心だった場合
    if (x+x == W && y+y == H) {
        huku = '1';
    }

    cout << ans << ' ' << huku << endl;
}

Measured memory_bytes: 256
a_b_m_var = input().split()
a_i_var = input().split()
b_i_var = input().split()

a_b_m = [int(s) for s in a_b_m_var]
a_i = [int(s) for s in a_i_var]
b_i = [int(s) for s in b_i_var]

not_discount_price = min(a_i) + min(b_i)

down_price_i = []
for i in range(a_b_m[2]):
    price_down_var = input().split()
    price_down = [int(s) for s in price_down_var]
    a, b, m = price_down[0], price_down[1], price_down[2]
    price = a_i[a-1] + b_i[b-1] - m
    down_price_i.append(price)

if not_discount_price > min(down_price_i):
    print(min(down_price_i))
else:
    print(not_discount_price)

Measured memory_bytes: 28812
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ll inp;
	cin >> inp;
	if(inp%2==0) cout << "-1\n";
	else{
		ll temp=0;
		ll i;
		for(i=1;i<=1000000;i++){
			temp=(temp*10+7)%inp;
			if(temp==0) break;
		}
		if(i==1000001) cout << "-1\n";
		else cout << i << '\n';
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  cin >> N;
  int a[N][2];
  bool flag = false;
  
  rep(i, N){
    cin >> a[i][0];
    a[i][0]--;
    a[i][1] = 0;
  }
  
  int current=0;
  int count=0;
  while(true){
    if(current == 1){
      flag = true;
      break;
    }else if(a[current][1] > 0){
      break;
    }else{
      count++;
      a[current][1]++;
      current = a[current][0];
    }
  }
                  
  if(flag == true) cout << count << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 1024
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M = MI()
    S=ST()
    ans_rev = []
    S_rev = S[::-1]
    i=0
    while i<N:
        step = False
        for j in range(1,M+1)[::-1]:
            if i+j>N:
                continue
            if S_rev[i+j]=="0":
                step=True
                ans_rev.append(j)
                i += j
                break
        if not step:
            print(-1)
            exit()
    print(*ans_rev[::-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 51056
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < tx-sx; ++i) cout << 'R';
  for (int i = 0; i < ty-sy; ++i) cout << 'U';
  for (int i = 0; i < tx-sx; ++i) cout << 'L';
  for (int i = 0; i < ty-sy; ++i) cout << 'D';
  cout << 'D';
  for (int i = 0; i <= tx-sx; ++i) cout << 'R';
  for (int i = 0; i <= ty-sy; ++i) cout << 'U';
  cout << "LU";
  for (int i = 0; i <= tx-sx; ++i) cout << 'L';
  for (int i = 0; i <= ty-sy; ++i) cout << 'D';
  cout << 'R' << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
     
    int main(void) {
        int n,i,j;
        scanf("%d",&n);
        int a[n];
        int b[n];
        for (i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }
        
        if (n%2 == 0) {
            for (j=0;j<n/2;j++) {
                b[j] = a[n-1-(j*2)];
            }
            for (j=0;j<n/2;j++) {
                b[j+n/2] = a[2*j];
            }
        } else {
            for (j=0;j<n+1/2;j++) {
                b[j] = a[n-1-(j*2)];
            }
            for (j=0;j<n/2;j++) {
                b[j+n/2+1] = a[2*j+1];
            }
        }
        
        for (i = 0; i < n; i++) {
            printf("%d ", b[i]);
        }
        printf("\n");
        return 0;
    }

Measured memory_bytes: 3712
moji_arr = input()

first = moji_arr.split()[0]
second = moji_arr.split()[1]

num = input()
num_arr = list(map(int, num.split()))

u = input()

if u==first:
    num_arr[0] = num_arr[0] - 1
elif u==second:
    num_arr[1] = num_arr[1] - 1

print(num_arr[0], num_arr[1])

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    V<int> a(N,0),b(N,0);
    for(int i = 0; i < N; ++i){
        if(S[i]=='#') a[i]++;
        else b[i]++;
    }
    for(int i = 1; i < N; ++i) a[i] += a[i-1];
    for(int i = 1; i < N; ++i) b[i] += b[i-1];
    int ans = 2000000;
    chmin(ans,a[N-1]);
    chmin(ans,b[N-1]);
    for(int i = 0; i < N-1; ++i){
        chmin(ans,a[i] + b[N-1] - b[i]); 
    }
    cout << ans << endl;
    


    

 
    return 0;
}


Measured memory_bytes: 2180
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int a,b,x,y;
	cin>>a>>b;
	if(a>0)
	{
		cout<<"Positive"<<endl;
		goto lop1;
	}
	if(a<=0&&b>=0)
	{
		cout<<"Zero"<<endl;
		goto lop1;
	}
	if(b<0)
	{
		if((b-a+1)%2==0)
		{
			cout<<"Positive"<<endl;
			goto lop1;
		}
		else if((b-a+1)%2!=0)
		{
			cout<<"Negative"<<endl;
			goto lop1;
		}
	}
	lop1:;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
x = [int(i) for i in input().split()]

s = 0
for i in x:
    s += i

p = s//n

m = 0
mm = 0
for i in x:
    m += (i - p)**2
    mm += (i - p - 1)**2
    
print(min([m, mm]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define BITSEARCH(i,n) for(int i=0;i<(1<<(n));++i)
#define BITCHK(i,j) (i) & (1<<(j))

/* BITSEARCH 使い方
 
BITSEARCH(i,n){
  vector<int> h;
  REP(j,n){
    if (BITCHK(i,j)){
      h.push_back(j+1);
    }
  }
}

*/

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t tr = a * n;
  int64_t mi = min(tr,b);
  cout << mi << endl;
  return 0;
}



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

ll H, W;

ll ans;

void calc(ll h, ll max_h, ll max_w) {
    vector<ll> areas_1;
    vector<ll> areas_2;

    ll area1 = h * max_w;
    areas_1.push_back(area1);
    areas_2.push_back(area1);

    // 横線をひくパターン
    if (max_h - h >= 2) {
        ll area2_h = (max_h - h) / 2;
        ll area2 = area2_h * max_w;
        areas_1.push_back(area2);

        // 切り上げ
        ll area3_h = ceil((double)(max_h - h) / 2);
        ll area3 = area3_h * max_w;
        areas_1.push_back(area3);

        // printf("h: %d, area1: %d area2: %d, area3: %d\n", h, area1, area2, area3);
        sort(areas_1.begin(), areas_1.end());
        ans = min(ans, areas_1[areas_1.size() - 1] - areas_1[0]);
    }

    // 縦線をひく
    if (max_w >= 2) {
        ll area4_h = ceil((double)max_w / 2);
        ll area4 = area4_h * (max_h - h);
        ll area5_h = max_w / 2;
        ll area5 = area5_h * (max_h - h);
        areas_2.push_back(area4);
        areas_2.push_back(area5);
        // printf("h: %d, area1: %d area4: %d, area5: %d\n", h, area1, area4, area5);
        sort(areas_2.begin(), areas_2.end());
        ans = min(ans, areas_2[areas_2.size() - 1] - areas_2[0]);
    }

    // cout << ans << endl;
}

int main() {
    cin >> H >> W;

    ans = H * W;

    // A を決める
    for (int i = 1; i <= H - 1; i++) {
        calc(i, H, W);
    }

    for (int i = 1; i <= W - 1; i++) {
        calc(i, W, H);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import static java.lang.Long.bitCount;

public class Main {

    public static void main(String[] args) {
        FastScanner in = new FastScanner();
        String name;
        name = in.next();
        System.out.println(name.substring(0, 3));
    }

    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 32608
N = int( input() )
a = list( map( int, input().split() ) )


for i in range(N-1): a[i+1] += a[i]

ans = abs( a[N-1] - 2*a[0] )
for i in range(1,N-1):
    ans = min( ans, abs( a[N-1] - 2*a[i] ) )

print( ans )

Measured memory_bytes: 23800
def check_int(num):
    try:
        int(num)
        return True
    except:
        return False

a, b = map(int, raw_input().split(" "))
s = raw_input().split("-")
if len(s) != 2:
    print 'No'
else:
    flag = True
    for i in s:
        if not check_int(i):
            flag = False
    if flag:
        if len(s[0]) == a and len(s[1]) == b:
            print 'Yes'
        else:
            print 'No'
    else:
        print 'No'


Measured memory_bytes: 2568
import sys
 
n = int(input())
minv = int(input())
maxv = -1000000000
 
for r in map(int,sys.stdin.readlines()):
  m = r-minv
  if maxv < m: 
    maxv = m
    if m < 0: minv = r
  elif m < 0: minv = r
 
print(maxv)

Measured memory_bytes: 21852
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix32(int A[],const int sz)
{
  int temp[200001];const int bit=0b1000,mask=0b11111111;
  rep(k,0b100)
  {
    int u[0b100000000]={},v[0b100000000]={};
    rep(i,sz)u[A[i]>>bit*k&mask]++;
    rep(i,mask)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&mask]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&mask]++;
    rep(i,mask)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&mask]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,minus=0,A[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid;
  while(N--){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  rep(i,m)A[p+i]*=-1;
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{mid*=-1l;minus=1;int low=0;rep(i,m){while(1l*A[low]*A[p+i]<mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K){if(minus)r=-mid-1l;else r=mid-1l;}else{if(minus)l=-mid+1l;else l=mid+1l;}
  }
  return OUT(l),0;
}

Measured memory_bytes: 2908
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int a[N*N];
int G[N][N];
int main() {
    int h,w,n;
    scanf("%d%d",&h,&w);
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);

    int cnt=1;
    for(int i=1; i<=h; i++) {
        if(i%2) {
            for(int j=1; j<=w; j++) {
                if(a[cnt]==0) {
                    cnt++;
                    G[i][j]=cnt;
                    a[cnt]--;
                }
                else if(a[cnt]>0) {
                    G[i][j]=cnt;
                    a[cnt]--;
                }
            }
        }
        else {
            for(int j=w; j>=1; j--) {
                if(a[cnt]==0) {
                    cnt++;
                    G[i][j]=cnt;
                    a[cnt]--;
                }
                else if(a[cnt]>0) {
                    G[i][j]=cnt;
                    a[cnt]--;
                }
            }
        }
    }

    for(int i=1; i<=h; i++) {
        for(int j=1; j<=w; j++)
            printf("%d ",G[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <set>

using namespace std;

char s[3][109];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 3; ++i) {
    scanf("%s", s[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    set<char> t;
    for (int j = 0; j < 3; ++j) {
      t.insert(s[j][i]);
    }
    if ((int)t.size() == 2) {
      ans += 1;
    } else
    if ((int)t.size() == 3) {
      ans += 2;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //AtCoder
//#include <iostream> //Codeforces
//#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}//最大公約数
int lcm(int a,int b){return a/gcd(a,b)*b;}//最小公倍数

/****************************** START ******************************/

signed main(){
  int N;
  cin >> N;
  Vi L(N);
  rep(i,0,N){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  int ans = 0;
  
  rep(i,0,N-2){
    rep(j,i+1,N-1){
      if (L.at(j) != L.at(i)){
        rep(k,j+1,N){
          if (L.at(k) != L.at(j) && L.at(k) < L.at(i) + L.at(j)){
            ans++;
          }
        }
      }
    }
  }
  
  cout << ans;
        
}
    
  


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11 {
    class Program {
        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            while (true) {
                int num_length = int.Parse(Console.ReadLine());
                if (num_length == 0) {
                    return;
                }
                int[] input = new int[num_length];
                for (int i = 0; i < input.Length; i++) {
                    input[i] = int.Parse(Console.ReadLine());
                }

                int sorted = 0;
                int allsorted = 0;
                do {
                    sorted = 0;
                    for (int i = 0; i < input.Length - 1; i++) {
                        int tmp = input[i];
                        if (input[i] > input[i + 1]) {
                            input[i] = input[i + 1];
                            sorted++;
                        } else continue;
                        input[i + 1] = tmp;
                    }
                    allsorted += sorted;
                } while (sorted > 0);
                Console.WriteLine(allsorted);
            }
        }
    }
}

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main(){
	int n;
	cin>>n;
	vector<int>dp(n+1, 0);
	dp[0]=1;
	for(int i=3; i<=n; i++){
		size_t m=0;
		for(int j=3; j<=i; j++){
			if(dp[i-j]!=0)
				(m+=dp[i-j])%=mod;
		}
		dp[i]=m;
	}
	cout<<dp[n]<<'\n';	
	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

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

        int sum = 0;
        for (int n = 1; n <= num; n ++) {
            sum += n;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <math.h>
using namespace std;


void doIt(){
	int a,b,c,n,i;
	cin >> a >> b >> c;
	while(a + b + c > 0){
		cin >> n;
		int r[n];
		//cout << sqrt(a*a + b*b) / 2 << ", " << sqrt(b*b + c*c) / 2 << "," << sqrt(a*a + c*c) / 2;
		for(i = 0; i < n; i++){
			std::cin >> r[i];
			//斜辺を計算する
			bool bOK = false;
			if(sqrt(a*a + b*b) / 2 < r[i] || sqrt(b*b + c*c) / 2 < r[i] || sqrt(c*c + a*a) / 2 < r[i]){
				bOK = true;
			}
			if(bOK){
				cout << "OK" << endl;
			}
			else{
				cout << "NA" << endl;
			}
		}
		cin >> a >> b >> c;
	}
}

int main(){
doIt();
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long intl;
intl dp[3010][3010];
intl MOD= 998244353;
int main(){
	intl a,b,c,d;
	cin>>a>>b>>c>>d;
	intl n=c-a;
	intl m=d-b;
	for(intl i=0;i<=n;i++){
		for(intl j=0;j<=m;j++){
			if(i==0&& j==0){
				dp[i][j]=1;
			}
			else if(i==0){
				dp[i][j]=dp[i][j-1]*(i+a)%MOD;	
			}
			else if(j==0){
				dp[i][j]=dp[i-1][j]*(j+b)%MOD;
			}
			else{
				dp[i][j]=(dp[i-1][j]*(j+b)+dp[i][j-1]*(i+a)-(dp[i-1][j-1]*(j+b-1)*(i+a-1))%MOD+MOD)%MOD;
			}
			
		}
	}
	
	
	cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 74168