akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){

  // read problem
  long long int N, M, tmp;
  scanf("%lld%lld", &N, &M);

  std::vector<long long int> k;
  std::vector<std::vector<long long int> > s(M);
  std::vector<long long int> p;

  for(long long int i = 0; i < M; i++){
    scanf("%lld", &tmp);
    k.push_back(tmp);
    for(long long int j = 0; j < k[i]; j++){
      scanf("%lld", &tmp);
      s[i].push_back(tmp-1);
    }
  }
  for(long long int i = 0; i < M; i++){
    scanf("%lld", &tmp);
    p.push_back(tmp);
  }

  // solve problem
  long long int ans = 0;
  long long int onflag;
  for(long long int S = 0; S < (1LL << N); S++){
    onflag = 1;
    // check states of each light
    for(long long int i = 0; i < M; i++){
      tmp = 0;
      for(long long int j = 0; j < k[i]; j++){
        tmp += (S>>s[i][j])&1;
      }
      // if the light is off
      if((tmp+2)%2 != p[i]){
        onflag = 0;
        break;
      }
    }
    // if all lights are on
    if(onflag == 1){
      ans++;
    }
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;  
}


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

using namespace std;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
char c[5] = "LRDU";
long long x[1000];
long long y[1000];
char ans[1000][41];

int main() {
    int n, i, j, k;
    vector <long long> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%lld %lld", &x[i], &y[i]);
    
    for (i = 1; i < n; i++) {
        if (abs(x[0] + y[0]) % 2 != abs(x[i] + y[i]) % 2) {
            puts("-1");
            
            return 0;
        }
    }
    
    for (i = 35; i >= 0; i--) {
        long long d = (1LL << i);
        
        for (j = 0; j < n; j++) {
            int p = -1;
            long long m = 1e18;
            
            for (k = 0; k < 4; k++) {
                long long t = abs(x[j] + dx[k] * d) + abs(y[j] + dy[k] * d);
                
                if (t < m) {
                    m = t;
                    p = k;
                }
            }
            
            x[j] += dx[p] * d;
            y[j] += dy[p] * d;
            ans[j][v.size()] = c[p];
        }
        
        v.push_back(d);
    }
    
    if (x[0] + y[0] != 0) {
        for (i = 0; i < n; i++) {
            for (j = 0; j < 4; j++) {
                if (abs(x[i] + dx[j]) + abs(y[i] + dy[j]) == 0) {
                    ans[i][v.size()] = c[j];
                    
                    break;
                }
            }
        }
        
        v.push_back(1);
    }
    
    printf("%d\n", v.size());
    
    for (i = 0; i < v.size(); i++) {
        if (i > 0) putchar(' ');
        printf("%lld", v[i]);
    }
    puts("");
    
    for (i = 0; i < n; i++) printf("%s\n", ans[i]);
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

map <ll, vll> clean;


int main () {
	fastCin;
	int n;
	cin >> n;
	ll mx[3] = {longLIMIT::min(), longLIMIT::min(), 0};
	ll mn[3] = {longLIMIT::max(), longLIMIT::max(), 0};
	for (int x = 0; x < n; x++) {
		ll a, b;
		cin >> a >> b;
		if (a+b > mx[0]) {
			mx[0] = a+b;
		}
		if (a-b > mx[1]) {
			mx[1] = a-b;
		}
		if (a+b < mn[0]) {
			mn[0] = a+b;
		}
		if (a-b < mn[1]) {
			mn[1] = a-b;
		}
	}
	cout << max (mx[0]-mn[0], mx[1]-mn[1]) << "\n";

	return 0;
}

Measured memory_bytes: 3172
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.IntStream;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        long n = in.nextLong();
        int min = 100;
        for (long i = 1; i * i <= n; i++) {
            if(n % i != 0) continue;
            min = Math.min(min, Math.max(String.valueOf(i).length(), String.valueOf(n / i).length()));
        }
        System.out.println(min);
    }
}


class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

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

