akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A==B && B!=C){
        cout << "Yes";
    }
    
   else if(A!=B && B==C){
        cout << "Yes";
    }
    else 
    if(A==C && B!=C){
        cout << "Yes";
    }
    else cout << "No";
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <cctype>
#include <deque>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {

	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}

		out << "\n";
	}
		
    return out;

}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	int left = n;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i - 1]) 
			--left;
	}

	cout << left << "\n";

	return 0;

}

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

int main(){
    string num;
    cin >> num;
    
    if(num[num.length()-1]=='2' || num[num.length()-1]=='4'|| num[num.length()-1]=='5'|| num[num.length()-1]=='7'|| num[num.length()-1]=='9'){
    cout <<"hon";	
	}
	else if(num[num.length()-1]=='0'||num[num.length()-1]=='1'||num[num.length()-1]=='6'||num[num.length()-1]=='8'){
		cout <<"pon";
	}
	else{
		cout <<"bon";
	}
    
}


Measured memory_bytes: 3628
import numpy as np

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
XY = np.array(xy).flatten()

X = XY[::2] ; Y = XY[1::2]

dx = X[:,None] - X[None, :]
dy = Y[:, None] - Y[None,:]

dist_mat = (dx*dx + dy*dy) ** .5

answer = dist_mat.sum() / N
print(answer)


Measured memory_bytes: 27228
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
int main(){ 
    ll n;
    cin>>n;
    vector<ll> a(n-1);
    REP(i,n-1) cin>>a[i];
    ll b=a[0]+a[n-2];
    REP(i,n-2){
        b+=min(a[i],a[i+1]);
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# map(int, input().split())
from collections import deque

class Node():
    def __init__(self, idx):
        self.idx = idx
        self.next_node = []
        self.is_searched = False
    
    def add_node(self, node):
        self.next_node.append(node)

N, M = map(int, input().split())
nodes = {n+1: Node(n+1) for n in range(N)}

for m in range(M):
    A, B = map(int, input().split())
    nodes[A].add_node(nodes[B])
    nodes[B].add_node(nodes[A])

# 幅優先で友達クラスターを作る
clusters = []
for i in range(N):
    que = deque([nodes[i+1]])
    cluster = []
    while len(que) != 0:
        node = que.pop()
        if not node.is_searched:
            cluster.append(node)
            que.extend(node.next_node)
            node.is_searched = True

    clusters.append(cluster)

print(max([len(cluster) for cluster in clusters]))

Measured memory_bytes: 154520
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n, k; cin >> n >> k;
  vector <int> a(n);
  for(auto &x: a) cin >> x;
  sort(all(a));
  a.resize(k);
  cout << accumulate(all(a), 0) << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		double R=sc.nextDouble();
		System.out.println(2*R*Math.PI);
	}
	
	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: 33076
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N;
	cin >> N;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i*j == N){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
  int l, r, largest, tmp;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

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

  for(int i = 1; i <= H; i++) {
    scanf("%d", &A[i]);
  }

  for(int i = H / 2; i >= 1; i--) {
    maxHeapify(i);
  }

  for(int i = 1; i <= H; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    vector<char> c;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != 'B') c.push_back(s[i]);
        else if (c.empty()) continue;
        else c.pop_back();
    }
    for (auto x : c) cout << x << "";
    cout << "" << std::endl;
    return 0;
}

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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int a = ReadAndParseInt();
            int b = ReadAndParseInt();
            int c = ReadAndParseInt();
            int d = ReadAndParseInt();

            int ans = Math.Min(a, b) + Math.Min(c, d);
            Console.WriteLine(ans);
        }
        
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    ll a,b;cin>>a>>b;
    ll ans=max(a-b,max(a+b,a*b));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N = 100010;

char s[N];

