akhauriyash/Code-Regression huggingface dataset:
N, M, Q = map(int, input().split())
zz = [list(map(int, input().split())) for _ in range(Q)]

def f(s):
    if len(s) == N:
        return [s]
    result = []
    if s == '':
        r = 0
    else:
        r = int(s[-1])
    for i in range(r, M):
        result.extend(f(s + str(i)))
    return result

ans = 0
V = f('')
for s in V:
    A = [int(c) + 1 for c in s]
    t = 0
    for a, b, c, d in zz:
        if A[b - 1] - A[a - 1] == c:
            t += d
    ans = max(ans, t)
print(ans)

Measured memory_bytes: 15860
#include<iostream>
using namespace std;
main(){
  int a,b,c,d,e,f;
  char op;
  
 
  while(1){
    cin >> a >> op >> b ;
    c=a+b;
    d=a-b;
    e=a*b;

    
    if(op == '+'){
      cout<< c <<"\n";
    }else if(op == '-'){
      cout<< d <<"\n";
    }else if(op == '*'){
      cout<< e <<"\n";
    }else if(op == '/'){
      f=a/b;
      cout << f <<"\n";
    }else if(op == '?')break;
    
  }
  return 0;
}
  

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

int Solve(const vector<int>& a) {
  vector<int> b(a);
  sort(b.begin(), b.end());

  int odd = 0;
  for (int i = 0; i < a.size(); ++i) {
    int j = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    if ((i - j) % 2)
      ++odd;
  }
  return odd / 2;
}

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


Measured memory_bytes: 1024
import networkx as nx
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(m)]

g=nx.Graph()
g.add_edges_from(s)
di=nx.predecessor(g,source=1)

print("Yes")
for x in range(2,n+1):
    print(di[x][0])

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	int n,k;
	cin>>n>>k;
	if(k==1)
	{
		cout << "0\n";
		return 0;
	}
	n = n - k;
	cout << n << "\n";
	return 0;
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int point = sc.nextInt();
		int anser_C = sc.nextInt();

		int[] part = new int[N];
		//参加者に初期ポイントを付与
			Arrays.fill(part, point-anser_C);
		//anser_C回ループ
		for(int i = 1; i <= anser_C; i++ ) {
			//勝者の番号に+1加算する
			part[sc.nextInt()-1]++;
		}
		for(int i = 0; i<N; i++) {
			if(part[i] <= 0) {
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
		}
	}
}

Measured memory_bytes: 63272
#include <stdio.h>
#include <stdlib.h>

int main(){
        char c;
        scanf("%c",&c);
        if(c == 'A'){
                printf("T\n");
        }else if(c == 'C'){
                printf("G\n");
        }else if(c == 'G'){
                printf("C\n");
        }else if(c == 'T'){
                printf("A\n");
        }
        return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
 	long long n,b,r,ans=0;
  	cin>>n>>b>>r;
  	ans+=(n/(b+r))*b;
  	n%=(b+r);
  	if(n>b) ans+=b;
  	else ans+=n;
  	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}

ll lcm(ll n, ll m) {
	return m / gcd(n, m) * n;
}

int main(void) {
	int n, c, count=0, p;
	cin >> n >> c;
	for (int i = 0; i < c; i++) {
		cin >> p;
		count += p;
	}
	cout << count/(n+1)+(count%(n+1)==0 ? 0 :1) << endl;
	return 0;
}


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

namespace ConsoleApplication1
{
    struct State
    {
        internal int x, y, cnt;

        public State(int x, int y, int cnt)
        {
            this.x = x;
            this.y = y;
            this.cnt = cnt;
        }
    }

    class Problem
    {
        readonly int[] moveX = new int[] { -1, 0, 1, 0 };
        readonly int[] moveY = new int[] { 0, -1, 0, 1 };
        readonly int INF = 1 << 20;
        readonly int w, h;

        int[,] map, memo;
        int sx, sy;

        public Problem(int w, int h)
        {
            this.w = w;
            this.h = h;
            map = new int[h, w];
            memo = new int[h, w];
            MakeMap();
        }

