akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n;
signed main() {
    while(cin >> n, n) {
        vector<int> v[35];
        set<int> s[50];
        rep(i,0,n) s[i].insert(i);
        rep(i,0,n) {
            int m; cin >> m;
            rep(j,0,m) {
                int inp; cin >> inp;
                v[inp].push_back(i);
            }
        }

        int ans = INF;
        rep(i,0,35) {
            int sz = v[i].size();
            rep(x,0,sz) rep(y,x+1,sz) {
                set<int> temp = s[v[i][x]];
                s[v[i][x]].insert(s[v[i][y]].begin(), s[v[i][y]].end());
                s[v[i][y]].insert(temp.begin(), temp.end());
                if(s[v[i][x]].size() == n) ans = min(ans, i);
            }
        }

        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int main(void) {
	long long x, y, z, ans;
	long long n, m;
	long long a[50];
	scanf("%lld %lld", &n, &m);
	a[0] = 1;
	ans = 0;
	for (int i = 0; i < 49; i++)a[i + 1] = a[i] * 2;
	for (int i = 1; i < 48; i++) {
		x = n % a[i + 1];
		y = m % a[i + 1];
		x -= a[i];
		y -= (a[i] - 1);
		if (x < 0)x = 0;
		if (y < 0)y = 0;
		if ((x + y) % 2 == 1)ans += a[i];
	}
	x = n % 4;
	y = m % 4;
	x = (x + 3) % 4;
	x = (x + 1) / 2;
	y = (y + 5) / 2;
	if ((y - x) % 2 == 1)ans++;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 128
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def judge(n,m):
    if (0 <= n < H) and (0 <= m < W) and s[n][m]=="#":
        return True

def cnt(a,b):
    l = [-1,0,1]
    num = 0
    for i in l:
        for j in l:
            if i == j == 0:
                continue
            else:
                if judge(a+i,b+j):
                    num += 1
    return num

H,W = IL()
s = [[i for i in S()] for i in range(H)]
ans = [["#" for i in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            ans[i][j] = cnt(i,j)

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

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

int main()
{
    map<string, int> m;

    int n;
    cin >> n;

    while (n--)
    {
        int x;
        int y;
        string z;

        cin >> x;
        if (x == 0)
        {
            cin >> z >> y;
            //m.insert(make_pair(z, y));
            m[z] = y;
        }
        if (x == 1)
        {
            cin >> z;
            cout << m[z] << endl;
        }
    }
    return 0;
}


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

int main() {

	int s; cin >> s;

	const int p = 147483647;
	vector<int> num(p, 0);

	int ans;
	int a_prev;
	int a_now = s;
	int i = 1;
	while (true) {

		if (i == 1) {
			a_now = s;
		}
		else {
			a_prev = a_now;
			if (a_prev % 2 == 0) {
				a_now = a_prev / 2;
			}
			else {
				a_now = a_prev * 3 + 1;
			}
		}

		if (num[a_now] == 1) break;
		else num[a_now]++;
		
		i++;
	}

	cout << i << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, mx = 0;
  ll sol = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mx = max(mx, x);
    sol += mx - x;
  }
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 3648
def inpl(): return [int(i) for i in input().split()]
import numpy as np
N = int(input())
p = inpl()

a = np.array(range(1,N+1))
b = np.array(range(1,N+1))
c = np.zeros((N,1), dtype = int)
d = np.zeros((N,1), dtype = int)
for i in range(N):
    c[p[i]-1] += i+1
    d[N-p[i]] += i+1
print(*(a+np.cumsum(c)))
print(*(b+np.cumsum(d))[::-1])

Measured memory_bytes: 15604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
using Graph = vector<vector<int>>;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;

#define For(N,i) for(int i = 0; i < N; i++)
	
int main(){
	int N;
	double ret = 0;
	cin>> N;
	
	
		//ret = 0.5;
		int a = N / 2;
		
		ret += 1 - (double)a / N;
	
	cout<<ret<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long dp[55][5000];
const int GETA = 2500;
int main() {
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    for (int i = 0; i < N; ++i) cin >> x[i], x[i] -= A;

    memset(dp, 0, sizeof(dp));
    dp[0][GETA] = 1;
    for (int i = 0; i < N; ++i) {
        for (int s = 0; s+x[i] < 5000; ++s) {
            if (dp[i][s] == 0) continue;
            dp[i+1][s] += dp[i][s];
            dp[i+1][s+x[i]] += dp[i][s];
        }
    }
    // 「何も選ばない」を除く
    cout << dp[N][GETA] - 1 << endl;
}

Measured memory_bytes: 2432
from collections import defaultdict

S = list(input())
N = len(S)

dic = defaultdict(int)
dic[0] = 1

ans = 0

tmp = 0
for i in range(N):
    s = S[N - 1 - i]
    tmp += int(s) * pow(10, i, 2019)
    ans += dic[tmp % 2019]
    dic[tmp % 2019] += 1

print (ans)

# print (dic)

Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[100000];

int main()
{
	int n;
	int cnt[3];
	ll ans=0;
	fill(cnt,cnt+3,0);
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0)
		{
			cnt[2]++;
			ans+=2;
		}else if(a[i]%2==0){
			cnt[1]++;
			ans++;
		}else{
			cnt[0]++;
		}
	}

	ll s = n - n%2;
	if(ans<s)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

N = int(input())

edges = [[] for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().rstrip().split(' '))
    u = u - 1
    v = v - 1
    
    edges[u].append([v, w])
    edges[v].append([u, w])
    
from collections import deque

temp = deque([[0, 0]])

color = [-1] * N
while len(temp) > 0:
    a, b = temp.popleft()
    color[a] = b
    
    
    for edge in edges[a]:
        if edge[1] % 2 == 1 and color[edge[0]] == -1:
            temp.append([edge[0], 1 - b])
        elif color[edge[0]] == -1:
            temp.append([edge[0], b])

for c in color:
    print(c)




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

int main(){
	int n, x;
	vector<int> a, b;
	vector<double> c;
	double dis1 = 0, dis2 = 0, dis3 = 0;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		a.push_back(x);
	}
	for(int i=0;i<n;i++){
		cin>>x;
		b.push_back(x);
		c.push_back(abs(a[i]-b[i]));
	}

	for(int i=0;i<n;i++){
		dis1 += c[i];
		dis2 += pow(c[i], 2);
		dis3 += pow(c[i], 3);
	}
	sort(c.begin(), c.end());

	printf("%.8lf\n%.8lf\n%.8lf\n%.8lf\n", dis1, sqrt(dis2), pow(dis3, 1/(double)3), c[n-1]);
	return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n), s(n + 1);
    ll sum = 0;
    REP(i, n) {
        cin >> a[i];
        sum += a[i];
        s[i + 1] = s[i] + a[i];
    }
    ll tmp = 0, id = 1;
    REP(i, n) {
        tmp += a[i];
        if (tmp > sum - tmp) {
            id = i;
            break;
        }
    }
    ll res = min(abs(2 * s[id + 1] - sum), abs(2 * s[id] - sum));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3456
import java.util.*;

public class Main{

	public static void main(String[] args) throws java.io.IOException{

		Scanner in = new Scanner(System.in);
		int[] x;
		x = new int[5];
		for(int i = 0; i < 5; i++){
			x[i] = in.nextInt();
		}
		if( x[4] <= x[2] && x[2] <= x[0] - x[4] && x[4] <= x[3] && x[3] <= x

[1] - x[4]){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17356
#include "bits/stdc++.h"
using namespace std;

//

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

string s;
int k;

vector<string> v;

int main(){
  cin>>s>>k;

  char headchar='A',dum;
  
  while(true){
    // determine head char
    dum=headchar;
    headchar = 'z'+1;
    REP(i,s.size()){
      if(s[i]>dum && headchar>s[i]){
	headchar=s[i];
      }
    }

    REP(i,s.size()){
      if(s[i]!=headchar) continue;
      FOR(j,1,min((int)(s.size()-i+1),6)){
	v.push_back(s.substr(i,j));
      }
    }

    sort(v.begin(),v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    if(v.size()>=k) break;
  }
  cout<<v[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>

int Prime(int);

int main(){
  int n, x, i;
  int cnt=0;
  scanf("%d", &n);
  for(i=0; i<n; i++)
  {
    scanf("%d", &x);
    if(Prime(x))cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}

int Prime(int x){
  int i;
  if(x < 2)return 0;
  else if(x == 2)return 1;
  if(x%2 == 0)return 0;
for(i=3; i*i<=x; i+=2){
    if(x%i==0)return 0;
  }
  return 1;
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

template<class T> vector<T> CumulativeSumVector(const vector<T>& xs) {
  int n = xs.size();
  vector<T> c_sums(n + 1);
  for (int i = 0; i < n; i++) {
    c_sums[i + 1] = c_sums[i] + xs[i];
  }
  return c_sums;
}

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

  int n;
  cin >> n;

  vector<int64> xs;
  vector<char> ops;
  ops.push_back('+');
  for (int i = 0; i < 2 * n - 1; i++) {
    if (i % 2 == 0) {
      int64 x;
      cin >> x;
      xs.push_back(x);
    } else {
      char op;
      cin >> op;
      ops.push_back(op);
    }
  }

  vector<int64> c_sums = CumulativeSumVector(xs);

  int64 ans = INT64_MIN;
  int64 current = 0;
  for (int i = 0; i < n; i++) {
    if (ops[i] == '-') {
      int p = n;
      for (int j = i + 1; j < n; j++) {
        if (ops[j] == '-') {
          p = j;
          break;
        }
      }
      int64 s = current - (c_sums[p] - c_sums[i]) + (c_sums[n] - c_sums[p]);
      UpdateMax(ans, s);
    }

    if (ops[i] == '+') current += xs[i];
    else if (ops[i] == '-') current -= xs[i];
  }
  UpdateMax(ans, current);

  cout << ans << endl;
}

Measured memory_bytes: 2036
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val r = scanner.nextInt()
    val d = scanner.nextInt()
    val x2t = scanner.nextInt()
    var xi = x2t
    (1..10).forEach {
        xi = r * xi - d
        println(xi)
    }
}


Measured memory_bytes: 29588
# https://atcoder.jp/contests/abc148/tasks/abc148_f


import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def dist_on_tree(tree, s, N):
    '''tree...(to,cost)の隣接リスト形式
    s...始点ノード
    N...ノード数'''
    from collections import deque
    D = [-1] * N
    D[s] = 0
    que = deque([(s, 0)])  # 現在のノード、そこまでの距離
    while que:
        now, dist = que.popleft()
        for to, cost in tree[now]:
            if D[to] != -1:
                continue
            D[to] = dist + cost
            que.append((to, dist + cost))
    return D


INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations

N, u, v = read_ints()
tree = defaultdict(lambda: [])
for _ in range(N - 1):
    a, b = read_ints()
    a -= 1
    b -= 1
    tree[a].append((b, 1))
    tree[b].append((a, 1))


# u...逃げる v...追いかける
# u,vからxへの距離をud[x],vd[x]とすると、ud[x]<vd[x]を満たすxが答えの候補となる(∵ud[x]>=vd[x]は追いかける方の陣地、その中に突っ込むのは必ず不利 =は距離が同じ、ということはその前に衝突している
# ud[x]<=vd[x]のなかで最も大きなvd[x]-1が答え(uが壁から跳ね返ってvが動かずとも衝突する)

ud = dist_on_tree(tree, u - 1, N)
vd = dist_on_tree(tree, v - 1, N)
dist = ud[v - 1]
# print(ud)
# print(vd)

ans = 0
for x in range(N):
    # if ud[x] + vd[x] == dist and ud[x] == vd[x]:
    #     ans = max(ans, vd[x] - 1 if (vd[x] - ud[x]) & 1 else vd[x])
        # ans
    if ud[x] >= vd[x]:
        continue
    ans = max(ans, vd[x] - 1)

print(ans)


Measured memory_bytes: 73692
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize
    }
    if n == 22 {
        println!("Christmas Eve Eve Eve");
    } else if n == 23 {
        println!("Christmas Eve Eve");
    } else if n == 24 {
        println!("Christmas Eve");
    } else if n == 25 {
        println!("Christmas");
    }
}


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

void swap(int *xp, int *yp){
	int temp=*xp;
	*xp=*yp;
	*yp=temp;
}

void bubblesort(int a[], int n){
	int i,j;
	for(i=0;i<n-1;i++){
		for(j=0;j<n-i-1;j++){
			if(a[j]>a[j+1]){
				swap(&a[j],&a[j+1]);
			}
		}
	}
}

int main(){
	int n,k,sum=0;
	cin>>n>>k;
	int a[n]={0};
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
//	sort(a.at(0),a.at(n-1));
bubblesort(a, n);
/*
	for (int i=0;i<n;i++){
		cout<<a[i]<<" ";
	}*/
	for(int i=0;i<k;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
    return 0;
}

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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 100001;
int a[N];
int main() {
	ios_base::sync_with_stdio(0);

	int a,b,c;
	cin >> a >> b >> c;
	if (a <= c && c <= b)
		cout << "Yes\n";
	else
		cout << "No\n";
  	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int a, b;
  cin >> a >> b;
  if(a >= 13) cout << b << endl;
  else if(a <= 5) cout << 0 << endl;
  else cout << b/2 << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
using namespace std;
typedef long long ll;
ll n=50;
int main()
{
    ll k;
    ll i=0;
    scanf("%lld",&k);
    printf("50\n");
    while(n--)
    {
        printf("%lld",49-i+((49-i+k)/50));
        i++;
        if(n)
            printf(" ");
        else
            printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

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

        final int k = sc.nextInt();
        final int n = sc.nextInt();

        final int[] d = new int[n];
        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        for (int i = 0; i < n-1; i++) {
            d[i] = a[i+1] - a[i];
        }

        d[n-1] = k + a[0] - a[n-1];

        System.out.println(IntStream.of(d).sum() - IntStream.of(d).max().getAsInt());
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  int ans = 0;
  rep(i,n)rep(j,n)rep(k,n) {
    if (i < j && j < k) {
      if (l[i] == l[j]) continue;
      if (l[i] == l[k]) continue;
      if (l[k] == l[j]) continue;
      if ((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int n, m;
int gr[10][10] = {};
int use[10] = {};
ll ans = 0;

int dfs(int depth, int p)
{
    if (depth == n)
    {
        ans++;
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            if (use[i] == 0 && gr[p][i] == 1)
            {
                use[i] = 1;
                dfs(depth + 1, i);
                use[i] = 0;
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        gr[a][b] = gr[b][a] = 1;
    }
    use[1] = 1;
    dfs(1, 1);
    cout << ans << endl;
}


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

Measured memory_bytes: 3064
S = list(input())
if S[0] != "A":
  print("WA")
  exit()
count = 0
for i in range(2,len(S)-1):
  if S[i] == "C":
    count += 1
if count != 1:
  print("WA")
  exit()
S2 = [str.upper() for str in S]
count = 0
for i in range(len(S)):
  if S[i] == S2[i]:
    count += 1
if count != 2:
  print("WA")
else:
  print("AC")
           

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<tuple>
#include<cassert>
#define int long long
using namespace std;
int test[213456], aa[213456];
signed main() {
	int n, m, sum = 0; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	for (int h = 1; h < n; h++) {
		aa[h] = test[h] - test[h - 1] - 1;
	}
	sort(aa + 1, aa + n);
	for (int h = 1; h <= n - m; h++) {
		sum += aa[h];
	}
	cout << n + sum << endl;
}


Measured memory_bytes: 4684
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = Math.abs(a+b);
        System.out.println(ans % 2 == 0? ans/2: "IMPOSSIBLE");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, m, q;
  cin >> n >> m >> q;

  int ans = 0;
  int a[q], b[q], c[q], d[q];
  for(int i = 1; i <= q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  for(int i1 = 1; i1 <= m; i1++ ){
    for(int i2 = i1; i2 <= m; i2++ ){
      for(int i3 = i2; i3 <= m; i3++ ){
        for(int i4 = i3; i4 <= m; i4++ ){
          for(int i5 = i4; i5 <= m; i5++ ){
            for(int i6 = i5; i6 <= m; i6++ ){
              for(int i7 = i6; i7 <= m; i7++ ){
                for(int i8 = i7; i8 <= m; i8++ ){
                  for(int i9 = i8; i9 <= m; i9++ ){
                    for(int i10 = i9; i10 <= m; i10++ ){
                      vector<int> A(11);
                      A = {0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10};

                      int temp = 0;
                      for(int i = 1; i <= q; i++){
                        if(A[b[i]] - A[a[i]] == c[i]){
                        temp += d[i];
                      }

                      ans = max(ans, temp);  
                      }

                    } 
                  } 
                } 
              } 
            } 
          } 
        } 
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

ll comb(ll N_, ll C_) {
	const int NUM_=500001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mod, factr[i]=factr[i-1]*inv[i]%mod;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mod*factr[N_-C_]%mod;
}

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    if (n-1<=k){
        cout<<comb(2*n-1,n)<<endl;
        return 0;
    }
    ll ans = 1;
    rep(i,1,k+1){
        ans = (ans+comb(n,i)*comb(n-1,i)%mod)%mod;
    }
    cout<<ans<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> arr = vector<int>(n);
    vector<int> front_west = vector<int>(n);
    vector<int> front_east = vector<int>(n);
    vector<int> rear_west = vector<int>(n);
    vector<int> rear_east = vector<int>(n);

    for(int i = 0; i < n; i++){
        char c;
        cin >> c;
        if(c == 'W') arr[i] = 1;
        else arr[i] = 2;
    }

    for(int i = 1; i < n; i++){
        if(arr[i - 1] == 1){
            front_west[i] = front_west[i - 1] + 1;
            front_east[i] = front_east[i - 1];
        } else {
            front_west[i] = front_west[i - 1];
            front_east[i] = front_east[i - 1] + 1;
        }
    }

    for(int i = n - 2; i >= 0; i--){
        if(arr[i + 1] == 1) {
            rear_west[i] = rear_west[i + 1] + 1;
            rear_east[i] = rear_east[i + 1];
        } else {
            rear_west[i] = rear_west[i + 1];
            rear_east[i] = rear_east[i + 1] + 1;
        }
    }

    int min = n + 1;
    for(int i = 0; i < n; i++){
        int cur = rear_east[i] + front_west[i];
        if(min > cur) min = cur;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 6144
#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 a, b, k;
  cin >> a >> b >> k;
  vector<ll> cand;
  FOR(i, 1, min(a, b) + 1) {
    if (a % i == 0 && b % i == 0) {
      cand.push_back(i);
    }
  }
  sort(ALL(cand));
  reverse(ALL(cand));
  cout << cand[k - 1] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  char s[SIZE];

  scanf("%s", s);

  int n = strlen(s);


  ll ans = 0;
  int counter = 0;

  for(int i=0;i<n;i++){
    if(s[i] == 'A') {
      counter++;
    } else if(s[i] == 'B' && s[i+1] == 'C') {
      ans += counter;
      i += 1;
    } else {
      counter = 0;
    }


  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    long X;
    static long MX = 100000000000007L;
    List<Long> ps, ns;

    void solve(){
        ps = new ArrayList<>(); ns = new ArrayList<>();
        ps.add(0L); ns.add(0L);
        for(long a=1; pow(a, 5) < MX; a++){
            ps.add((long)pow(a, 5));
        }
        for(long a=-1; pow(a, 5)*-1 < MX; a--){
            ns.add((long)pow(a, 5));
        }
        for(int i=0; i<ps.size(); i++){
            for(int j=i; j<ps.size(); j++){
                long ai = ps.get(i), aj = ps.get(j);
                if(aj - ai == X){
                    System.out.println(j + " " + i);
                    return;
                }
            }
        }

        for(int i=0; i<ps.size(); i++){
            for(int j=0; j<ns.size(); j++){
                long ai = ps.get(i), aj = ns.get(j);
                if(ai - aj == X){
                    System.out.println(i + " " + j*-1);
                    return;
                }
            }
        }
    }

    public Main() throws Exception {
        //System.setIn(new FileInputStream("d.in"));
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        X = sc.nextLong();
        solve();
    }

    static public void main(String[] args) throws Exception {
        Main m = new Main();
    }
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e3 + 5;

string s[ N ];

int add(int x, int y, int mod) {
  return x + y >= mod ? x + y - mod : x + y;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int r, c;
  cin >> r >> c;
  for (int i = 0; i < r; i++) cin >> s[i];
  vector <vector <int> > ways (N, vector <int> (N, 0));
  bool f = false;
  for (int i = 0; i < c; i++) {
    if (s[0][i] == '#') f = true;
    if (!f) ways[0][i] = 1;
  }
  f = false;
  for (int i = 0; i < r; i++) {
    if (s[i][0] == '#') f = true;
    if (!f) ways[i][0] = 1;
  }
  for (int i = 1; i < r; i++) {
    for (int j = 1; j < c; j++) {
      if (s[i][j] == '#') ways[i][j] = 0;
      else ways[i][j] = add(ways[i - 1][j], ways[i][j - 1], mod);
    }
  }
  cout << ways[r - 1][c - 1] << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int b[13];
int main(){
	int N;
	cin >> N;
	vi a(N);
	for(int i=0;i<N;i++){
		cin >> a[i];
		b[a[i]/400]++;
	}
	int ans = 0;
	for(int i=0;i<8;i++){
		if(b[i]>0)ans++;
	}
	int k = 0;
	for(int i=8;i<13;i++){
		k += b[i];
	}
	cout << max(1,ans) << ' ' << ans+k << endl;	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n,x;

  cin >> n >> x;

  while(n!=0 || x!=0){
    int ans=0;

    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        for(int k=j+1;k<=n;k++){
          if(i==k || k==j || i==j) continue;
          //cout << i << " " << j << " " << k << endl;
          if(i+j+k==x) ans++;
        }
      }
    }
    cout << ans << endl;
    cin >> n >> x;
  }
  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, x, y, now = 1;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n)cin >> p.at(i);
    rep(i, n)cin >> q.at(i);
    int a, b, array[n];
    REP(i, n)array[i-1] = i;
    do{
        bool c=true, d=true;
        rep(i, n){
            if(array[i] != p[i])c = false;
            if(array[i] != q[i])d = false;
        }
        if(c)x = now;
        if(d)y = now;
        now++;
    }while(next_permutation(array, array+n));
    cout << abs(x-y);
}

Measured memory_bytes: 256
/*\
 * ...
 * ......
 * In the name of ALLAH
 * ......
 * ...
 */

#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10 , MN =2e5 + 10;

int arr[MN];

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	deque<int>deq;
	int n;cin>>n;
	for(int i=0;i<n;++i) cin >> arr[i];
	for(int i=0;i<n;++i)
		if(i&1) deq.push_front(arr[i]);
		else deq.push_back(arr[i]);
	if(n&1){
		for(int i=Size(deq)-1;~i;--i) cout << deq[i] << ' ';
	}else
		for(auto x:deq) cout << x << ' ';
	cout << '\n';
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  int a = 0;
  int z = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'A'){
      a = i;
      break;
    }
  }
  for(int j = s.size() - 1;j >= 0;j--){
    if(s[j] == 'Z'){
      z = j;
      break;
    }
  }
  //cout << z << a << endl;
  cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		//		int n = ni();
		//
		//		int hen = (int) Math.sqrt(n);
		//
		//		int min = 100000;
		//
		//		for (int i = 0; i <= 100000; i++) {
		//			int tate = hen - i;
		//			if (n % tate == 0) {
		//				int yoko = n / tate;
		//				int sa = Math.abs(tate - yoko);
		//				int nouse = n - tate - yoko;
		//
		//				if (min >= sa + nouse) {
		//					min = sa + nouse;
		//				}
		//			}
		//
		//			if (tate == 1) {
		//				break;
		//			}
		//
		//		}

		int a = ni();
		int b = ni();

		out(a <= b ? a : a - 1);

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35576
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

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

typedef long long int64;
typedef pair<int64, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  vector<ii> a(4);
  for (int i = 0; i < 4; ++i) {
    scanf("%lld", &a[i].first);
    a[i].second = i;
  }
  int64 n;
  scanf("%lld", &n);
  sort(a.begin(), a.end(), [](ii u, ii v) {
      int64 x = u.first << (3 - u.second);
      int64 y = v.first << (3 - v.second);
      return x < y;
    });
  // for (int i = 0; i < 4; ++i) {
  //   cout << a[i].first << " " << a[i].second << endl;
  // }
  int64 ret = 0;
  for (int i = 0; i < 4; ++i) {
    if (n == 0) break;
    if (a[i].second == 3) {
      ret += n / 2 * a[i].first;
      n %= 2;
    } else {
      ret += n * (a[i].first << (2 - a[i].second));
      break;
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll read() {
	ll x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
ll now, ans, n;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		ll a=read();
		ans=(ans+now*a)%mod;
		now+=a;
		now%=mod;
	}
	cout<<ans;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

void decision(ll a, ll b) {
    a =min(a, b);
}

int main() {
    ll n, a;
    cin >> n;
   ll c = 0;
   while(n--) {
       cin >> a;
    while(a % 2 != 1) {
        a = a/2;
        c++;
    }
   }
    cout << c << endl;
}



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

int main(){
    long long n,ans=0;
    cin >> n;
    long long v[3*n];
    for(long long i = 0 ; i < 3*n ; i += 1){
        cin >> v[i];
    }
    sort(v,v+3*n);
    for(long long i = 3*n-2 ; i >= n ; i -= 2){
        ans += v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#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 loc[n][2];
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    loc[i][0]=x;
    loc[i][1]=y;  
  }
  long double dist[n][n];
  rep(i,n){
    rep(j,i){
      int tmpx=loc[i][0]-loc[j][0];
      int tmpy=loc[i][1]-loc[j][1];
      long double dis=sqrt(tmpx*tmpx+tmpy*tmpy);
      dist[i][j]=dis;
      dist[j][i]=dis;
    }
  }
  int a[n];
  rep(i,n){
    a[i]=i;
  }
  long double ans=0;
  do{
    long double cnt=0;
    rep(i,n-1){
      cnt+=dist[a[i]][a[i+1]];
    }
    rep(i,n){
      cnt/=(i+1);
    }
    ans+=cnt;  
  }while(next_permutation(a,a+n));
  cout << fixed << setprecision(8);
  cout << ans << endl;
}

Measured memory_bytes: 256
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = new HashMap[Int,Array[Int]]
    val log = ListBuffer.empty[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map.remove(l(1)).get
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


Measured memory_bytes: 57064
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n, k;
	cin >> n >> k;
	if (!cin) return false;

	string s;
	cin >> s;

	int cont = 1;
	int hap = 0;
	int us = 0;

	while (cont < n && s[cont] == s[cont - 1]) {
		++cont;
		++hap;
	}

	while (cont < n && us < k) {
		++cont;
		++hap;
		while (cont < n && s[cont - 1] == s[cont]) {
			++cont;
			++hap;
		}
		++us;
		while (cont < n && s[0] == s[cont]) {
			++cont;
			++hap;
		}
	}

	while (cont < n) {
		++cont;
		if (s[cont - 1] == s[cont]) ++hap;
	}

	cout << hap << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

int W, H, K;

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

int64_t solve() {
    // A = I + B / 2 - 1, where I <= K
    // A - B / 2 + 1 = I <= K
    // 2 * A - B <= 2 * (K - 1)
    //
    // A = H * W - W * (H - (y1 + y2) / 2) - x * y1 / 2 - (W - x) * y2 / 2
    //   = W * (y1 + y2) / 2 - x * y1 / 2 - (W - x) * y2 / 2
    //   = [(W - x) * y1 + x * y2] / 2
    // B = gcd(y1 - y2, W) + gcd(y1, x) + gcd(y2, W - x)
    int64_t total = 0;
    int lim = 2 * (K - 1) + 3 * W;
    for (int x = 1; x < W; x++) {
        for (int y2 = 1; y2 < H; y2++) {
            if (x * y2 > lim)
                break;
            // (W - x) * y1 + x * y2 <= 2 * (K - 1) + 3 <= 2 * (K - 1) + B
            int y1 = (2 * (K - 1) - x * y2 + 3) / (W - x);
            if (y1 >= y2) {
                total += 2 * y2 - 1;
                continue;
            }
            if (y1 < 1)
                y1 = 1;
            total += 2 * (y1 - 1);
            for (; y1 <= y2; y1++) {
                int A2 = (W - x) * y1 + x * y2;
                if (A2 > lim)
                    break;
                int B = gcd(y1, x) + gcd(y2, W - x) + gcd(abs(y1 - y2), W);
                if (A2 - B <= 2 * (K - 1)) {
                    total++;
                    if (y1 != y2)
                        total++;
                }
            }
        }
    }
    return total;
}

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

    cin >> W >> H >> K;

    int64_t total = solve();
    swap(W, H);
    total += solve();
    total *= 2;
    cout << total << endl;
}


Measured memory_bytes: 3196
use std::io::{BufRead, Write};
use std::cmp;

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let (n, k): (usize, usize) = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut a: Vec<i32> = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    for _ in 0..k {
        let mut b: Vec<i32> = vec![0; n as usize];
        let m = n as i32;
        for i in 0..n {
            let x = i as i32;
            let left = cmp::max(0, x - a[i]) as usize;
            let right = cmp::min(m - 1, x + a[i]) as usize;
            b[left] += 1;
            if right + 1 < n as usize {
                b[right + 1] -= 1;
            }
        }

        let mut flag = b[0] == m as i32;
        for i in 1..n {
            b[i] += b[i - 1];
            if b[i] < m {
                flag = false;
            }
        }

        a = b;
        if flag { break; }
    }

    let a = a.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" ");
    writeln!(writer, "{}", a).unwrap();
}

Measured memory_bytes: 15064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,T=INTM()
    ct=1001
    for i in range(n):
        c,t=INTM()
        if T>=t:
            ct=min(ct,c)
    if ct==1001:
        print('TLE')
    else:
        print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064