int main()
{
int aa;
    scanf("%s", s);
    int cnt = 0, len = strlen(s);
    for (int i = 1; i < len; i++)
        if (s[i] != s[i - 1])
            cnt ++;
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M, C;
	cin >> N >> M >> C;
	VLL B(M);
	in(B);
	LL ans = 0;
	for (LL n = 0; n < N; n++) {
		LL temp = 0;
		for (LL m = 0; m < M; m++) {
			LL A;
			cin >> A;
			temp += B[m] * A;
		}
		if (temp + C > 0)ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
dic = {'A':A,'B':B,'C':C}
S = [input() for _ in range(N)]

def solve(N,dic,S):
    ans = ['Yes']
    for i in range(N):
        if dic[S[i][0]]>dic[S[i][1]]:
            dic[S[i][0]]-=1
            dic[S[i][1]]+=1
            ans.append(S[i][1])
        elif dic[S[i][0]]<dic[S[i][1]] or dic[S[i][0]]>1:
            dic[S[i][1]]-=1
            dic[S[i][0]]+=1
            ans.append(S[i][0])
        elif dic[S[i][0]]==0:
            return ['No']
        elif i==N-1:
            dic[S[i][0]]+=1
            dic[S[i][1]]-=1
            ans.append(S[i][0])
        else:
            if S[i][0] in S[i+1]:
                dic[S[i][0]]+=1
                dic[S[i][1]]-=1
                ans.append(S[i][0])
            else:
                dic[S[i][1]]+=1
                dic[S[i][0]]-=1
                ans.append(S[i][1])
    return ans
print(*solve(N,dic,S),sep='\n')

Measured memory_bytes: 17652
N,M=map(int,input().split())
A=[0 for i in range(N)]
flg=0

for i in range(M):
    s,c=map(int,input().split())
    if A[s-1]!=0 and A[s-1]!=c:
        flg=1
    if s==1 and c==0 and N!=1:
        flg=1
    if flg==0:
        A[s-1]=c

if flg==1:
    print(-1)
else:
    if A[0]==0:
        if N!=1:
            A[0]=1
    print(''.join(map(str,A)))

Measured memory_bytes: 3064
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int L=128,C=62;
int diff,edit[63]={0},sz[126]={0},pw[126][128];
static inline int decode(int x){return x<=26?64+x:(x<=52?96-26+x:48+x-52-1);}
static inline int ask(int u,int i,int j)
{
  int len=diff;
  printf("? ");rep(k,sz[u]){len--;putchar(decode(pw[u][k]));}len--;putchar(decode(pw[u<<1][i]));
  rep(k,sz[u<<1|1]-j){len--;putchar(decode(pw[u<<1|1][k+j]));}puts("");fflush(stdout);
  int res;if(scanf("%d",&res)!=0)return res==len;else return -1;
}
static inline void solve(int u,int le,int ri)
{
  if(le==ri){sz[u]=edit[le];rep(i,edit[le]){pw[u][i]=le;}return;}
  int mid=(le+ri)>>1;
  solve(u<<1,le,mid);solve(u<<1|1,mid+1,ri);
  for(int i=0,j=0;i<sz[u<<1]||j<sz[u<<1|1];)
  {
    if(i<sz[u<<1]&&(j==sz[u<<1|1]||ask(u,i,j))){pw[u][sz[u]++]=pw[u<<1][i];i++;}
    else{pw[u][sz[u]++]=pw[u<<1|1][j];j++;}
  }
}
int main(void)
{
  rep(i,C)
  {
    printf("? ");rep(j,L){putchar(decode(i+1));}puts("");fflush(stdout);
    int res;if(!scanf("%d",&res))return -1;
    edit[i+1]=L-res;diff+=L-res;
  }
  solve(1,1,C);
  printf("! ");rep(i,sz[1])putchar(decode(pw[1][i]));puts("");fflush(stdout);
  return 0;
}

Measured memory_bytes: 3800
fun main(args: Array<String>) {
  val n: Int = readLine()!!.toInt()
  val list: MutableList<List<Int>> = mutableListOf()
  for (i in 1..n) {
    list.add(readLine()!!.split(" ").map { it.toInt() })
  }
  var answer: String = "No"
  for (i in 0..list.size - 3) {
    var one: Boolean = false
    var two: Boolean = false
    var three: Boolean = false
    if (list[i][0] == list[i][1]) one = true
    if (list[i + 1][0] == list[i + 1][1]) two = true
    if (list[i + 2][0] == list[i + 2][1]) three = true
    if (one && two && three) {
      answer = "Yes"
      break
    }
  }
  println(answer)
}

Measured memory_bytes: 37860
N=int(input())
x=int((-1+(1+8*N)**0.5)/2)


if x*(x+1)/2==N:

    for i in range(x):
        print(i+1)
    exit()
else:
    print(x+1)
    N -= (x+1)

    for i in range(x,0,-1):
        if N-i>=0:
            print(i)
            N -= i


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A,A+N);
	for(int i=0;i+1<N;i+=2)
	{
		if(A[i]+A[i+1]<0)
		{
			A[i]*=-1;
			A[i+1]*=-1;
		}
	}
	long ans=0;
	for(int i=0;i<N;i++)ans+=A[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n, a, r;
    std::cin >> n >> a;
    r = n % 500;
    if (r == 0)
    {
        std::cout << "Yes" << std::endl;
        return 0;
    }
    if (r <= a) { std::cout << "Yes" << std::endl; }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  rep(i, 1e5) {
    ll now = i * (i + 1) / 2;
    if(now >= x) {
      cout << i << endl;
      return 0;
    }
  }
}

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

int Euler_Phi(int n){
      int res = n;
      for(int i=2; i*i <= n;  i++){
            if(n%i == 0) {
                  res  = res / i * (i-1);
                  while(n%i == 0) n /= i;
            }
      }
      if(n!=1) res = res / n * (n-1);
      return res;
  
}
  
int main(){
      int n; cin >> n;
      cout << Euler_Phi(n) << endl;
  
}

Measured memory_bytes: 3100
#include <cstdio>
#include <vector>
#include <forward_list>

using namespace std;


int cnt = 0;
int cntp = 0;
vector<int> pre;
vector<int> post;

int DAG = 1;

class Edge{
public:
  int v;
  int w;
  Edge(int vi,int wi):v(vi),w(wi){;}
};

class Graph{
public:
    int V;
    int E;
    vector<vector<bool>> adj_matrix;
    Graph(int v,int e):V(v),E(e){
        adj_matrix.resize(V);
        pre.resize(V);post.resize(V);
        for(int i = 0; i < V;i++) {adj_matrix[i].resize(V);pre[i] = -1;post[i] = -1;}
        for(int i = 0; i < V;i++){
            for(int j = 0; j < V;j++)
                adj_matrix[i][j] = false;
        }
    }
    void dfsR(Edge e);
    void addEdge(int v,int w){adj_matrix[v][w] = true;}
};


void Graph::dfsR(Edge e){
    int w = e.w;
    pre[e.w] = cnt++;
    for(int i = 0; i < V;i++){
        if(pre[i] == -1 && adj_matrix[w][i]){
            dfsR(Edge(e.w,i));
        }
        else{
            if(pre[i] < pre[w] && adj_matrix[w][i] && post[i] == -1)
                DAG = 0;
        }
    }
    post[e.w] = cntp++;
}


void solution(Graph &G){
    for(int i = 0; i < G.V;++i){
        if(pre[i] == -1 && DAG)
            G.dfsR(Edge(i,i));
    }
}

int main(void){
    int V,E;
    scanf("%d %d",&V,&E);
    Graph G(V,E);
    int v,w;
    for(int i = 0; i < E;i++){
        scanf("%d %d",&v,&w);
        G.addEdge(v,w);
    }
    solution(G);
    printf("%d\n",1-DAG);
    return 0;
}


Measured memory_bytes: 2708
<?php
fscanf(STDIN, "%d", $N);

$paper = array();

for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d", $A);
    if (!isset($paper[$A]) || $paper[$A] == 0) {
        $paper[$A] = 1;
    } else {
        $paper[$A] = 0;
    }
}