        public int Solve()
        {
            int ret = INF;

            Stack<State> stk = new Stack<State>();
            stk.Push(new State(sx, sy, 0));

            while (stk.Count > 0)
            {
                State cur = stk.Pop();
                memo[cur.y, cur.x] = cur.cnt;

                for (int i = 0; i < 4; i++)
                {
                    int nx = cur.x + moveX[i];
                    int ny = cur.y + moveY[i];

                    if (IsValid(nx, ny))
                    {
                        int tempCnt = cur.cnt + (map[cur.y, cur.x] == 1 ? 0 : map[ny, nx]);

                        if (tempCnt < memo[ny, nx] && tempCnt < ret)
                        {
                            stk.Push(new State(nx, ny, tempCnt));
                        }
                    }
                    else ret = Math.Min(ret, cur.cnt);
                }
            }
            return ret;
        }

        private bool IsValid(int x, int y)
        {
            if (x >= 0 && x < w && y >= 0 && y < h) return true;
            return false;
        }

        private void MakeMap()
        {
            for (int i = 0; i < h; i++)
            {
                string input = Console.ReadLine();

                for (int j = 0; j < w; j++)
                {
                    switch (input[j])
                    {
                        case '#':
                            map[i, j] = 1;
                            break;
                        case '&':
                            sx = j;
                            sy = i;
                            break;
                    }
                    memo[i, j] = INF;
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int w = int.Parse(input[0]);
                int h = int.Parse(input[1]);

                if (w == 0 && h == 0) break;

                Problem pb = new Problem(w, h);
                sb.AppendLine(pb.Solve().ToString());
            }
            Console.Write(sb);
        }
    }
}

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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> a( H );
	for( int i = 0; i < H; i++ ) {
		cin >> a[i];
	}