int main()
{
  long long d, t, s;

  cin >> d >> t >> s;

  if(d  <=(t*s)){
    cout << "Yes";
  }
  else{
    cout << "No";
  }



}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 2000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
string str; 
long long CNT[MAXA] = {0};
long long func(long long int num){
	if(num%2==0){
		return (num/2)*(num-1);
	}else{
		return (num)*((num-1)/2);
	}
	
}
int main(){
	long long int i, n, j;
	map<string,long long> mp;
	cin >> n;
	rer(i,0,n){
		cin >> str;
		sort(str.begin(),str.end());
		mp[str]++;
	}
	long long int sum = 0;
//	auto可以在声明变量时根据变量初始值的类型自动为此变量选择匹配的类型
	for(map<string,long long>::iterator it = mp.begin(); it != mp.end(); it++){
		sum += func(it->second);
	}
	cout << sum;
	return 0;
} 


Measured memory_bytes: 11136
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<int,int> P;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N,K;
    cin >> N >> K;
    int ans = 1;
    for(int i = 1; i <= N; i++){
        ans = min(ans*2,ans+K);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Working program with FastReader 
import java.io.*; 

import java.util.*; 
 

public class Main 
{ 
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

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

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	public static void main(String[] args) 
	{ 
		int mod=1000000007;
		FastReader sc=new FastReader(); 
		int n=sc.nextInt();
		long[] a=new long[n];
		for(int i=0;i<n;i++)
		a[i]=sc.nextLong()%mod;
		
		long pSum[]=new long[n];
			pSum[n-1]=a[n-1];
		for(int i=n-2;i>=0;i--)
		pSum[i]=(a[i]+pSum[i+1])%mod;
	
		
		long sum=0;long prod=1;
		
		for(int i=0;i<n-1;i++)
		{
		    prod=(a[i]*pSum[i+1])%mod;
		    sum=(sum+prod)%mod;
		    prod=1;
		}
	
		System.out.println(sum%mod);
	} 
} 


Measured memory_bytes: 56440
fn main() {
    let n: i32 = read();
    let mut qq: Vec<i32> =  Vec::new();
    for i in 1..10 {
        for j in 1..10 {
            qq.push(i * j);
        }
    }
    for i in &qq {
        if i == &n {
            println!("Yes");
            break;
        } else if i == &qq[qq.len() - 1] {
            println!("No");
            break;
        } else {
            continue;
        }
    }

}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int x, n;
    int p[101];
    map<int, int> cnt;

    cin >> x >> n;
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }

    for(int i = 0; i < n; i++) {
        cnt[p[i]] = 1;
    }

    for(int i = 0; i <= 1000; i++) {
        if(cnt[x - i] == 0) {
            cout << x - i << endl;
            exit(0);
        } else if(cnt[x + i] == 0) {
            cout << x + i << endl;
            exit(0);
        }
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    }
}

Measured memory_bytes: 25660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846



int main(void) {
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);

	if (abs(x - b) >= abs(x - a)) {
		printf("A");
	}
	else {
		printf("B");
	}


	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;

ll dp[200000][3];
ll A[200000];
void rec1(ll i){
	if (i==0){
		dp[i][0] = A[i*2];
		dp[i][1] = A[i*2+1];
	}
	dp[i+1][0] = dp[i][0] + A[i*2+2];
	dp[i+1][1] = max(dp[i][0] + A[i*2+2+1], dp[i][1] + A[i*2+2+1]);
}

void rec2(ll i){
	if (i==0){
		dp[i][0] = A[i*2];
		dp[i][1] = A[i*2+1];
		dp[i][2] = A[i*2+2];
	}
	dp[i+1][0] = dp[i][0] + A[i*2+2];
	dp[i+1][1] = max(dp[i][0] + A[i*2+2+1], dp[i][1] + A[i*2+2+1]);
	dp[i+1][2] = max(max(dp[i][0] + A[i*2+2+2], dp[i][1] + A[i*2+2+2]), dp[i][2]+ A[i*2+2+2]);
}