echo array_sum($paper) . PHP_EOL;


Measured memory_bytes: 13048
s =list(input())
data = []
for i in range(len(s)):
    if s[i]=='0':
        data.append('0')
    elif s[i]=='1':
        data.append('1')
    elif s[i] =='B':
        if len(data)>0:
            data.pop()
            
for i in data:
    print(i,end="")
        

Measured memory_bytes: 3060
MOD = 10 ** 9 + 7

N, M = map(int, input().split())

def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    import math
    dic = dict()
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] = count
    if k != 1: #sqrt(k)までチェックしてもkが1になっていない --> kが素因数
        dic[k] = 1
    return dic

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0




C = Factorial(N + 100, MOD).comb

ans = 1
dic = factoring(M)
for tmp in dic:
    # print (tmp, dic[tmp])
    ans *= C(dic[tmp] + N - 1, dic[tmp])
    ans %= MOD

print (ans)




Measured memory_bytes: 11096
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
		int H = in.nextInt();
		int W = in.nextInt();
		if(H==0&&W==0){
			break;
		}
		for(int i = 0; i<H ; i++){
			for(int j = 0; j<W ; j++){
				if((i==0||j==0)||(i==H-1||j==W-1)){
					System.out.print("#");
				}else{
					System.out.print(".");
					}
						}
					System.out.println();
							}
						System.out.println();
				}
			}
		}