	vector<int> v( H );
	vector<int> h( W );
	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			if( a[i][j] == '#' ) {
				v[i] = 1;
				h[j] = 1;
			}
		}
	}

	for( int i = 0; i < H; i++ ) {
		if( v[i] == 0 ) continue;
		for( int j = 0; j < W; j++ ) {
			if( h[j] == 0 ) continue;
			cout << a[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <cmath>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> fruit(N);
  for(int i = 0;i < N;i++){
    cin >> fruit.at(i);
  }
  sort(fruit.begin(),fruit.end());
  int kekka = 0;
  for(int i = 0;i < K;i++){
    kekka += fruit.at(i);
  }
  cout << kekka << endl;
}


Measured memory_bytes: 3620
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K = map(int,readline().split())
S = read().rstrip().decode('utf-8')

LS = list(S)
LS[K-1] = LS[K-1].lower()
print(''.join(LS))

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	int i, j;
	int flag = 0;
	cin >> n;
	for (i = 0; i <= n / 7; i++)
	{
		if ((n - 7 * i) % 4 == 0)flag = 1;
	}
	if (flag)printf("Yes\n");
	if (flag == 0)printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define inf 1000000007

int main(void){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    a[n]=0;    
    sort(a, a+n);
    int ans = 0; int count = 1;
    for(int i = 0; i < n; i++){
        if(a[i]==a[i+1])
            count++;
        if(a[i]!=a[i+1]&&count%2!=0){
            ans++; count=1;
        }
        if(a[i]!=a[i+1]&&count%2==0)
            count=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

#define EPS (1e-10)
#define equals (fabs((a)-(b)<EPS)
int n;

struct Point
{
    double x, y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator +(Point a)
    {
        return Point(x+a.x,y+a.y);
    }
    Point operator -(Point a)
    {
        return Point(x-a.x,y-a.y);
    }
    Point operator *(double a)
    {
        return Point(x*a,y*a);
    }

    double norm()
    {
        return x*x+y*y;
    }
};
Point p1,p2,p;
double cross(Point a,Point b)
{
    return a.x*b.y-b.x*a.y;
}
double dot(Point a,Point b)
{
    return a.x*b.x+a.y*b.y;
}
void solve()
{
    Point a=p2-p1;
    Point b=p-p1;
    if(cross(a,b)>EPS) printf("COUNTER_CLOCKWISE\n");
    else if(cross(a,b)<-EPS) printf("CLOCKWISE\n");
    else if(dot(a,b)<-EPS) printf("ONLINE_BACK\n");
    else if(a.norm()<b.norm()) printf("ONLINE_FRONT\n");
    else printf("ON_SEGMENT\n");

}

int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf",&p.x,&p.y);
        solve();
    }
    return 0;
}

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

int main(){

    int N;cin>>N;
    int ans=0;
    int p=log10(N)+1;
    if(p>=3){
        vector<int> sample;
        int count=0;
        for(int i=1;i<p;i++){
            count+=pow(3,i);
        }

        sample.push_back(3);sample.push_back(5);sample.push_back(7);
        for(int i=0;i<count;i++){
            sample.push_back(sample.at(i)*10+3);
            sample.push_back(sample.at(i)*10+5);
            sample.push_back(sample.at(i)*10+7);
        }

        int k,count3,count5,count7;
        count+=pow(3,p);
        for(int i=12;sample.at(i)<=min(777777753,N);i++){
            k=sample.at(i);

            count3=0;count5=0;count7=0;
            p=log10(k)+1;
            for(int j=0;j<p;j++){
                if(k%10==3)count3++;
                else if(k%10==5)count5++;
                else count7++;
                k/=10;
            }
            if(count3!=0 && count5!=0 && count7!=0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    t = 1;
    for(int i=0;i<t;i++)
    {
        sieve();
        cin>>n;
        int arr[n];
        int z;
        unordered_map <int,int> mp,mp2;
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
            mp[arr[i]]++;
        }
        vector <int> v;
        for(auto i = mp.begin();i!=mp.end();i++)
        {
            v.push_back(i->first);
        }
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
        {
            for(int j=2;j<=1000000;j++)
            {
                if(v[i]*j>1000000)
                {
                    break;
                }
                mp2[v[i]*j] = 1;
            }
        }
        int cnt = 0;
        for(int i=0;i<v.size();i++)
        {
            if(mp[v[i]]>=2)
            {
                continue;
            }
            if(!mp2[v[i]])
            {
                cnt++;
            }
        }
        cout<<cnt;
    }
    return 0;
}

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

fn main() {
    let (n, m) = get!(usize, usize);
    let mut v = Vec::with_capacity(n);
    for _ in 0..n {
        let tmp = get!(i64, i64, i64);
        v.push(tmp);
    }
    let mut ans = 0;
    for bit in 0..1 << 3 {
        let mut tv: Vec<i64> = Vec::new();
        for i in v.iter() {
            let mut t = 0;
            if bit & 0b001 == 0b001 {
                t += i.2;
            } else {
                t -= i.2;
            }
            if bit & 0b010 == 0b010 {
                t += i.1;
            } else {
                t -= i.1;
            }
            if bit & 0b100 == 0b100 {
                t += i.0;
            } else {
                t -= i.0;
            }
            tv.push(t);
        }
        tv.sort_by(|x, y| y.cmp(x));
        let sum = tv.iter().take(m).sum();
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define mod 1000000007 
using namespace std;
int n,q,ans;
int x[3005],y[3005];
int a[3005],two[3005];
int dp[3005][3005][2],G[3005][3005][2];
int f[4][3005],g[2];

void up(int A,int B,int C,int D){
	if(G[A][B][C]==D) return;
	dp[A][B][C]=1ll*dp[A][B][C]*two[D-1-G[A][B][C]]%mod;
	G[A][B][C]=D; 
}

void work(int id,int k){
	memset(f,0,sizeof(f));
	for(int t=1;t<=n;t++){
		if(t!=y[k]) up(x[k],t,id,k),f[0][t]=dp[x[k]][t][id];
		if(t!=x[k]) up(y[k],t,id,k),f[1][t]=dp[y[k]][t][id];
		if(t!=y[k]) up(t,x[k],id,k),f[2][t]=dp[t][x[k]][id];
		if(t!=x[k]) up(t,y[k],id,k),f[3][t]=dp[t][y[k]][id];
	}
	up(x[k],y[k],id,k),g[0]=dp[x[k]][y[k]][id];
	up(y[k],x[k],id,k),g[1]=dp[y[k]][x[k]][id];
	for(int t=1;t<=n;t++){
		up(y[k],t,id,k),(dp[y[k]][t][id]+=f[0][t])%=mod;
		up(x[k],t,id,k),(dp[x[k]][t][id]+=f[1][t])%=mod;
		up(t,y[k],id,k),(dp[t][y[k]][id]+=f[2][t])%=mod;
		up(t,x[k],id,k),(dp[t][x[k]][id]+=f[3][t])%=mod;
	}
	up(y[k],x[k],id,k),(dp[y[k]][x[k]][id]+=g[0])%=mod;
	up(x[k],y[k],id,k),(dp[x[k]][y[k]][id]+=g[1])%=mod;
	/*for(int t=1;t<=n;t++){
		for(int T=1;T<=n;T++) if(t!=x[k]&&t!=y[k]&&T!=x[k]&&T!=y[k]) dp[t][T][id]=2*dp[t][T][id]%mod;
	}*/
}

int main(){
	scanf("%d %d",&n,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=q;i++) scanf("%d %d",&x[i],&y[i]);
	two[0]=1;for(int i=1;i<=q+1;i++) two[i]=2*two[i-1]%mod;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(a[i]<a[j]) dp[i][j][0]++;
			else if(a[i]>a[j]) dp[i][j][1]++;
		}
	}
	for(int k=1;k<=q;k++){
		work(0,k);
		work(1,k);
	}
	for(int k=1;k<=n;k++){
		for(int t=1;t<k;t++) up(k,t,0,q+1),(ans+=dp[k][t][0])%=mod;
	}
	for(int k=1;k<=n;k++){
		for(int t=k+1;t<=n;t++) up(k,t,1,q+1),(ans+=dp[k][t][1])%=mod;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a={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 i;
  
  cin >>i;
  
  cout << a.at(i-1) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は√N
 */

//ここから書き始める
int main(){
	int a,b;
	cin >> a >> b;
	int x,y,z;
	x = a + b;
	y = a - b;
	z = a * b;
	int ans = max({x,y,z});
	cout << ans << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int dp[1<<21];
int cnt[21][100010];
int ccnt[21];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll now=0;
    map<ll,ll>m;m[0]++;
    for(ll i=0;i<n;i++){
        now+=a[i];
        m[now]++;
    }
    ll ans=0;
    for(auto i:m){
        if(i.se>1){
            ans+=(i.se-1)*i.se/2;
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------

































Measured memory_bytes: 14336
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using std::cin; using std::cout;
using std::endl;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::stringstream; using std::vector;
using std::pair; using std::make_pair;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<ULL, ULL> puu;
#ifdef DEBUG
using std::cerr;
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)                                                     \
  {                                                                            \
    cerr << #a << " = {";                                                      \
    for (int qwq = (st); qwq <= (n); ++qwq)                                    \
      if (qwq == (st))                                                         \
        cerr << a[qwq];                                                        \
      else                                                                     \
        cerr << ", " << a[qwq];                                                \
    cerr << "}" << endl;                                                       \
  }
#define displayv(a) displaya(a, 0, (int)(a.size() - 1))
#include <ctime>
class MyTimer {
    clock_t st;
public:
    MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
    ~MyTimer() { report(); }
    void reset() { st = clock_t(); }
    void report() {  cerr << "Time consumed: " << (clock() - st) * 1e3 / CLOCKS_PER_SEC << "ms" << endl; }
} myTimer;
#else
#define cerr if(false) std::cout
#define pass ;
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(a) ;
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename A, typename B>
std::ostream& operator << (std::ostream &cout, const pair<A, B> &x) {
    return cout << "(" << x.first << ", " << x.second << ")";
}
template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }

static int c[10];

int main() {
    for(int i = 0; i < 6; ++ i) {
        int x; cin >> x; c[x] ++;
    }
    int ans = 0;
    for(int i = 1; i <= 4; ++ i) ans += (c[i] == 1);
    cout << (ans == 2 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a, b, c, x=0;


	while (scanf("%d %d", &a, &b) != EOF) {



		c = a + b;
		x = 0;

		while (c > 0){
			c = c / 10;
			x++;
		}

		printf("%d\n", x);
	}
	return 0;

}

Measured memory_bytes: 600
#include<cstdio>
#define N 100005
inline void chk(int &x,int y){if(y>x)x=y;}
int n,a[N][3];
int dp[N][3];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)for(int j=0;j<3;++j)scanf("%d",&a[i][j]);
	for(int i=0;i<3;++i)dp[0][i]=a[0][i];
	for(int i=1;i<n;++i)for(int j=0;j<3;++j){
		for(int k=0;k<3;++k)if(k!=j)chk(dp[i][j],dp[i-1][k]+a[i][j]);
	}
	int ans=0;
	for(int i=0;i<3;++i)chk(ans,dp[n-1][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#define INF 100000000
using namespace std;
int min(int a,int b){
  return a<b?a:b;
}
int main(){
  int n,m;
  while(cin>>n>>m){
    if(n==0&&m==0) break;
    int d0[m+1][m+1],d1[m+1][m+1];
    for(int i=1;i<=m;i++){
      for(int j=1;j<=m;j++){
	d0[i][j] = INF;
	d1[i][j] = INF;
      }
    }
    int a,b,cost,time;
    for(int i=0;i<n;i++){
      cin >> a >> b >> cost >> time;
      d0[a][b] = cost;
      d0[b][a] = cost;
      d1[a][b] = time;
      d1[b][a] = time;
    }
    for(int i=1;i<=m;i++){
      for(int j=1;j<=m;j++){
	for(int k=1;k<=m;k++){
	  d0[j][k] = min(d0[j][k],d0[j][i]+d0[i][k]);
	  d1[j][k] = min(d1[j][k],d1[j][i]+d1[i][k]);
	}
      }
    }
    int s,p,q,r; 
    cin >> s;
    for(int i=0;i<s;i++){
      cin >> p >> q >> r;
      if(p==q) cout << 0 << endl;
      else if(r==0) cout << d0[p][q] << endl;
      else cout << d1[p][q] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(be(a));
    ll ma=1e18+1,mi=-ma;
    ll mid=(ma+mi)/2;
    while(ma-mi>1){
        ll num=0;
        for(int i=0;i<n;i++){
            if(a[i]<0){
            	ll le=-1,ri=n,niko=(ri+le)/2;
            	while(ri-le>1){
            		if(a[niko]*a[i]<=mid){
            			ri=niko;
            		}else{
            			le=niko;
            		}
            		niko=(ri+le)/2;
            	}
            	num+=n-ri;
                if(ri!=n&&a[i]>=a[ri])num--;
            }else if(a[i]==0){
                if(mid>=0)num+=n-1;
            }else{
            	ll le=-1,ri=n,niko=(ri+le)/2;
            	while(ri-le>1){
            		if(a[niko]*a[i]<=mid){
            			le=niko;
            		}else{
            			ri=niko;
            		}
            		niko=(ri+le)/2;
            	}
            	num+=le+1;

                if(le!=-1&&a[i]<=a[le])num--;
            }
        }

        if(num>=k*2){
            ma=mid;
        }else{
            mi=mid;
        }
        mid=(ma+mi)/2;
    }
    cout <<ma<<endl;
    return 0;
}


Measured memory_bytes: 1792
import itertools
import sys
input = sys.stdin.readline
n = int(input())
data = []
for x in range(n):
    for y in range(int(input())):
        k, l = map(int, input().split())
        data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
    s = sum(list(i))
    for g in data:
        if i[g[0]] == 1 and i[g[1]] != g[2]:
            s = 0
            break
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 3064
/* Coached by rainboy */
#include <stdio.h>
#include <stdlib.h>

#define N 1000

long long xx[N], yy[N], zz[N], ww[N];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return ww[i] == ww[j] ? 0 : ww[i] > ww[j] ? -1 : 1;
}

int main() {
	static int ii[N];
	int n, m, i, b;
	long long a, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%lld%lld%lld", &xx[i], &yy[i], &zz[i]);
	ans = 0;
	for (b = 0; b < 8; b++) {
		for (i = 0; i < n; i++) {
			ww[i] = (b & 1 ? -xx[i] : xx[i]) + (b & 2 ? -yy[i] : yy[i]) + (b & 4 ? -zz[i] : zz[i]);
			ii[i] = i;
		}
		qsort(ii, n, sizeof *ii, compare);
		a = 0;
		for (i = 0; i < m; i++)
			a += ww[ii[i]];
		if (ans < a)
			ans = a;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
const ll MAX_A = 1010;

int main() {
    ll n, k;
    cin >> n >> k; 
    
    map<ll, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }

    vl v;
    for(auto p : mp) {
        v.pb(p.second);
    }
    sort(all(v));

    ll m = v.size();
    if(m <= k) {
        out(0);
    }
    else {
        ll ans = 0;
        rep(i, m-k) {
            ans += v[i];
        }
        out(ans);
    }

    re0;
}

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

using namespace std;
int ans;
int main(){
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < n; i++){
		ans++;
		for(int j = i + 1; j < n; j++){
			if(s[i] == s[j]){
				i = j;
			}
			else break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){

  int A,B,C;
  cin >> A >> B >> C;
  
  int ans = 0;
  
  if(A == B && A == C) ans++;
  if(A != B && B != C && A != C) ans++;
  
  if(ans == 0){
    puts("Yes");
  }else{
    puts("No");
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

def print_end(x):
    pr = ['No','Yes']
    print(pr[x])
    exit()

if(sum(a)==0):
    print_end(1)

if(n%3!=0):
    print_end(0)

set_a = set(a)
if(len(set_a)==1)|(len(set_a)>3):
    print_end(0)

if(len(set_a)==2):
    a0,a1 = sorted(list(set_a))
    if(a0!=0):
        print_end(0)
    if(a.count(a0) * 2 == a.count(a1)):
        print_end(1)
    print_end(0)
else:
    a0,a1,a2 = sorted(list(set_a))
    if(a.count(a0) == a.count(a1) == a.count(a2))&((a0^a1)==a2):
        print_end(1)
    print_end(0)

Measured memory_bytes: 60784
main = do
  [n,y] <- map read . words <$> getLine :: IO [Int]
  let c = [[k,j,i] | i<-[0..n], j<-[0..(n-i)], k<-[0..(n-i-j)], (i*1000 + j*5000 + k*10000)==y, i+j+k==n]
  if not $ null c then putStrLn (init $ concatMap ((++" ") . show) $ head c) else putStrLn "-1 -1 -1"

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,a[200000],memo[2][200000],sum,ans=INF;

signed main() {
    cin >> n;
    rep(i,n) cin >> a[i], sum += a[i], memo[0][i] = memo[1][i] = a[i];
    rep1(i,n) memo[0][i] += memo[0][i-1];
    repm(i,n-1) memo[1][i] += memo[1][i+1];
    rep1(i,n) ans = min(ans,abs(memo[0][i-1]-memo[1][i]));
    cout << ans << endl;
}




Measured memory_bytes: 4992
import java.util.Scanner;

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

        int M = 0, S = 0;
        for (int i = 0; i < N; ++i){
            L[i] = sc.nextInt();
            M = Math.max(M, L[i]);
            S += L[i];
        }

        System.out.println(2 * M < S ? "Yes" : "No");

        sc.close();
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3648
#include <string>
#include <iostream>
using namespace std;

#include <algorithm>
#include <vector>
#include <cstdio>
#include <random>
#include <functional>



int main(){
  int N, Alice=0, Bob=0, dif;
  cin >> N;
  int v[N];
  for (int i = 0; i < N; i++) {
    cin >> v[i];
	}
  
  std::sort(v, v+N, greater<int>());
  for(int i = 0; i<N;i++){
    if(i%2 == 0)Alice += v[i] ;
    else Bob += v[i];
  }
 
    dif = Alice - Bob;
  
 cout << dif <<  endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	_ = scanInt()
	m := scanInt()

	ps := make(pairs, m)
	for i := 0; i < m; i++ {
		p := scanInt()
		y := scanInt()
		ps[i] = pair{p, y, i}
	}
	sort.Sort(ps)

	ps = append(ps, pair{-1, -1, -1})
	x := 1
	ans := make([]int, m)
	for i := 0; i < m; i++ {
		ans[ps[i].num] = ps[i].p*1e6 + x
		x++
		if ps[i].p != ps[i+1].p {
			x = 1
		}
	}

	for i := 0; i < m; i++ {
		fmt.Fprintf(wr, "%012d\n", ans[i])
	}
}

type pair struct {
	p, y, num int
}

type pairs []pair

func (a pairs) Len() int      { return len(a) }
func (a pairs) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a pairs) Less(i, j int) bool {
	if a[i].p == a[j].p {
		return a[i].y < a[j].y
	}
	return a[i].p < a[j].p
}


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

int main() {
  int N, M;
  cin >> N >> M;

  int ans = 1;
  for (int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      if (M / i >= N)
        ans = max(ans, i);
      if (i >= N)
        ans = max(ans, M / i);
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct LazySegmentTree {
private:
    int n;
    vector<T> node, lazy;
    vector<bool> updated;
    T def;
    function<T(T,T)> cmp;
    
    void init(const vector<T> &v, T _def, function<T(T,T)> _cmp) {
        def = _def; cmp = _cmp;
        int vl = (int)v.size();
        n = 1; while(n < vl) n *= 2;
        node.resize(2 * n - 1);
        lazy.resize(2 * n - 1, _def);
        updated.resize(2 * n - 1, false);
        for(int i = 0; i < vl; i++) node[i + n - 1] = v[i];
        for(int i = n - 2; i >= 0; i--) node[i] = cmp(node[i * 2 + 1], node[i * 2 + 2]);
    }
    
    void eval(int k, int l, int r) {
        if (updated[k]) {
            node[k] += lazy[k];
            if ((r - l) > 1) {
                lazy[k * 2 + 1] += lazy[k] / 2;
                lazy[k * 2 + 2] += lazy[k] / 2;
                updated[k * 2 + 1] = updated[k * 2 + 2] = true;
            }
            lazy[k] = 0;
            updated[k] = false;
        }
    }
    
public:
    LazySegmentTree() {}
    LazySegmentTree(int _n, T _def, function<T(T,T)> _cmp) {
        init(vector<T>(_n, _def), _def, _cmp);
    }
    LazySegmentTree(const vector<T> &v, T _def, function<T(T,T)> _cmp) {
        init(v, _def, _cmp);
    }
    
    void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if((b <= l) || (r <= a)) return;
        if((a <= l) && (r <= b)) {
            lazy[k] += (r - l) * x;
            updated[k] = true;
            eval(k, l, r);
        }
        else {
            update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = cmp(node[2 * k + 1], node[2 * k + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        eval(k, l, r);
        if ((b <= l) || (r <= a)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return cmp(vl, vr);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    LazySegmentTree<ll> lst(n, 0, [](ll a, ll b){ return a + b; });
    rep(i, q) {
        ll com;
        cin >> com;
        if (com == 0) {
            ll s, t, x;
            cin >> s >> t >> x;
            s--; t--;
            lst.update(s, t + 1, x);
        }
        else {
            ll s;
            cin >> s;
            s--;
            cout << lst.query(s, s + 1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7880
#include<stdio.h>

#define S 100002
int N;
int list[S];
int s[S];

void input(){
	int i;
	char c;
	scanf("%d\n", &N);
	for( i = 1; i <= N; i++ ){
		scanf("%c", &c);
		s[i] = (c=='o'?0:1);
	}
	return;
}

void output(){
	int i;
	for( i = 1; i <= N; i++ ){ printf("%c", (list[i]==0?'S':'W')); }
	printf("\n");
	return;
}

int get(){
	int i;
	for( i = 2; i <= N; i++ ){
		list[i+1] = (list[i-1] + list[i] + s[i]) % 2;
	}
	return 0;
}

int check(){
	int i;
	list[0] = list[N];
	list[N+1] = list[1];
	for( i = 1; i <= N; i++ ){
		if( (list[i-1] + list[i] + list[i+1]) % 2 != s[i] ){ return 0; }
	}
	return 1;
}

int main(){
	int i;
	input();
	int start[4][2] = {{0,0}, {0,1}, {1,0}, {1,1}};
	for( i = 0; i < 4; i++ ){
		list[1] = start[i][0];
		list[2] = start[i][1];
		get();
		if( list[N+1] != list[1] ){ continue; }
		if( check() == 0 ){ continue; }
		output();
		return 0;
	}
	printf("-1\n");
	return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main() {
  int n;
  scanf("%d",&n);
  int ans = 0;
  if((n/1000)==2) {
    ans++;
  }
  if((n/100)%10==2) {
    ans++;
  }
  if((n/10)%10==2) {
    ans++;
  }
  if(n%10==2) {
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    ll N;
    cin >> N;

    ll ans = 0;
    for (int a = 1; (N - a) / a > a; a++) {
        if ((N - a) % a == 0)
            ans += (N - a) / a;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  long long int a[3005],sum=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum=sum+a[i]-1;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}


void solve() {
    ll a, b; cin >> a >> b;
    ll ans = LCM(a,b);
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  double sum=0;
  double a[n+1];
  for(int i=0; i<n; i++){
    cin>>a[i];
    sum+=a[i];
  }
  double x=sum/n;
  int k=n-1;
  double m=abs(a[n-1]-x);
  for(int i=n-2; i>=0; i--){
    if(m>=abs(a[i]-x)){
      m=abs(a[i]-x);
      k=i;
    }
  }
  cout<<k<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long f[100010],w[110],c[110];
int main()
{
    long long n,v;
    cin>>n>>v;
    for(int i=1;i<=n;i++)
        cin>>c[i]>>w[i];
    for(long long i=1;i<=n;i++)
        for(long long j=v;j>=c[i];j--)
            f[j]=max(f[j],f[j-c[i]]+w[i]);
    cout<<f[v]<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

s = input()
y(s != s[0] * 3)



Measured memory_bytes: 5040
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int
	n = nextInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	ans, s := bubbleSort(a)
	printSlice(s)
	fmt.Println(ans)

}

func printSlice(s []int) {
	length := len(s)
	for i, v := range s {
		if i == length-1 {
			fmt.Printf("%d\n", v)
		} else {
			fmt.Printf("%d ", v)
		}
	}

}

func bubbleSort(a []int) (int, []int) {
	left := 0
	n := len(a)
	ans := 0
	for left < n-1 {
		for i := n - 1; i >= left+1; i-- {
			v := a[i]
			if v < a[i-1] {
				a[i] = a[i-1]
				a[i-1] = v
				ans++
			}
		}
		left++
	}
	return ans, a
}



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

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define nnm(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int N;
int pos[100010];
int A, B;
int combA[100010];
int combB[100010];
int combN[100010];
int sumA[100010]; //sumA[n] : AC0 + AC2 + ... + ACn
int sumB[100010];

const int mod = 1000000007;

int P(int x, int y) {
	if (y == 1) return x;
	int a = P(x, y / 2);
	int ret = (int)(((ll)a * (ll)a) % mod);
	if (y & 1) ret = (int)(((ll)ret * (ll)x) % mod);
	return ret;
}

int recip(int x) {
	return P(x, mod - 2);
}

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	N++;
	for (int i = 1; i <= N; i++) {
		int j;
		scanf("%d", &j);
		if (pos[j] != 0) {
			A = pos[j];
			B = i;
			break;
		}
		pos[j] = i;
	}
	A = A - 1;
	B = N - B;

	int NC = 1;
	int C = 1;
	for (int k = 1; k <= N; k++) {
		int temp = (int)(((ll)(N - k + 1) * (ll)NC) % mod);
		NC = (int)(((ll)temp * (ll)recip(k)) % mod);
		if (k != 1 && (k - 1) <= A + B) {
			temp = (int)(((ll)(A + B - k + 2) * (ll)C) % mod);
			C = (int)(((ll)temp * (ll)recip(k - 1)) % mod);
		}

		int ans = NC;
		if ((k - 1) <= A + B) ans = nnm(ans - C, mod);

		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll dp[100000][2];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  dp[0][0]=a[0];
  dp[0][1]=-a[0];
  repeat(i,1,n-1) {
    dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
    dp[i][1]=max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
  }
  cout << max(dp[n-2][0]+a[n-1],dp[n-2][1]-a[n-1]) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>d(2*n);
    rep(0,i,2*n){
        cin>>d[i];
    }
    ll ans=false;
    rep(2,i,n){
        if(d[2*i]==d[2*i+1]&&d[2*i-1]==d[2*i-2]&&d[2*i-3]==d[2*i-4])ans=true;
    }
    if(ans)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3624