// 検索タグ
int main() {
	// 入力
	ll N;cin>>N;
    REP(i,N)cin>>A[i];

	// 解法
	ll ans;
	if (N%2==0){
		REP(i,N/2) rec1(i);
		ans = max(dp[N/2-1][0], dp[N/2-1][1]);
	}
	else{
		REP(i,N/2) rec2(i);
		ans = max(dp[N/2-1][0], dp[N/2-1][1]);
		ans = max(ans, dp[N/2-1][2]);
	}
	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 7600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s, t;
  cin >> s >> t;
  int mn = INT_MAX;
  for(int i = 0; i <= s.size() - t.size(); i++){
    int cur = 0;
    for(int j = 0; j < t.size(); j++){
      if(s[i + j] != t[j]) cur++;
    }
    mn = min(mn, cur);
  }
  cout << mn << "\n";
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
using namespace std;

int main() {
	string s; cin >> s;
	int cnt = 0;
	int ans = 0;

	rep(i, s.size()) {
		for (int j = s.size(); j >0 ; j--) {
			for (int k = i; k < j; k++) {
				if (s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T')break;
				if (s[k] == 'A' || s[k] == 'C' || s[k] == 'G' || s[k] == 'T') {
					cnt++;
				}
			}
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, Z, W;
    cin >> N >> Z >> W;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];

    if(N == 1){
        cout << abs(W-a[0]) << endl;
        return 0;
    }
    ll ans = max(abs(W-a[N-1]), abs(a[N-2]-a[N-1]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int t,n,m,e,ask,vot=0,sum=0;
	int a[10000];
	scanf("%d%d",&n,&m);
	for(t=0;t<n;t++){
		scanf("%d",&a[t]);
		sum=sum+a[t];
	}
	ask=sum/(4*m);
	if(sum%(4*m)!=0){
		ask=ask+1;
	}
	for(e=0;e<n;e++){
		if(a[e]>=ask){
			vot=vot+1;
		}
	}
	if(vot>=m){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
fun main(args:Array<String>) {
    val (a,b,c,d) = readLine()!!.split(" ").map { it.toInt() }
    var count = 1
    while (true) {
        if (c - b*count <= 0) {
            println("Yes")
            break
        }
        if (a - d*count <= 0) {
            println("No")
            break
        }
        count++
    }
}

Measured memory_bytes: 36324
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

int main(void)
{
	int d, t, s;
	scanf("%d %d %d", &d, &t, &s);
	printf(t * s >= d ? "Yes" : "No");
	return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define FF first
#define SS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 1000007;

int n;
char s[MAXN], t[MAXN];
PII q[MAXN];

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d%s%s", &n, s+1, t+1 );
}

void work ()
{
	// main work
	
	int tl, si = n + 1, l = 1, r = 0, tag = 0, tc;
	for ( int i = n; i; i = tl - 1 ){
		--si;
		while ( si && s[si] != t[i] ) --si;
//		cerr << i << " " << si << endl;
		if ( !si ){
			printf ( "-1\n" );
			return;
		}
		tl = i;
		while ( tl > si && t[tl-1] == t[i] ) --tl;
		
		if ( l <= r && q[r].SS - tag == si ) ++q[r].FF;
		else q[++r] = MP ( 1, si + tag );
		if ( q[l].SS - tag == i ){
			if ( !--q[l].FF ) ++l;
		}
		tc = 0;
		while ( l <= r && q[l].SS - tag >= tl ) tc += q[l++].FF;
		if ( tc ) q[--l] = MP ( tc, tl + tag );
		
		++tag;
	}
	
	int ans = 0;
	while ( l <= r ) ans += q[l++].FF;
	
	cout << ans << endl;
}

Measured memory_bytes: 9984
// https://atcoder.jp/contests/abc166/tasks/abc166_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, M;
  cin >> N >> M;

  VL hs(N);
  rep(i, N) cin >> hs[i];

  VVL edge_list(N, VL(0));

  rep(i, M) {
    ll a, b;
    cin >> a >> b;
    --a, --b;

    edge_list[a].push_back(b);
    edge_list[b].push_back(a);
  }

  ll res = 0;

  rep(u, N) {
    ll ok = true;

    for (auto v : edge_list[u]) {
      unless(hs[u] > hs[v]) ok = false;
    }

    if (ok) res++;
  }

  cout << res << "\n";
}


Measured memory_bytes: 9796
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <numeric>
#include <algorithm>
#include <math.h>

using namespace std;

int N;

int main(){
    cin >> N;
    vector<int> X(N);
    for(int i=0;i<N;i++)    cin >> X[i];

    vector<int> cpX(N);
    for(int i=0;i<N;i++)    cpX[i] = X[i];
    sort(cpX.begin(), cpX.end());

    double midd = (N-1) / 2.0;
    
    for(int i=0;i<N;i++){
        auto itr = lower_bound(cpX.begin(), cpX.end(), X[i]);
        int index = itr - cpX.begin();
        if( index < midd ) cout << cpX[N/2] << endl;
        else                cout << cpX[(N-1)/2] << endl;
    }

    cout << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++);

int main() {
	char S[11];
	int count = 0;
	bool flag = false;
	cin >> S;
	if (S[0] != 'A') {
		cout << "WA" << endl;
		return(0);
	}
	for (int i = 1; i < (int)strlen(S); i++) {
		if (S[i] == 'C') {
			if ((i == 1)||(i == strlen(S) - 1)||flag) {
				cout << "WA" << endl;
				return(0);
			}
			flag = true;
		}else if((S[i]>= 'a')&&(S[i]<= 'z')){
			count++;
		}
	}
	if (flag && (count == strlen(S) - 2))cout << "AC" << endl;
	else cout << "WA" << endl;
	return(0);
}


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

int main(){
    int N, K;
    cin >> N >> K;
    
    vector<int> B(N);
    int d[K];
    for (size_t i = 0; i < K; i++)
    {
        cin >> d[i];
        int A[d[i]];
        for (int j = 0; j < d[i]; j++)
        {
            cin >> A[j];
            B.at(A[j] - 1)++;
        }
        
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (B.at(i) == 0)
        {
            ans++;
        }
        
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
  int d,t,s;
  1<=d<=10000;
  1<=t<=10000;
  1<=s<=10000;

  scanf("%d %d %d",&d,&t,&s);
  if(d<=s*t){
    printf("Yes");
  }else{
    printf("No");
  }

return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)



int main()
{
	ios::sync_with_stdio(false);
	string T;
	int n;
	cin>>T;
	n=T.length();
	for(int i=0;i<n;i++)
	{
		if(T[i]!='?')
		cout<<T[i];
		else cout<<"D";
	}
	return 0;
}




Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    int A[110000];
    cin >> N;
    for(int i=0; i < N; i++) cin >> A[i];

    // int num[1100000000];
    // for (int i = 0; i < N; i++)
    // {
    //     num[A[i]]++;
    // }

    sort(A, A + N);
    
    int ans = 0;
    int res = 0;
    while(res < N)
    {
        int c = A[res], f = 0;
        while ((A[res] == c) && (res < N))
        {
            f++;
            res++;
        }
        ans += f%2;
    }
    
    cout << ans << endl;

    return 0;
}

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

//ABC125A
int main(void) {
  int a,b,t,n, k, i, cou=0, tmp;
  scanf("%d %d %d", &a,&b,&t);
  printf("%d",t/a*b);
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[105][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i][0];
    }
    REP(i, N) {
        cin >> A[i][1];
    }

    ll ans = 0;
    ll s = 0;
    REP(i, N) {
        s += A[i][0];
        ll t = s;
        FOR(j, N, i) {
            t += A[j][1];
        }
        ans = std::max(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans = "";

		if ( Math.abs(x-a) < Math.abs(x-b) ) {
			ans = "A";
		} else {
			ans = "B";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
 
int main() {
	long int a,b,k,i;
	cin>>a>>b>>k;
	long int sum=a+b;
	for(i=a;i<a+k && i<=b;i++)
	   {
	   	cout<<i<<'\n';
	   }
	  //cout<<'a'<<'\n'; 
	 for(i=b-k+1;i<=b;i++)
	   {
	   	if(i>=a+k)
	   	  cout<<i<<'\n';
	   	else
	   	   continue;
	   }
	// your code goes here
	return 0;
}

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

int main()
{
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	printf("%.11lf ",w*h/2.0);
	if(w/2==x&&h/2==y)
	{
		cout<<'1'<<endl;
	}
	else
	{
		cout<<'0'<<endl;
	}
	
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e6;
int n , a[maxn] , dp[maxn];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    cin >> a[1];
    for(int i = 2 ; i <= n ; ++i)
    {
        cin >> a[i];
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        if(i > 2)dp[i] = min(dp[i] , dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n];
}


Measured memory_bytes: 4736
//author : Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define ln "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

const ll MOD = 1e9 + 7;

int main()
{
	FASTIO;
	string str;
	cin >> str;
	int n = str.length();
	for (int i = 0; i < n - 1; i++)
		if (str[i] == str[i + 1])
		{
			cout << "Bad" << ln;
			return 0;
		}
	cout << "Good" << ln;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String s = sc.next();
    char[] res = s.toCharArray();
    char[] m = new char[N];
    String ans = "-1";
    boolean flg;
    char[] sw = {'S', 'W'};

    // m[0],m[1]を決めて残りのmを求めていく
    for(int k = 0; k < 2; k++) {
      for(int l = 0; l < 2; l++) {
        flg = true;
        m[0] = sw[k];
        m[1] = sw[l];
        for(int i = 1; i < N - 1; i++) {
          if(res[i] == 'o') {
            if(m[i] == 'S') {
              m[i + 1] = m[i - 1];
            } else {
              if(m[i - 1] == 'S') {
                m[i + 1] = 'W';
              } else {
                m[i + 1] = 'S';
              }
            }
          } else {
            if(m[i] == 'S') {
              if(m[i - 1] == 'S') {
                m[i + 1] = 'W';
              } else {
                m[i + 1] = 'S';
              }
            } else {
              m[i + 1] = m[i - 1];
            }
          }
        }
        // res[N - 1]に矛盾がないかチェック
        if(res[N - 1] == 'o') {
          if(m[N - 1] == 'S') {
            if(m[N - 2] != m[0]) flg = false;
          } else {
            if(m[N - 2] == m[0]) flg = false;
          }
        } else {
          if(m[N - 1] == 'S') {
            if(m[N - 2] == m[0]) flg = false;
          } else {
            if(m[N - 2] != m[0]) flg = false;
          }
        }
        // res[0]に矛盾がないかチェック
        if(res[0] == 'o') {
          if(m[0] == 'S') {
            if(m[N - 1] != m[1]) flg = false;
          } else {
            if(m[N - 1] == m[1]) flg = false;
          }
        } else {
          if(m[0] == 'S') {
            if(m[N - 1] == m[1]) flg = false;
          } else {
            if(m[N - 1] != m[1]) flg = false;
          }
        }

        if(flg) ans = new String(m);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26436
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		double result = 0;
		for(int i = 0; i < n; i++){
		    double x = sc.nextDouble();
		    String s = sc.next();
		    if(s.equals("JPY")){
		        result += x;
		    }else{
		        result += x * 380000;
		    }
		}
		// 計算

		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 23252
import java.io.*;
import java.util.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        if(a<b){ System.out.println("a < b"); }
        else if(a>b){ System.out.println("a > b");}
        else{ System.out.println("a == b"); }
    }
}

Measured memory_bytes: 24264
#include<stdio.h>

int main(){
  int n, i; 
  int F[44];

  scanf("%d", &n);

  F[0] = 1;
  F[1] = 1;
  
for ( i = 2; i <= n; i++ ) {
    F[i] = F[i-1] + F[i-2];
  }
  
  printf("%d\n", F[n]);

  return 0;
}

Measured memory_bytes: 596
A, B, K = map(int, input().split())

if 2 * K > B - A:
    for i in range(B - A + 1):
        print(A + i)
else:
    for i in range(K):
        print(A + i)
    for j in range(B - K + 1, B + 1):
        print(j)


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

int main() {
  string s;
  cin>>s;
  int a=-10;
  int b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A')a=i;
    if(s[i]=='C'&&a-i==-1)b=1;
  }
  if(b==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();
  ll a, b, c;
  cin >> a >> b >> c;
  out(a + b < c && a * b * 4 < (c - a - b) * (c - a - b) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1001;
int n;
int s[500][500];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int m = sqrt(n*2);
  if(m*(m+1)/2 != n){
    cout << "No" << endl;
    return 0;
  }
  int t = 0;
  cout << "Yes" << endl << m+1 << endl;
  FOR(i, 0, m+1){
    cout << m;
    FOR(j, 0, m) cout << " " << (s[i][j] = (j<i ? s[j][i-1] : ++t));
    cout << endl;
  }
}

Measured memory_bytes: 2304
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double d;

    for(;sc.hasNext();){
      d = sc.nextDouble();
      if(d <= 48.0)out.println("light fly");
      else if(d <= 51.0)out.println("fly");
      else if(d <= 54.0)out.println("bantam");
      else if(d <= 57.0)out.println("feather");
      else if(d <= 60.0)out.println("light");
      else if(d <= 64.0)out.println("light welter");
      else if(d <= 69.0)out.println("welter");
      else if(d <= 75.0)out.println("light middle");
      else if(d <= 81.0)out.println("middle");
      else if(d <= 91.0)out.println("light heavy");
      else out.println("heavy");
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 19264
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<int> a(100002);

int main(){
    ll n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    vector<int> c;
    ll ans = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == 0){
            c.push_back(0);
        } else {
            ll pos = 0;
            int tmp = -1;
            for(int j = 0; j < c.size(); j++){
                if(c[j] == a[i]-1){
                    tmp = j;
                    pos++;
                }
            }
            if(tmp == -1){
                cout << 0 << endl;
                return 0;
            }
            c[tmp]++;
            ans = ans*pos %MOD;
        }
    }

    for(ll j = 0; j < c.size(); j++){
        ans = ans * (3L-j) % MOD;
    }

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

Measured memory_bytes: 1276
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int H = sc.nextInt();
    int W = sc.nextInt();
    System.out.println((N - H + 1) * (N - W + 1));
  }
}

Measured memory_bytes: 22740
#include<stdio.h>
int main()
{
    int height[10];
    int i,j;
    for(i = 0;i < 10;i++)
    {
        scanf("%d", &height[i]);
    }
    for(j = 0; j <9; j++)
    {
        for(i=0; i<9-j; i++)
        {
            int a = 0;
            if(height[i]>height[i+1])
            {
                a = height[i];
                height[i] = height[i+1];
                height[i+1] = a;
            }
        }
    }

    for(i = 9; i >6; i--)
    {
        printf("%d\n", height[i]);
    }
    return 0;
}

Measured memory_bytes: 1856
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>
#include<tuple>
#include<utility>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 2-1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;


int main() {
	int n;
	cin >> n;
	vi a(n);
	REP(i, n)
		cin >> a[i];
	int res = INF;
	for (int j = -100; j <= 100; j++) {
		int cost = 0;
		REP(i, n)
			cost += (j - a[i])*(j - a[i]);
		res = min(cost, res);


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int n,k,ans=0;
int x[200];
signed main(){
    cin>>n>>k;
    rep(i,n){
        cin>>x[i];
        int dis=min(x[i],k-x[i]);
        ans+=2*dis;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
	int n;
	cin>>n;
	ll num[3][2];
	rep(i,3){
		num[i][0]=-1;
		num[i][1]=0;
	}
	rep(i,n){
		bool flag=false;
		ll tmp;
		cin>>tmp;
		rep(j,3){
			if(num[j][0]==-1){
				num[j][0]=tmp;
				num[j][1]++;
				flag=true;
				break;
			}
			else if(num[j][0]==tmp){
				num[j][1]++;
				flag=true;
				break;
			}
		}
		if(flag)continue;
		cout<<"No"<<endl;
		return 0;
	}

	//rep(i,3)cout<<num[i][0]<<","<<num[i][1]<<endl;


	/////全て0//////
	if(num[1][0]==-1 && num[2][0]==-1 && num[0][0]==0)cout<<"Yes"<<endl;
	else if(n%3 != 0)cout<<"No"<<endl;
	/////0,x,x,0,x,x //////
	else if(num[2][0]==-1 && num[1][0]!=-1 && num[0][0]!=-1){
		if(num[0][0]==0 && num[0][1]==n/3 && num[1][1]==2*n/3)cout<<"Yes"<<endl;
		else if(num[1][0]==0 && num[1][1]==n/3 && num[0][1]==2*n/3)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	/////x^y^z=0
	else if((num[0][0]^num[1][0]^num[2][0])==0 && num[0][1]==n/3 && num[1][1]==n/3 && num[2][1]==n/3)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

using namespace std;

#define ge getchar()
#define Re read()

inline int read() {
	int x = 0, ch;
	while(!isdigit(ch = ge)) ;
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = ge;
	return x;
}

template<typename T>
inline void chkmax(T&a, T b) { a = a > b ? a : b; }
template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

int res[3001];
int A[3001];
int B[3001];
int C[3001];
int len;
int p;

inline int ksm(int x, int k) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % p;
		x = 1LL * x * x % p; k >>= 1;
	} return s;
}

inline void Add(int a[], int b[], int m) {
	for(int i = 0; i < p; i++)
		a[i] = (a[i] + b[i] * m) % p;
}

inline void Div(int a[], int b[], int v) {
	int rt = 0;
	for(int i = len - 1; i; i--) {
		int ml = rt + a[i]; b[i - 1] = ml;
		a[i - 1] = (a[i - 1] + v * ml) % p;
	}
}

int main() {
	p = Re; A[1] = 1, len = 2;
	for(int i = 1; i < p; i++) {
		for(int j = len; j >= 1; j--) {
			A[j] = (-A[j] * i % p + p + A[j - 1]) % p;
		} ++len;
	}
	for(int i = 0; i < p; i++) {
		int a = Re, mul = 1;
		if(!a) continue;
		for(int j = 0; j < p; j++)
			if(i != j) mul = mul * (i - j + p) % p;
		mul = ksm(mul, p - 2);
		memcpy(C, A, sizeof(A));
		// for(int j = 0; j <= p; j++) cout << C[j] << ' '; cout << endl;
		Div(C, B, i);
		// for(int j = 0; j < p; j++) cout << B[j] << ' '; cout << endl;
		Add(res, B, mul);
	}
	for(int i = 0; i < p; i++) printf("%d ", res[i]); puts("");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int x;
	cin >> x;

	int ret = x / 11;
	ret *= 2;

	x %= 11;

	if (x > 0) ret++;
	if (x > 6) ret++;

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long 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()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll x = c-a; ll y = d-b;
    cout<<c-y<<' '<<d+x<<' '<<a-y<<' '<<b+x;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
#define MAX 26
#define Astart 65
#define Aend 90
#define Atoa 32
#define astart 97
#define aend 122
using namespace std;

int main()
{
	int count[MAX]={0};
	string ss;

	while(1)
	{
		cin >> ss ;
		if(cin.eof()) break;

		for(int i=0;i<(int)ss.size();i++)
		{
			if(((int)ss[i] >=Astart)&&((int)ss[i]<=Aend))
			{
				ss[i] = ss[i] + Atoa;
			}

			if(((int)ss[i] >=astart)&&((int)ss[i]<=aend))
			{
				count[((int)ss[i]-astart)]++;
			}
		}

	}
	
	for(int i=0;i<MAX;i++)
	{
		cout << (char)(astart+i) << " : " << count[0+i] << endl ; 
	}

	return 0;
}

Measured memory_bytes: 1180
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (D, G): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (p, c): (Vec<usize>, Vec<usize>) = {
        let (mut p, mut c) = (vec![], vec![]);
        for _ in 0..D {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            p.push(iter.next().unwrap().parse().unwrap());
            c.push(iter.next().unwrap().parse().unwrap());
        }
        (p, c)
    };

    fn iceil(a: usize, b: usize) -> usize { (a + b - 1) / b }
    let K = 1 << D;
    let ans = (0..K).map(|x| {
        let complete_score = (0..D).map(|i| ((x >> i) & 1) * (100 * (i + 1) * p[i] + c[i])).sum::<usize>();
        let solved = (0..D).map(|i| ((x >> i) & 1) * p[i]).sum::<usize>();
        let (res, _) = (0..D).rev().fold(
            (solved, complete_score),
            |(problem_cnt, score), i| if ((x >> i) & 1) == 0 && G > score {
                let added = std::cmp::min(iceil(G - score, 100 * (i + 1)), p[i]);
                (problem_cnt + added, score + 100 * (i + 1) * added)
            } else { (problem_cnt, score) }
        );
        res
    }).min().unwrap();

    println!("{}", ans);
}

Measured memory_bytes: 4352