Measured memory_bytes: 32596
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	
	sort(a, a + n);

	int l = a[n / 2 - 1], r = a[n / 2];
	
	cout << r - l;

	return 0;
}

Measured memory_bytes: 640
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 200 * 1001;
int n, a[N], res[N];
long long sum, xo, ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int p1 = 0, p2 = 0;
	while (p1 < n) {
		bool bad = false;
		while (p2 < n) {
			sum += a[p2];
			xo ^= a[p2];
			if (sum != xo) {
				res[p1] = max(res[p1 - 1], p2 - 1);
				sum -= (a[p1] + a[p2]);
				xo = sum;
				bad = true;
				break;
			}
			else if (sum == xo && p2 == n - 1 && !bad) {
				res[p1] = p2;
				break;
			}
			else
				p2++;
		}
		p1++;
//		cout << p2 << "  " << sum << " " << " */ \n";
	}
	for (int i = 0; i < n; i++) {
//		cout << res[i] << "  --- ";
		ans += (res[i] - i + 1);
	}
	cout << ans << endl;
}
				

Measured memory_bytes: 1920
function main(input) {
  const lines = input.split("\n");
  const [N, M] = lines[0].split(' ').map(Number);
  const a = lines[1].split(' ').map(Number);

  const total = a.reduce((acc, current) => acc + current);
  const border = total / (4 * M);
  let count = 0;
  a.forEach(n => {
    if (n < border) return;
    count++;
  });

  console.log(count < M ? 'No' : 'Yes');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
public class Main {


  private static void solve() {
    int m = ni();
    int k = ni();
    
    if (k >= (1 << m) || m == 1 && k == 1) {
      System.out.println(-1);
      return;
    }
    
    StringBuilder sb = new StringBuilder();
    if (k == 0) {
      for (int i = 0; i < (1 << m); i++) {
        sb.append(i + " ");
      }
      for (int i = (1 << m) - 1; i >= 0; i--) {
        sb.append(i + " ");
      }
      
    } else {

      for (int i = 0; i < (1 << m); i++) {
        if (i == k) continue;
        sb.append(i + " ");
      }
      sb.append(k + " ");
      for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i == k) continue;
        sb.append(i + " ");
      }
      sb.append(k);
      
    }
    System.out.println(sb.toString());


  }


  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 47200
