akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		out.println(n*(n+1)/2);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21332
// SeeAlso: 

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    ll dp[200000];
    memset(dp, 0, sizeof(dp));
    int i = 1;
    ll result = 0;
    while(result<200000) {
        result = i*i;
        if(result<200000) {
            dp[result]++;
        }
        i++;
    }

    result = a * pow(10, to_string(b).size()) + b;  

    if(dp[result]>0) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


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


int main()
{
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  if (b - b % k >= a)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  if (S.find("RRR") != string::npos) {
    ans = 3;
  } else if (S.find("RR") != string::npos) {
    ans = 2;
  } else if (S.find("R") != string::npos) {
    ans = 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
	int n;
	int ans=1;
	string s;
	cin >> n >> s;

	for (int i = 0; i+1 < s.size(); i++) {
		if (s[i] != s[i + 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 2000000000
#define IN (1<<30)
#define O 0
#define I 1
#define W 2
#define Z 10

int H, A[N];

void maxHeapify(int i){
  int l,r,largest,keep;
  l=W*i;
  r=W*i+I;
  if(l<=H&&A[l] > A[i]){
    largest = l;
  }
  else{
    largest=i;
  }
  if(r<=H && A[r] > A[largest]){
    largest=r;
  }
  if(largest!=i){
    keep=A[i];
    A[i]=A[largest];
    A[largest]=keep;
    maxHeapify(largest);
  }
}
void insert(int key){
  H++;
  A[H]=-IN;
  increaseKey(H,key);
}

void increaseKey(int i,int key){
  int c;
  if(key<A[i]){
    return;
  }
  A[i]=key;
  while(i>I  && A[i/W]<A[i]){
    c=A[i/W];
    A[i/W]=A[i];
    A[i]=c;
    i=i/W;
  }
}

int heapExtractMax(){
  int m;
  if(H<I){
    return -IN;
  }
  m=A[I];
  A[I]= A[H];
  H--;
  maxHeapify(I);
  return m;
}

int main(){
  int key;
  A[H]=-IN;
  char com[Z];
  while(I){
    scanf("%s",com);
    if(com[O]=='e' && com[I]=='n'){
      break;
    }
    if(com[O]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",heapExtractMax());
    }
  }
  return O;
}



Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        int ori = i;
        int rev = 0;
        while (ori > 0) {
            rev = rev * 10 + ori % 10;
            ori /= 10;
        }
        if (i == rev) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LIMITATION 1000000000

int gcd(int a, int b);
int main(int argc, char** argv) {
    
  

    int a, b;

    int readScan = scanf("%d %d", &a, &b);
    if (readScan == EOF)
    {
        printf("data not enough! \n");
        return(EXIT_FAILURE);
    }
    if (readScan != 2)
    {
        printf("Input data error!\n");
        return(EXIT_FAILURE);
    }

    if (a < 0 || b < 0)
    {
        printf("Number should be non-negative!\n");
        return(EXIT_FAILURE);
    }  

    if (a > LIMITATION || b > LIMITATION)   
    {
        printf("Number should be less than 10^9! \n");
        return(EXIT_FAILURE);
    }
      
    int gCD;
    gCD = gcd(a, b);
    printf("%d\n", gCD);

    return (EXIT_SUCCESS);
}

int gcd(int x, int y)
{
	while (x != y)
	{
		if (x > y)	x = x - y;
		else        y = y - x;
	}
	return x;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define int long long
void bfs(int i, int f, vector<int> e[], vector<int>& parent, int n)
{
    vector<bool> visited(n, false);
    queue<int> q;
    q.push(i);
    visited[i] = true;
    while(visited[f] == false && q.empty() == false){
        int fr;
        fr = q.front();
        q.pop();
        for( auto &j: e[fr]){
            if(visited[j] == false){
                visited[j] = true;
                q.push(j);
                parent[j] = fr;
            }
        }
    }
}
int height(int i, vector<int> edges[], int x, set<int>& s)
{
    if(edges[i].size() == 1)
        return 1;
    int ans = 0;
    for(auto &j: edges[i]){
        if(j != x && s.find(j) == s.end() )
        ans = max(ans , height(j,edges, i, s) +1);
    }
    return ans;
}
int32_t main()
{
  int n, f, i;
  cin>>n>>f>>i;
  f--;
  i--;
  vector<int> e[n];
  for(int i=0; i<n-1; i++){
      int a, b;
      cin>>a>>b;
      a--;
      b--;
      e[a].push_back(b);
      e[b].push_back(a);
  }
  vector<int> parent(n, -1);
  bfs(i, f, e, parent,n);
  parent[i] = i;
  vector<int> path1;
  set<int> s;
  int k = f;
  while(parent[k] != k){
   path1.push_back(k);
   s.insert(k);
   k = parent[k];
  }
  path1.push_back(k);
  s.insert(k);
  reverse(path1.begin(), path1.end());
  int ans = INT_MIN;
  int leave = ((int)path1.size() + 1) / 2;
  int extra = leave;
  int discard;  
  for(auto &j: path1){
    if(leave > 0 ){ leave--, discard  = j;}
    else{
        ans = max(ans, height(j, e, discard, s) - 2 + extra);
        //cout<<j<<" "<<height(j, e, discard)<<endl;
        discard = j;
        extra++;
    }
}
cout<<ans;
}
    


Measured memory_bytes: 12672
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

bool p[50000];

int main(){
	int n,cnt;
	vector<int> v;
	for(int i=2;i<50000;i++)if(!p[i]){
		v.push_back(i);
		for(int j=i+i;j<50000;j+=i)p[j]=1;
	}
	for(;;){
		scanf("%d",&n);
		if(!n)break;
		cnt=0;
		for(int i=0;v[i]<=n/2;i++)cnt+=binary_search(v.begin(),v.end(),n-v[i]);
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(void) {
	int R0 = 0, W0 = 0, C = 0, R = 0;
	while (cin >> R0 >> W0 >> C >> R) {
		if (R0 == 0) {
			break;
		}
		int x = 0;
		int r = W0 * C;
		if (R0 < r) {
			if ((r - R0) % R == 0) {
				x = (r - R0) / R;
			}
			else {
				x = (r - R0) / R + 1;
			}			
		}
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int N,T,c,t,C,Flag;

int main(void){
	scanf("%d %d",&N,&T);
	scanf("%d %d",&C,&t);
	if(t<=T)Flag=1;
	for(;N>1;N--){
		scanf("%d %d",&c,&t);
		if(t<=T && C>c){
			C=c;
			Flag=1;
		}
	}
	if(Flag)printf("%d",C);
	else printf("TLE");
	return 0;
}

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

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CINS(ll, A, N);
    sort(A.begin(), A.end());

    ll ans = 0;
    int nIndex = -1;
    for (int i = 0; i < N; i++) {
        if (A[i] < 0) nIndex = i;
        ans += abs( A[i] );
    }

    if ( nIndex == -1 ) {
        ans = ans - 2 * A[0];
        nIndex = 0;
    } else if (nIndex == N-1) {
        ans = ans + 2 * A[N - 1];
        nIndex = N - 2;
    }
    cout << ans << "\n";

    ll temp = 0;
    temp = A[0];
    for (int i = nIndex + 1; i < N - 1; i++) {
        cout << temp << " " << A[i] << "\n";
        temp = temp - A[i];
    }
    A[0] = temp;
    temp = A[N-1];
    for (int i = 0; i <= nIndex; i++) {
        cout << temp << " " << A[i] << "\n";
        temp = temp - A[i];
    }

    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <algorithm>

#define BUF 200002
#define LIM_N 100001

char str[BUF];

int N, M;
int L[LIM_N];
int R[LIM_N];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &N, &M);

	for (size_t i = 0; i < M; i++) {
		scanf("%d %d", &L[i], &R[i]);
	}
}

int solve() {
	int l = 1, r = N;
	for (size_t i = 0; i < M; i++) {
		r = r > R[i] ? R[i] : r;
		l = l < L[i] ? L[i] : l;
	}

	int ans = r-l+1;
	return 0 < ans ? ans : 0;
}

int main(void) {
	receive_input();

	// solve();
	printf("%d\n", solve());

	return 0;
}


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

int n;
vector<string> s;
vector<int> cnt, memo;
string lis = " |";

void solve();

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    s.resize(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    solve();
    for(int i = 0; i < n; ++i) cout << s[i] << endl;
  }
  return 0;
}

void solve() {
  cnt.assign(n + 1, 0);
  memo.assign(n + 1, 0);
  for(int i = 0; i < n; ++i) {
    int ncnt = 0;
    while(s[i][ncnt] == '.') ++ncnt;
    memo[i] = ncnt;
    ++cnt[ncnt];
    if(i != 0) s[i][ncnt - 1] = '+';
  }
  for(int i = 1; i < n; ++i) {
    int lim = i + 1;
    bool ch = 0;
    while(lim < n && memo[lim] > memo[i]) ++lim;
    if(lim < n && memo[i] == memo[lim]) ch = 1;
    for(int j = i + 1; j < lim; ++j)
      s[j][memo[i] - 1] = lis[ch];
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const int MAX_N=55555;

int prime[MAX_N];
bool is_prime[MAX_N+1];

// エラトステネスの篩
// is_prime[i]=true⇔iが素数
int sieve(int n){
	int res=0;
	REP(i, n+1){
		is_prime[i]=true;
	}
	is_prime[0]=is_prime[1]=false;
	FOR(i, 2, n+1){
		if(is_prime[i]){
			prime[res++]=i;
			for(int j=2*i; j<=n; j+=i){
				is_prime[j]=false;
			}
		}
	}
	return res;
}

int ans[60];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	sieve(MAX_N);
	int cnt=0;
	REP(i, n){
		while(prime[cnt++]%5!=1);
		cout<<prime[cnt-1]<<" \n"[i==n-1];
	}
	return 0;
}


Measured memory_bytes: 384
import string

N = int(input())
S = input()
R = 26

d = dict(zip(string.ascii_uppercase, range(26)))
inv_d = {v: k for k, v in d.items()}

ans = ""

for c in S:
    i = d[c]
    new_i = (i + N) % R
    ans += inv_d[new_i]

print(ans)


Measured memory_bytes: 3956
K,N=map(int,input().split())
a=list(map(int,input().split()))
ans=K
ans=min(ans,a[-1]-a[0],a[0]+K-a[1],K-a[-1]+a[-2])
for i in range(1,N-1):
  v1=a[i-1]+K-a[i]
  v2=a[i]+K-a[i+1]
  ans=min(ans,v1,v2)
print(ans)

Measured memory_bytes: 77516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int R=scan.nextInt();
		if(R<1200)
		{
			System.out.println("ABC");
		}
		else if((1200<=R) && (R<2800))
		{
			System.out.println("ARC");
		}
		else if(R>=2800)
		{
			System.out.println("AGC");
		}

	}

}


Measured memory_bytes: 35552
#include <iostream>
#include <algorithm>

using namespace std;

int dif(int a){
  int n[20],dig,b=0;
    for(dig = 0;a>0;a/=10,dig++)
      n[dig] = a%10;
    sort(n,n+dig);
    for(int j=dig-1;j>=0;j--){
      b *= 10;
      b += n[j]%10;
    }
    reverse(n,n+dig);
    for(int j=dig-1;j>=0;j--){
      a *= 10;
      a += n[j]%10;
    }
    return b-a;
}

int main(){
  int a,n;
  for(cin>>n;n>0;n--){
  cin >> a;
  cout << dif(a) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  int a,b,work;
  scanf("%d %d",&a,&b);
  if(a<b){
    work=a;
    a=b;
    b=work;}
  while((work=a%b)!=0){
    a=b; 
    b=work;}
  printf("%d\n",b);
return 0;
}

Measured memory_bytes: 592
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
class  goodx{
	int freq;
	int val;
	goodx(int a,int b)
	{
		freq=a;
		val=b;
	}
}
class comparator implements Comparator<goodx>{

	@Override
	public int compare(goodx o1, goodx o2) {
		if(o1.freq<o2.freq)
		{
			return 1;
		}
		else if(o1.freq>o2.freq)
		{
			return -1;
		}else {
			return 0;
		}
	}
	
}
public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=scan.nextInt();
			
		}
		int first[]=new int[1000007];
		int second[]=new int[1000007];
		goodx lol[]=new goodx[n/2];
		
		int counter=0;
		for(int i=0;i<n;i++)
		{
			if(i%2==0)
			{
				first[ar[i]]++;
			}else {
				second[ar[i]]++;
				
			}
		}
		for(int i=1;i<n;i+=2) {
			lol[counter++]=new goodx(second[ar[i]],ar[i]);
		}
		Arrays.parallelSort(lol,new comparator());
//		for(int i=0;i<lol.length;i++)
//		{
//			System.out.println(lol[i].val+" "+lol[i].freq);
//		}
		int global=Integer.MAX_VALUE;
		for(int i=0;i<n/2;i+=2)
		{
			int cost1=(n/2)-first[ar[i]];
			int cost=0;
			for(int j=0;j<n/2;j++)
			{
				if(lol[j].val==ar[i])
					{continue;
					}
				cost=lol[j].freq;
				break;
			}
//			System.out.println(cost);
			int cost2=(n/2)-cost;
//			System.out.println(cost1+" "+cost2);
			global=Math.min(global,cost1+ cost2);
//			System.out.println(global+"this is golal ");
		}
		System.out.println(global);
		
		
	}
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
const int N = 101;
int dis[N][N];
int32_t main(){
	fast;
	int n,m;
	cin >> n >> m;
	
	vector<pair<int,pair<int,int>>> edge(m);
	f(i,0,N)	f(j,0,N)	dis[i][j] = inf;
	f(i,0,N)	dis[i][i] = 0;
	f(i,0,m)
	{
		int x,y,c;
		cin >> x >> y >> c;
		edge[i] = mp(x,mp(y,c));
		dis[x][y] = min(dis[x][y] , c);
		dis[y][x] = min(dis[y][x] , c);
	}
	
	for(int i=1 ; i<=n ; i++)
	{
		for(int j=1 ; j<=n ; j++)
		{
			for(int k=1 ; k<=n ; k++)
				dis[j][k] = min(dis[j][k] , dis[j][i] + dis[i][k]);
		}
	}
	
	int ans = 0;
	int vis[m] = {0};
	for(int i=0 ; i<m ; i++)
	{
		for(int j=1 ; j<=n ; j++)
		{
			for(int k=1 ; k<=n ; k++)
			{
				int u = edge[i].F;
				int v = edge[i].S.F;
				int c = edge[i].S.S;
				if(dis[j][u]  + c + dis[v][k] == dis[j][k] || dis[j][v]  + c + dis[u][k] == dis[j][k] )
					vis[i] = 1;
			}
		}
	}
	f(i,0,m)	if(vis[i] == 0)	ans++;
	cout << ans;
	
}



Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int a,b,c,d,e,f,g,h,i,j;
     cin>>a;
    int ar[a];
    cin>>b;
     for(i=0;i<a;i++)
     {
         cin>>ar[i];
     }
     c=(a-1+b-2)/(b-1);
     cout<<c<<endl;
 }


Measured memory_bytes: 640
l, r = map(int, input().split())
if r-l >=2019:
  l=0
  r=1
else:
  l = l % 2019
  r = r % 2019
if l > r:
  l = 0
  r = 1
min = 2020
now = 0
for i in range(l, r):
  for j in range(i+1, r+1):
    now = i*j%2019
    if min > now:
      min = now
print(min)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    mat a(N, vec(N));
    REP(i, N) readv(a[i]);

    vec dp(1 << N, 0);
    REP(i, 1 << N){
        REP(j, N) REP(k, j){
            if((i & (1 << j)) && (i & (1 << k))) dp[i] += a[j][k];
        }
    }

    FOR(i, 1, 1 << N){
        int tmp = dp[i];
        int sub = i;
        do{
            tmp = max(tmp, dp[sub] + dp[i ^ sub]);
            sub = (sub - 1) & i;
        }while(sub != i);
        dp[i] = tmp;
    }
    cout << dp[(1 << N) - 1];
    
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    llong n, m;
    llong ans;

    signed call_of_Cthulhu( signed datum ) {

        read n >> m;
        if ( n*2 <= m ) {
            m -= n*2;
            ans += n;
        }
        else {
            ans += m/2;
            m = 0;
        }
        echo (ans+m/4) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int l, r;
  cin >> l >> r;
  if (r - l >= 2019) {
    cout << 0 << endl;
  } else {
    int ans = 1e9;
    for (int i = l; i <= r; i++) {
      for (int j = i + 1; j <= r; j++) {
        ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');


            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (c >= a && c <= b)
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

         

            Console.ReadKey();



        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>


long long ans[ 100 + 1 - 2 ][ 20 + 1 ] ;



int main()
{
	int n ;
	scanf( "%d" ,&n ) ;


	int kale[ 100 ] ;


	int i ,j ,pp ,mp ;
	for( i = 0 ; i < n ; ++i )
	{
		scanf( "%d" ,&kale[ i ] ) ;
	}

	ans[ 0 ][ kale[ 0 ] ] = 1 ;

	for( i = 0 ; i < n - 2 ; ++i )
	{
		for( j = 0 ; j <= 20 ; ++j )
		{
			if( ans[ i ][ j ] > 0 )
			{
				pp = j + kale[ i + 1 ] ;
				mp = j - kale[ i + 1 ] ;

				if( pp < 21 )
					ans[ i + 1 ][ pp ] += ans[ i ][ j ] ;

				if( mp >= 0 )
					ans[ i + 1 ][ mp ] += ans[ i ][ j ] ;
			}
		}	
	}

	printf( "%lld\n" ,ans[ i ][ kale[ n - 1 ] ] ) ;


	return 0 ;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    ll cnt=0;
    ll ans=0;
    rep(i,s.size()){
        if(s[i] == 'B') cnt++;
        else if(s[i] == 'W') ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<string.h>

int n[1000] = { 0 };

int main() {
	
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int l;

	scanf("%d", &l);

	for (int i = 0; i < l; i++) {
		scanf("%d", &n[i]);
	}
	std::sort(n, n + l);

	printf("%d", n[l - 1] - n[0]);
}

Measured memory_bytes: 128
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 210000
using namespace std;
int a[N],p[N],f[N],t[N],n;
bool cal(int i,int j,int k)
{
	return (p[i]<p[j])&&(p[j]<p[k]);
}
bool check(int i,int j,int k)
{
	return cal(i,j,k)|cal(j,k,i)|cal(k,i,j);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i;
	for(int i=n-1;i>=1;i--)
		if(t[i+1]==0)
		{
			if(p[i]>p[i+1]) t[i]=1,f[i]=i+1;
		}
		else
		{
			if(check(i,i+1,f[i+1])) t[i]=t[i+1],f[i]=f[i+1];
			else t[i]=t[i+1]+1,f[i]=i+1;
		}
	printf("%d\n",t[1]);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;

int n, k, c;
string s;
int dp[200002];
int mx[200002];
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k >> c;
    cin >> s;
    s = ' ' + s;
    for(int i = n; i >= 1; --i)
    {
        if(s[i] == 'o')
            dp[i] = 1 + mx[min(n+1, i + c + 1)];
        else
            dp[i] = mx[i+1];
        mx[i] = max(dp[i], mx[i+1]);
    }
    int mxr = k;
    int lst = 1;
    int bgrm = 0;
    deque<int> v;
    while(mxr)
    {
        for(int i = lst; i <= n; ++i)
            if(s[i] == 'o' && dp[i] >= mxr)
                v.push_back(i);
            else
            {
                if(mx[i] < mxr){
                    lst = i;
                    break;
                }
            }
       // cout << v.size() << '\n';
        if(v.size() == 1)
            cout << v[0] << '\n';
        if(v.size())
            lst = max(lst, v[0] + c + 1);
      //  cout << lst << '\n';
        int prv_val = v[0];
        while(!v.empty() && prv_val + c + 1 > v[0])
            v.pop_front();
        --mxr;
    }
    return 0;
}


Measured memory_bytes: 3408
// Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(true){
		string S;
		getline(cin, S);
		istringstream ist(S);

		int m;
		ist >> m;

		if(m==0)
			break;

		int N[40], P[40];
		for(int i=0; i<m; i++){
			getline(cin, S);
			istringstream ist(S);

			ist >> N[i];

			int p[21];
			for(int j=0; j<21; j++){
				ist >> p[j];

				if(ist.eof())
					break;
			}

			P[i] = 0;
			int k = 0;
			for(int j=0; j<9; j++){
				P[i] += p[k];
				if(p[k]==10){
					P[i] += (p[k+1]+p[k+2]);
					k++;
					continue;
				}

				P[i] += p[k+1];
				if(p[k]+p[k+1]==10){
					P[i] += p[k+2];
				}
				k += 2;
			}

			P[i] += (p[k]+p[k+1]);
			if(p[k]==10||p[k]+p[k+1]==10){
				P[i] += p[k+2];
			}
		}

		for(int i=0; i<m-1; i++){
			for(int j=i+1; j<m; j++){
				if(P[i]<P[j]||(P[i]==P[j]&&N[i]>N[j])){
					int tmp = N[i];
					N[i] = N[j];
					N[j] = tmp;

					tmp = P[i];
					P[i] = P[j];
					P[j] = tmp;
				}
			}
		}

		for(int i=0; i<m; i++){
			cout << N[i] << ' ' << P[i] << '\n';
		}
	}

	return 0;
}

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

#define BUF_SIZE 2000000
typedef unsigned char uchar;

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

#define BUCKET_SIZE 200001

int main(void) {
  int num, kind;
  char line[BUF_SIZE];
  FILE* fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  sscanf(line, "%d %d", &num, &kind);

  int i;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  int hist[BUCKET_SIZE] = {0};
  for(i = 0; i < num; i++) {
    char* tmp = strtok(tmpbuf, " ");
    int n = strtol(tmp, NULL, 10);
    hist[n]++;
    tmpbuf = NULL;
  }
  qsort(hist, BUCKET_SIZE, sizeof(int), comp); //descending order

  int sum = 0;
  for(i = kind; i < BUCKET_SIZE; i++) {
    sum += hist[i];
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 3196
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	// 30回ぐらい？

	final double e0 = 8.854187 * 1e-12;// Fm^(-1)
	final double a = 1;// 格子間距離
	final double dt = 0.01;
	double[][][] charge = new double[100000][3][3];
	double[][][] voltage = new double[100000][3][3];
	double thickness = 0.1;
	double k = 1e-3;// ω/k=c,k=ω/c ω=10^12 c=10^8,適当
	double Z = 120 * Math.PI;
	final long MOD = (long) 1e17 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		long[][] dp = new long[N + 1][N * A + 1];
		dp[0][0] = 1;
		int[] x = new int[N];
		for (int i = 0; i < N; ++i) {
			x[i] = sc.nextInt();
		}
		Arrays.sort(x);
		for (int i = 0; i < x.length; ++i) {
			for (int k = dp.length - 2; k >= 0; --k) {
				for (int j = dp[k + 1].length - 1 - x[i]; j >= 0; --j) {
					dp[k + 1][j + x[i]] += dp[k][j];
				}
			}
		}
		long ans = 0;
		for (int i = 1; i <= N; ++i) {
			ans += dp[i][A * i];
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 87632
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	for (int i = 1; i <= 1000; i++) {
		if (i * 8 / 100 == a && i * 10 / 100 == b) {
			cout << i << '\n';
			return 0;
		}
	}
	
	cout << "-1\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;
using std::sort;

int main()
{
    int N;
    vector<int> L;
    int result = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int lnow;
        cin >> lnow;
        L.push_back(lnow);
    }

    sort(L.rbegin(), L.rend());

    for (int i = 0; i < N; i++)
    {
        int a = L[i];
        for (int j = i + 1; j < N; j++)
        {
            int b = L[j];
            int ab = a + b;
            for (int k = j + 1; k < N; k++)
            {
                int c = L[k];
                if (c >= ab){
                    continue;
                }

                if ((a < b + c) && (b < c + a))
                {
                    result++;
                }
            }
        }
    }
    cout << result << endl;
    
    return 0;
}

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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
  vector<vector<edge>>g(100001,vector<edge>(0));
    int n,m;
void dfs(vector<vector<int>>v,vector<int>&dis,int start){
  rep(i,n){
    if(v[start][i]==1){
      if(dis[i]==-1){
        dis[i]=dis[start]+1;
        dfs(v,dis,i);
      }
    }
  }
}
signed main() {
  cin>>n>>m;
  vector<vector<int>>g(n,vector<int>(n));
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a][b]=1;
    g[b][a]=1;
  }
  int ans=0;
  rep(i,n){
    rep(j,n){
      if(g[i][j]==1){
      auto gdash=g;
      gdash[i][j]=0;
      gdash[j][i]=0;
      vector<int>d(n,-1);
      d[0]=0;
      dfs(gdash,d,0);
      rep(k,n){
        if(d[i]==-1){ans++;break;}
      }
    }
  }
}
  cout<<ans<<endl;
}


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

#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

void solveTest(){
	
}

int main(){
	fastio();
	//input();

	/*int t;
	cin>>t;
	while(t--){
		solveTest();
	}*/

	string a,b;
	cin>>a>>b;
	a+=b;
	int x = stoi(a);
	long double y = x;
	long double sr = sqrt(y);
	if(sr==floor(sr)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}


	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    ios::sync_with_stdio( false );
    int t , n ;
    cin >> t >> n;
      if((t %( n*2 +1)) ==0)
      {
          cout << (t /( n*2 +1)  ) << endl;
      }
  else {
  cout << (t/( n*2 +1)  ) +1 << endl;
  }
    
}

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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n, m, ans=0;

      n = Integer.parseInt(sc.next());
      m = Integer.parseInt(sc.next());

      int a[] = new int[m];

      for(int i=0; i<n; i++){
        int k = Integer.parseInt(sc.next());
        for(int j=0; j<k; j++){
          int ij = Integer.parseInt(sc.next());
          a[ij-1]++;
        }
      }
      
      for(int i=0; i<m; i++){
        if(a[i]==n){
          ans++;
        }
      }

      System.out.println(ans);
    }
    catch (Exception e) {
    }
  }
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    string str;
    cin >> str;
    vector<int> Enum(N, 0);
    vector<int> Wnum(N, 0);
    for(int n=0; n<N; n++) {
        if(n>0) {
            Wnum[n] += Wnum[n-1];
            Enum[N-1-n] += Enum[N-n];
            
            if(str[n-1]=='W') Wnum[n]++;
            if(str[N-n]=='E') Enum[N-1-n]++;
        }
    }
    
    int ans=N;
    for(int n=0; n<N; n++) {
        ans = min(ans, Wnum[n]+Enum[n]);
    }
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3076
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int a[200000];
int b[200000];
int c, d;

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

	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)b[i] = a[i];
	sort(b, b + n);
	c = b[n / 2 - 1];
	d = b[n / 2];


	rep(i,n) {
		if (a[i] <= c) {
			cout << d << endl;
		}
		else {
			cout << c << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int M = 15 + 5;
int a[M][M];
int dist[M];
int main(){
	int n;
	scanf("%d",&n);
	memset(a,-1,sizeof(a));
	for(int i = 1; i <= n; i++){
		int m;
		scanf("%d",&m);
		for(int j = 0; j < m;j++){
			int x,y;
			scanf("%d%d",&x,&y);
			a[i][x] = y;
		}
	}
//	for(int i = 1; i <= n; i++){
//		printf("%d\n",i);
//		for(int j = 1; j <= n; j++){
//			printf("%d %d\n",j,a[i][j]);
//		}
//	}
	int ans = 0;
//	printf("%d\n",(1<<(n-1)));
	for(int i = 0; i < (1<<n);i++){
		int s = i;
		int wz = 1;
		int sum = 0;
		memset(dist,0,sizeof(dist));
		while(s){
			if(s&1){
				dist[wz] = 1;
				sum++;	
			}
			else{
				dist[wz] = 0;
			}
			s>>=1;
			wz++;
		}
		int f = 0;
		for(int j = 1; j <= n; j++){
			if(dist[j]){
				for(int k = 1; k <= n; k++){
					if(a[j][k] != -1 && dist[k] != a[j][k]){
						f = 1;
						break;
					}
				}
			}
			if(f)break;
		}
		if(f == 0){
			ans = max(ans,sum);
//			cout<<i<<endl;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n; cin >> n;
  long long sum = 0;
  vector<long long> a(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  long long ans = 1e15;
  long long l = 0;
  for(int i=0; i<n; i++) {
    l += a[i];
    long long r = sum - l;
    ans = min(ans, abs(l-r));
  }
  cout << ans << endl;

  return 0;
}

// EOF


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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



void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


// 繰り返し二乗法
ll power(ll a, ll b){
  if(a==1)return a;
  // if(a==0)re
  ll res=1;
  while(b>0){
    if(b&1) res=res*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return res;
}

const int MAX=2100000;
 
ll fact[MAX], fact_inv[MAX];
 
void init_fact(ll n){
  fact[0]=1;
  // 階乗の計算
  rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
  fact_inv[n]=power(fact[n], MOD-2);
  // 逆元の計算
  for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll r){
  return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
 
ll perm(ll n, ll r){
  return (fact[n]*fact_inv[n-r])%MOD;
}






int main() {
  cout<<fixed<<setprecision(10);


  ll n; cin>>n;
  vint a(n); rep(i,n) cin>>a[i];

  map<ll,ll> m;
  for(auto e:a) m[e]++;

  ll ans = 0;
  for(auto p:m){
    ans += p.second*(p.second-1)/2;
  }


  for(auto e:a){
    if(m[e] == 1){
      cout<<ans<<endl;
      continue;
    }

    ll tmp = ans - m[e]*(m[e] - 1)/2 + (m[e]-1)*(m[e]-2)/2;
    cout<<tmp<<endl;
  }

}






Measured memory_bytes: 11136
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&a!=c||a==c&&a!=b||b==c&&b!=a){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int num = 0;
  char color = S.at(0);
  for (int i = 0; i < N -1; i++) {
    if (color == S.at(i+1)) {
      continue;
    }
    else {
      color = S.at(i+1);
      num++;
    }
  }
  num++;
  cout << num << endl;
}

    



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/math/common_factor.hpp>
using namespace std;
 
template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 
 
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
 
}comp_functor;

 
int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int i,j,t,n,m,l,q,ans=1,f=0,x,temp,h[200005]={0},a,b,c,d;
    
    string s1,s2;
    
    vector<pair<long long,long long>>v;
    
    cin>>n>>m;
    
    for(i=0;i<m;i++)
    {
        cin>>c>>d;
        
        v.push_back(make_pair(c,d));
    }
    
    sort(v.begin(),v.end());
    
    a=v[0].first;
    b=v[0].second;
    
    for(i=1;i<m;i++)
    {
        
        c=v[i].first;
        d=v[i].second;
        
        if(b<=c)
        {
            ans++;
            a=c;
            b=d;
        }
        else if(a>=d)
        {
            ans++;
            a=c;
            b=d;
        }
        else
        {
            a=min(a,c);
            b=min(b,d);
        }
    }
    
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF=1e18+10;
const int inf=1e9+10,dx[]= {0,0,1,-1,1,-1,1,-1},dy[]= {1,-1,0,0,1,1,-1,-1};
ll MOD=1e9+7;
ld eps=1e-7,pi=acos(-1);

int n,k,a[100100][3];

int mem[100100][5];

int solve(int i,int step)
{
if(i==n)return 0;

if(mem[i][step]!=-1)return mem[i][step];
int res=0;

for(int j=0;j<3;j++)
if(j!=step)
{
res=max(res,a[i][j]+solve(i+1,j));
}


return mem[i][step]=res;
}

int main()
{

scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);

memset(mem,-1,sizeof mem);

//for(int i=n-1;i>=0;i--)
//solve(i,0);

printf("%lld\n",solve(0,4));

return 0;
}


Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

bool kr_cmp(const edge& l, const edge& r) { return l.w < r.w; }

ll kruskal(int N, vector<edge> E) {
	sort(E.begin(), E.end(), kr_cmp);
	union_find uf(N);
	ll sum = 0;
	for (edge e: E)
		if (!uf.same(e.u, e.v)) {
			uf.unite(e.u, e.v);
			sum += e.w;
		}
	return sum;
}


int main() {
	int N, M; cin >> N >> M;
	vector<edge> E(M);
	for (int i = 0; i < M; i++) {
		int u, v, w; scanf("%d%d%d", &u, &v, &w);
		E[i] = edge{u, v, w};
	}
	cout << kruskal(N, E) << endl;
}

Measured memory_bytes: 6100
import qualified Data.IntMap as M

groups = [[1,3,5,7,8,10,12], [4,6,9,11], [2]]

solve :: [Int] -> String
solve (a:b:_)
  | m M.! a == m M.! b = "Yes"
  | otherwise = "No"
  where
    m = M.fromList $ concatMap (\(i, l) -> map (\y -> (y,i)) l )$ zip [0..] groups

main = getContents >>= putStrLn.solve.map read.words.last.lines


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)
 
#define INF 1e9
 
int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<int> cnt(61, 0);
  REP(i, N){
    REP(j, 61){
      cnt[j] += A[i] >> j & 1;
    }
  }
  ll ans = 0, sum = 0;
  REPR(i, 60){
    if(N-cnt[i] > cnt[i] && ans+(1LL<<i) <= K){
      ans += 1LL<<i;
      sum += (N-cnt[i]) * 1LL<<i;
    }
    else{
      sum += cnt[i] * 1LL << i;
    }
  }
  // cout << ans << endl;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    int size = s.size();

    if (s == t.substr(0, size))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < n; i++)

using namespace std;


const int MX = 200005;

int dp[MX];

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

    int n;
    cin>>n;
    vector<int> h(n);

    forn(i, n){
        cin>>h[i];
    }

    dp[0] = 0;

    for(int i = 1; i < n; i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i >= 2){ 
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }

    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024