#include<iostream>
using namespace std;
int main(){
  	int N;
  	int d[110];
  	cin>>N;
  	for(int i=0;i<N;++i){
    	cin>>d[i];
  	}
	int num[110] = {0};  
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  
    }

    int res = 0;  
    for (int i = 1; i <= 100; ++i) {  
        if (num[i]) {  
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,k;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
			if(n*m-i*j-(n-i)*(m-j)==k)
			{
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
N, W = map(int, input().split())
Items = [tuple(map(int, input().split())) for _ in range(N)]
DP = [-1] * (W + 1)
DP[0] = 0

for w, v in Items:
    D = DP[:]
    for i, d in enumerate(DP):
        if d < 0:
            continue
        if i + w > W:
            break
        D[i + w] = max(D[i + w], d + v)
    DP = D
print(max(DP))

Measured memory_bytes: 146352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef double ld;
#define X first
#define Y second
#define mk make_pair
#define pb push_back
#define Rep(i, n) for(int i = 0; i < int(n); i ++)
#define Rep1(i, n) for(int i = 1; i <= int(n); i ++)
#define all(x) (x).begin(), (x).end()
const int MOD = (int) 1e9 + 7;
const ll base =  31;
void MAIN();
int main(){
    //freopen("input.txt", "r", stdin);
    ios:: sync_with_stdio(false); cin.tie(0);
    MAIN();
    return 0;
}
////////////////////////////////////////////////////////////////////////

const int N = 100032;

int n, m, k, p, ans[N];
vector <ii> G[N], Q[N];
int d[N];
ii x[N];
vector <int> in[N];
int par[N], sz[N], cur;

int Find(int u){
    if(u == par[u]) return u;
    return par[u] = Find(par[u]);
}

void Union(int u, int v){
    u = Find(u); v = Find(v);
    if(u == v) return;
    if(sz[u] >= sz[v]) swap(u, v);
    Rep(i, in[u].size()){
        int a = in[u][i];
        in[v].pb(a);
        Rep(j, Q[a].size()){
            int b = Q[a][j].X;
            if(Find(b) == v){
                ans[Q[a][j].Y] = cur;
            } else if(Find(b) == u){
                swap(Q[a][j], Q[a].back());
                j --;
                Q[a].pop_back();
            }
        }
    }
    in[u].clear();
    sz[v] += sz[u];
    par[u] = v;
}

void MAIN(){
    cin >> n >> m >> k >> p;
    while(m --){
        int u, v, c;
        cin >> u >> v >> c;
        G[u].pb(ii(v, c));
        G[v].pb(ii(u, c));
    }
    priority_queue <ii> q;
    memset(d, 0x3f, sizeof d);
    while(k --){
        int u;
        cin >> u;
        d[u] = 0;
        q.push(ii(d[u], u));
    }
    while(!q.empty()){
        int u = q.top().Y, r = -q.top().X;
        q.pop();
        if(d[u] != r) continue;
        Rep(i, G[u].size()){
            int v = G[u][i].X, c = G[u][i].Y;
            if(d[v] > d[u] + c){
                d[v] = d[u] + c;
                q.push(ii(-d[v], v));
            }
        }
    }
    for(int i = 1; i <= n; i ++){
        x[i] = ii(-d[i], i);
        par[i] = i;
        sz[i] = 1;
        in[i].pb(i);
    }
    Rep(i, p){
        int s, t;
        cin >> s >> t;
        if(s == t) ans[i] = d[s];
        else {
            Q[s].pb(ii(t, i));
            Q[t].pb(ii(s, i));
        }
    }
    sort(x + 1, x + n + 1);
    memset(ans, 0xff, sizeof ans);
    for(int i = 1; i <= n; i ++){
        cur = -x[i].X;
        int u = x[i].Y;
        Rep(i, G[u].size()){
            int v = G[u][i].X;
            if(d[v] < d[u]) continue;
            Union(u, v);
        }
    }
    Rep(i, p) cout << ans[i] << "\n";
}

Measured memory_bytes: 24624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int solution = 0;
		int i = 0;
		while(scanner.hasNext()) {
			if(scanner.nextInt() == 0)
				solution = i + 1;
			i++;
		}
		System.out.print(solution);
		
	}
}


Measured memory_bytes: 26908
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

string s;
int a, b, x;

int main() {
	cin >> a >> b >> x;
	if((x - a < 0) || (a + b < x)) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
E = []
for _ in range(n):
    E.append(list(map(int, input().strip().split())))

class Node:
    def __init__(self, n):
        self.data = n
        self.parent = self
        self.rank = 0
    def find(self):
        if self.parent.data == self.data:
            return self
        else:
            ret = self.parent.find()
            self.parent = ret
            return ret
    def union(self, rhs):
        lhs = self
        lhs_root = lhs.find()
        rhs_root = rhs.find()
        if lhs_root.rank > rhs_root.rank:
            rhs_root.parent = lhs
        elif rhs_root.rank > lhs_root.rank:
            lhs_root.parent = rhs
        elif lhs_root.data != rhs_root.data:
            lhs_root.parent = rhs_root
            rhs_root.rank += 1
    def is_same(self, rhs):
        lhs = self
        return lhs.find().data == rhs.find().data

V = [Node(i) for i in range(n)]
inf = 2005

for i in range(n):
    for j in range(n):
        E[i][j] = [E[i][j], i, j, 0 if E[i][j] != -1 else inf]
min_op = lambda n: n[0] + n[3]

remain = n-1
sum_w = 0
while remain > 0:
    min_edge = min([min(E[i], key=min_op) for i in range(n)], key=min_op)
    w, i, j, _ = min_edge
    E[i][j][3] = E[j][i][3] = inf
    if not V[i].is_same(V[j]):
        V[i].union(V[j])
        sum_w += w
        remain -= 1
print(sum_w)




















Measured memory_bytes: 6840
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N,A;

  cin>>N>>A;

  cout<<N*N-A<<endl;
  
  
  return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;
int main() {
  int n, q, time, t = 0;
  string name;
  queue<pair<string, int> > p;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> name >> time;
    p.push(pair<string, int>(name, time));
  }
  while (!p.empty()) {
    pair<string, int> a = p.front();
    p.pop();
    a.second -= q;
    t += q;
    if (a.second <= 0) {
      t += a.second;
      cout << a.first << " " << t << endl;
    } else {
      p.push(a);
    }
  }
  return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <algorithm>
#define rep(i, n) for (i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k, inX, inY; char c;
int rui[2][4002][4002];		//rui[type][x][y]

int getSum(int type, int lx, int rx, int ly, int ry) {
	return rui[type][rx][ry] - rui[type][rx][ly] - rui[type][lx][ry] + rui[type][lx][ly];
}

signed main() {
	int i, j;
	
	cin >> n >> k;
	rep(i, n) {
		cin >> inX >> inY >> c;
		inX %= 2 * k;
		inY %= 2 * k;
		if (c == 'B') {
			rui[0][inX + 1][inY + 1]++;
			rui[0][inX + 2 * k + 1][inY + 1]++;
			rui[0][inX + 1][inY + 2 * k + 1]++;
			rui[0][inX + 2 * k + 1][inY + 2 * k + 1]++;
		}
		else {
			rui[1][inX + 1][inY + 1]++;
			rui[1][inX + 2 * k + 1][inY + 1]++;
			rui[1][inX + 1][inY + 2 * k + 1]++;
			rui[1][inX + 2 * k + 1][inY + 2 * k + 1]++;
		}
	}
	
	for (i = 1; i <= 4 * k; i++) {
		for (j = 1; j <= 4 * k; j++) {
			rui[0][i][j] += rui[0][i][j - 1];
			rui[1][i][j] += rui[1][i][j - 1];
		}
	}
	
	for (j = 1; j <= 4 * k; j++) {
		for (i = 1; i <= 4 * k; i++) {
			rui[0][i][j] += rui[0][i - 1][j];
			rui[1][i][j] += rui[1][i - 1][j];
		}
	}
	
	//平行移動を全探索
	int ans = 0;
	for (i = 0; i < 2 * k; i++) {
		for (j = 0; j < 2 * k; j++) {
			int a = getSum(0, i, i + k, j, j + k);
			int b = getSum(1, i, i + k, j + k, j + 2 * k);
			int c = getSum(1, i + k, i + 2 * k, j, j + k);
			int d = getSum(0, i + k, i + 2 * k, j + k, j + 2 * k);
			int black = a + d;
			int white = b + c;
			ans = max(ans, black + white);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 250496
import Data.List hiding (insert)

putListLn :: Show a => [a] -> IO ()
putListLn = putStrLn . unwords . map show

getList :: Read a => IO [a]
getList = fmap (map read . words) getLine

insert x [] = [x]
insert x (y:ys)
   | x <= y     = x:y:ys
   | otherwise = y:(insert x ys)

isortStates :: Ord a => [a] -> [[a]]
isortStates l = tail $ zipWith (++) (scanl (flip insert) [] l) (tails l)

main :: IO ()
main = do
  _ <- getLine
  ns <- getList :: IO [Int]
  mapM_ putListLn $ isortStates ns

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    vp data(3);
    rep(i, 3) {
        int2(a, b);
        data[i].fir = min(a, b);
        data[i].sec = max(b, a);
    }

    for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= 4; j++) {
            if (i == j) continue;
            for (int k = 1; k <= 4; k++) {
                if (i == k || j == k) continue;
                for (int l = 1; l <= 4; l++) {
                    if (i == l || j == l || k == l) continue;
                    //cout << i << " " << j << " " << k << " " << l << endl;
                    bool fl = false;
                    rep(p, data.size()) {
                        if (data[p].fir == min(i, j) && 
                                data[p].sec == max(i, j)) {
                            fl = true;
                            break;
                        }
                    }
                    if (!fl) continue;
                    fl = false;
                    rep(p, data.size()) {
                        if (data[p].fir == min(k, j) && 
                                data[p].sec == max(k, j)) {
                            fl = true;
                            break;
                        }
                    }
                    if (!fl) continue;
                    fl = false;
                    rep(p, data.size()) {
                        if (data[p].fir == min(k, l) && 
                                data[p].sec == max(k, l)) {
                            fl = true;
                            break;
                        }
                    }
                    if (!fl) continue;
                    else {
                        cout << "YES" << endl;
                        return 0;
                    } 
                }
            }
        }
    }

    cout << "NO" << endl;





    return 0;
}


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

using namespace std;

int main(void)
{
	int n;
	int a[200005];
	
	cin >> n;
	for(int i = 0; i < n;i++){
		cin >> a[i];
	}
	
	vector<int> vec;
	
	for(int i = 0; i < n; i++){
		if(i % 2 == 0) vec.push_back(a[i]);
		else vec.insert(vec.begin(), a[i]);
	}
	
	if(n % 2) reverse(vec.begin(), vec.end());
	for(int i = 0; i < (int)vec.size(); i++) cout << vec[i] << " ";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>x;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    rep(i,n){
        if(i==n-1){
            if(x==a[i])cnt++;
            else break;
        }
        else{
        if(x>=a[i]){
        x-=a[i];
        cnt++;
        }
        else{
            break;
        }
        }
    }
    Cout(cnt);
    return 0;
}


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

int main()
{
    int N,M;
    cin >> N >> M;
    
    vector<vector<int>> ab(M, vector<int>(2));
    vector<vector<int>> ba(M, vector<int>(2));
    for (int i=0; i<M; i++)
    {
        int x, y;
        cin >> x >> y;
        ab[i][0] = x;
        ab[i][1] = y;
        ba[i][0] = y;
        ba[i][1] = x;
    }

    vector<int> order(N-1);
    for (int i=2; i<=N; i++) order[i-2]=i;
    
    int ans=0;
    do
    {
        vector<int> tmp_order(order);
        tmp_order.insert(tmp_order.begin(), 1);

        vector<vector<int>> path(N-1, vector<int>(2));

        bool ok=true;
        for (int i=0; i<N-1; i++)
        {
            path[i][0] = tmp_order[i];
            path[i][1] = tmp_order[i+1];
            if (find(ab.begin(), ab.end(), path[i]) == ab.end() && find(ba.begin(), ba.end(), path[i]) == ba.end())
            {
                ok=false;
                break;
            }
        }
        if (ok) ans++;
        

    } while (next_permutation(order.begin(), order.end()));

    cout << ans << endl;
}

Measured memory_bytes: 3604
s=gets.chomp.split("")
t=gets.chomp.split("")
def check(s,t,i)
	flag=true
	(s.size).times do|k|
		if(i==(t.size))
			i=0
		end
		if(s[k]!=t[i])
			flag=false
			break
		end
		i+=1
	end	
	return flag
end
flag=false
(t.size).times do|i|
	if(t[i]==s[0])
		flag=check(s,t,i)
		break if(flag)
	end
end
puts(flag ? "Yes" : "No")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  int no_of_input;
  vector<int> vect1;
  int input;
  cin >> no_of_input;
  for(int i=0;i<no_of_input;i++){
    cin >> input;
    vect1.push_back(input);
  }
  int ans = 0;
  for(int i=0;i<no_of_input;i++){
    for(int j=i+1;j<no_of_input;j++){
      ans += vect1[i]*vect1[j];
    }
  }
  cout << ans;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;
  std::sort(a.begin(), a.end());

  if (n % 2 == 0) {
    for (int64_t i = 0; i < n; i++) {
      if (a[i] != ((i % 2 == 0) ? i + 1 : i)) {
        std::cout << 0 << std::endl;
        return 0;
      }
    }
    int64_t ans = 1;
    for (int64_t i = 0; i < n / 2; i++) {
      ans *= 2;
      ans %= 1000000007;
    }
    std::cout << ans << std::endl;
  } else {
    if (a[0] != 0) {
      std::cout << 0 << std::endl;
      return 0;
    }
    for (int64_t i = 1; i < n; i++) {
      if (a[i] != ((i % 2 == 1) ? i + 1 : i)) {
        std::cout << 0 << std::endl;
        return 0;
      }
    }
    int64_t ans = 1;
    for (int64_t i = 0; i < (n - 1) / 2; i++) {
      ans *= 2;
      ans %= 1000000007;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();

    if(str.equals("ABC")) {
      System.out.println("ARC");
    }
    else {
      System.out.println("ABC");
    }
  }
}
   

Measured memory_bytes: 35748
N,M,X,Y = map(int, input().split())

xa = list(map(int, input().split()))

ya = list(map(int, input().split()))

f=-1

ma = max(xa)
mi = min(ya)

for i in range(X+1,Y+1):
    if ma<i and i<=mi:
        f=1
        
if f>0:
    print("No War")
else:
    print("War")
    

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] dp = new long[N + 1];
    dp[0] =2;
    dp[1] =1;
    for (int i=2; i<=N; i++) {
      dp[i] = dp[i-1] + dp[i-2];
    }
      System.out.println(dp[N]);
  }
}

Measured memory_bytes: 22868
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li n; cin >>n;
  li ans=0;
  rep(_i,n){
    int i=_i+1;
    rep(j,n+1){
      if(i*j>n) break;
      ans+=i*j;
    }
  }
  print(ans);
}


Measured memory_bytes: 3632
#include <stdio.h>




int main(void){
    int N;
    scanf("%d",&N);
    int ans=0;
    for(int i=0;i<N;i++){
        int a;
        scanf("%d",&a);
        while(a%2==0){a/=2;ans++;}
    }
    
    printf("%d",ans);
    
    
    return 0;
}


Measured memory_bytes: 128
N, X, M = map(int, input().split())
a = [0 for i in range(M+1)]
b = [X]
a[X-1] = 1

for i in range(min(N-1, M)):
  X = X**2%M
  a[X-1] += 1
  b.append(X)
  if a[X-1] > 1:
    break

if len(b) == N:
  print(sum(b))

else:
  ls = b.index(b[-1])
  bloop = b[ls:-1]
  ans = 0
  if ls > 0:
    for i in range(ls):
      ans += b[i]
  loop = (N-ls)//len(bloop)
  ans += sum(bloop) * loop
  if (N-ls)%len(bloop) != 0:
    for i in range((N-ls)%len(bloop)):
      ans += bloop[i]
  print(ans)

Measured memory_bytes: 11900