akhauriyash/Code-Regression huggingface dataset:
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
string s;
char c[maxn];
int cur;

int main(){
	scanf("%s",c);
	s=c;
	rep(i,s.size()){
		if(i%2==0)if(s[i]=='p')cur--;
		if(i%2==1)if(s[i]=='g')cur++;
	}
	printf("%d",cur);
	return 0; 
}

Measured memory_bytes: 384
program minpro2019
  integer i, a(6), c(4)
  read *, a
  do i = 1, 4
     c(i) = count(a == i)
  end do
  if (all(c < 3)) then
     print *, 'YES'
  else
     print *, 'NO'
  end if
end program minpro2019


Measured memory_bytes: 256
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 


// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int flag = 1;
    while(a>0 and c>0)
    {
        if(flag==1){
            c-=b;
        }
        else{
            a-=d;
        }
        flag ^=1;
    }

    if(a>0)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}  //4 5


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		int[] a = new int[n];
		sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] dp = new int[k + 1];
		for (int i = 0; i < n; i++) {
			dp[a[i]] = 1;
		}
		for (int i = 1; i <= k; i++) {
			if (dp[i] == 0) {
				for (int j = 0; j < n; j++) {
					int b = i - a[j];
					if (b < 0) {
						dp[i] = 2;
						break;
					}
					if (dp[b] == 1) {
						dp[i] = 2;
					}
					if (dp[b] == 2) {
						dp[i] = 1;
						break;
					}
				}
			}
		}

		if (dp[k] == 1) {
			System.out.println("First");
		} else {
			System.out.println("Second");
		}
	}
}


Measured memory_bytes: 24276
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
 
using namespace std;

#define int long long
 
struct segtree {
    vector<int> dat;
    int n;
 
    segtree(int n_) {
        n = 1;
 
        while (n < n_) n *= 2;
 
        dat.resize(2*n, 0);
    }
 
    inline void update(int i, int x) {
        i += n - 1;
        int diff = x - dat[i];
        dat[i] = x;
 
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] += diff;
        }
    }
 
    inline int query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
 
        if (r <= a || l >= b) return 0;
 
        if (a <= l && r <= b) {
            return dat[k];
        }
 
        int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
 
        return lv + rv;
    }
};

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

    int N; cin >> N;
    vector<int> a(N), b(N);
 
    segtree P(N), Q(N);
    vector<tuple<int, int, int>> tmp;
 
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i];
        tmp.push_back(make_tuple(a[i], i, b[i]));
    }
 
    sort(begin(a), end(a));
    sort(begin(tmp), end(tmp));
 
    vector<pair<int, int>> data;
 
    for (int i = 0; i < N; ++i) {
        int aaa, bbb, val;
        tie(aaa, bbb, val) = tmp[i];
        data.push_back(make_pair(val, i));
    }
 
    sort(begin(data), end(data));
     
    for (int i = 0; i < N; ++i) {
        P.update(i, a[i]);
        Q.update(i, 1);
    }
 
    int ma = 0;
 
    for (int i = 0; i < N; ++i) {
        pair<int, int> d = data[i];
 
        int l = 0, r = N;

        int PP, QQ;
 
        for (int j = 0; j < 20; ++j) {
            int mid = (l + r) / 2;

            PP = P.query(0, mid + 1);
            QQ = Q.query(0, mid + 1);
 
            if (PP <= d.first * QQ) {
                l = mid;
            } else {
                r = mid;
            }
        }
 
        if (PP <= d.first * QQ) {
            ma = max(ma, QQ);
        }
 
        P.update(d.second, 0);
        Q.update(d.second, 0);
    }
 
    cout << ma << endl;
}

Measured memory_bytes: 43764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;


int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int x; cin>>x;
	cout<<k[x-1]<<endl;
	return 0;
}


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

const int MAXN = 1e5+5;
const ll p = 1e9+7;

ll n;
ll x[MAXN];
ll prod = 1;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i];
	int ct = 0;
	for (int i = 0; i < n; ++i) {
		if (x[i] <= 2*i-2*ct) {
			prod *= (i+1-ct);
			prod %= p;
			ct++;
		}
	}

	for (int j = n-ct; j >= 1; --j)
		prod = prod*j%p;
	cout << prod << endl;
}

Measured memory_bytes: 1024
N = int(input())
S = [[] for i in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  S[u-1].append((v-1, w))
  S[v-1].append((u-1, w))
#print(S)
C = [-1] * N
Q = [0]
C[0] = 0
while Q:
  p = Q.pop()
  Ns = S[p]
  #print(Ns)
  for v, w in Ns:
    if C[v] < 0:
      C[v] = (C[p]+w)%2
      Q.append(v)
for i in range(N):
  print(C[i])


Measured memory_bytes: 38832
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n,cnt = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
    if ((i+1) % 2 == 1 && a[i] % 2 == 1){
      cnt++;
    }
  }
  cout << cnt << '\n';  
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

#define mkp make_pair
int main() {
  int n;
  cin >> n;
  // vector<pair<int, pair<int, vector<int>>>> tree(n); // vector<id, pair<parent, vector<child>>;
  // vector<tuple<int, int, vector<int>> tree(n); // vector<tuple<id, parent, vector<child>>;
  // vector<pair<pair<int, int>, vector<int>>> tree(n); // vector<pair<pair<id, parent>, vector<child>>>
  // priority_queue<pair<pair<int, int>, vector<int>>> tree; //priority_queue<pair<pair<id, pairent>, vector<child>>>;
  map<int, pair<int, vector<int>>> tree; // map<id, pair<pairent, vector<child>>>;
  int id, k;
  vector<int> ids;
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> id;
    ids.push_back(id);
    cin >> k;
    tree.insert(mkp(id, mkp(-1, vector<int>(k))));
    for (j = 0; j < k; j++) {
      cin >> tree[id].second[j];
    }
  }
  sort(ids.begin(), ids.end());

  for (i = 0; i < tree.size(); i++) {
    for (j = 0; j < tree[ids[i]].second.size(); j++) {
      tree[tree[ids[i]].second[j]].first = ids[i];
    }
  }

  int depth, pairent;
  for (i = 0; i < ids.size(); i++) {
    cout << "node " << ids[i] << ": parent = " << tree[ids[i]].first << ", depth = ";
    depth = 0;
    pairent = tree[ids[i]].first;
    while (pairent != -1) {
      depth++;
      pairent = tree[pairent].first;
    }
    cout << depth << ", " << (tree[ids[i]].first == -1 ? "root" : (tree[ids[i]].second.size() != 0 ? "internal node" : "leaf")) << ", [";
    for (j = 0; j < tree[ids[i]].second.size(); j++) {
      cout << tree[ids[i]].second[j];
      if (j != tree[ids[i]].second.size() - 1) {
        cout << ", ";
      }
    }
    cout << ']' << endl;
  }

  return 0;
}



Measured memory_bytes: 11300
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
    
   ll n;
   cin>>n;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   ll cnt = 1;
   ll maxi = 1;
   ll curr = arr[0];
   for(ll i=1;i<n;i++)
   {
       maxi = max(maxi,cnt);
       if(arr[i]>curr)
       {
            curr = arr[i];
            cnt = 1;
       }
       
       else cnt++, curr = arr[i];
       maxi = max(maxi, cnt);
   }
   
   cout<<maxi-1;
   
   return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
p=list(map(int,input().split()))
pi=[0 for i in range(n+1)]
for i,j in enumerate(p,1):
    pi[j]=i
class unionfind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def count(self, x):
        return -self.root[self.find(x)]
uf=unionfind(n)
for i in range(m):
    x,y=map(int,input().split())
    uf.unite(x,y)
ans=0
for i in range(1,n+1):
    if uf.same(i,pi[i]):
        ans+=1
print(ans)

Measured memory_bytes: 14684
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,tmp;
    cin >> n;
    tmp = n;
    int digitsum = 0;
    while(tmp > 0){
        digitsum += (tmp %10);
        tmp/=10;
    }
    //cout << digitsum << endl;
    if(n % digitsum == 0)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
    return 0;
}

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

int main() {
	long n, a, b;
	cin >> n >> a >> b;
	long sum = a + b;
	long ans = 0L;
	ans += (n / sum) * a + min((n % sum), a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

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

    int n,k,s;
    cin >> n >> k >> s;

    if(s != 1e9){
        if(k == 0){
            rep(i,n){
                cout << (i == 0 ? "" : " ") << (int)(1e9);
            }
            cout << '\n';
            return 0;
        }
        rep(i,k){
            cout << (i == 0 ? "" : " ") << s;
        }
        rep(i,n-k){
            cout << " " << (int)(1e9);
        }
        cout << '\n';
    }else{
        if(k == 0){
            rep(i,n){
                cout << (i == 0 ? "": " ") << 1;
            }
            cout << '\n';
            return 0;
        }
        rep(i,k){
            cout << (i == 0 ? "" : " ") << s;
        }
        rep(i,n-k){
            cout << " " << 1;
        }
        cout << '\n';
    }


    return 0;
}



Measured memory_bytes: 1280
N = int(input())
S = input()

mod = 10**9 + 7
M=len(S)

DP = [[0]*(N+1) for i in range(N+1)]

DP[0][0] = 1

for i in range(1,N+1):
    for j in range(N+1):
        if j>0 and j<N:
            DP[i][j] = DP[i-1][j-1] + 2*DP[i-1][j+1]
        elif j==0:
            DP[i][j] = DP[i-1][j] + 2*DP[i-1][j+1]
        else:
            DP[i][j] = DP[i-1][j-1]
        DP[i][j] %= mod

print(DP[N][M])

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

int main() {
  string nums = "ABCDEF";
  char a, b;
  cin >> a >> b;
  int c, d;
  for (int i = 0; i < 6; i++) {
    if (a == nums.at(i)) c = i;
    if (b == nums.at(i)) d = i;
  }
  if (c == d) cout << "=" << endl;
  else if (c > d) cout << ">" << endl;
  else cout << "<" << endl;
}

Measured memory_bytes: 256
x=input()
l=len(x)
s=0
for i in x:
    s+=1
    if i=="A":
        print("X",end="")
    elif i=="B":
        print("Y",end="")
    elif i=="C":
        print("Z",end="")
    else:
        print(chr(ord(i)-3),end="")
    if s==l:
        print()


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

using namespace std;

#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define fi(i,x,n) for(i=x;i<n;++i)
#define f(n) for(int i=0;i<n;++i)
#define fa(x,y) for(auto x:y)
#define endl '\n'
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fr(i,x,n) for(i=x;i>=n;--i)

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    int k;
    cin>>s>>k;
    int n=sz(s);
    int j;
    set<string> l;
    f(k){
 //       cout<<i<<endl;
        fi(j,0,n-i){
//            cout<<j<<" "<<n-i<<" "<<i+1<<" ";
            l.insert(s.substr(j,i+1));
//            cout<<s.substr(j,i+1)<<endl;
        }
    }
    //cout<<endl;
    string  ans;
    int i=1;
    for(auto x:l){
        ans=x;
        if(i==k) break;
        ++i;
    }

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


Measured memory_bytes: 1664
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b,c,count = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a; i <= b; i++){
        if(c%i == 0) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2712
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int N = sc.nextInt();
	        long ans=1;
	        long[] a = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	            if((long)(Math.pow(10, 18)/ans)<a[i]) {
	            	ans=-1;
	            } else if(ans!=-1){
	            	ans=ans*a[i];
	            }
	            if(a[i]==0) {
	            	System.out.println(0);
	            	return;
	            }
	        }
	        if(ans>(long)Math.pow(10, 18))ans=-1;
    		System.out.println(ans);
	    }
	}

Measured memory_bytes: 60476
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

int n, x[55], y[55];

int main() {
  cin >> n;
  FI(i, 1, n) cin >> x[i] >> y[i];
  map<PII, int> mp;
  FI(i, 1, n) FI(j, i + 1, n) {
    int dx = x[j] - x[i], dy = y[j] - y[i];
    mp[{dx, dy}]++;
    mp[{-dx, -dy}]++;
  }
  int maxv = 0;
  for (auto p : mp) maxv = max(maxv, p.second);
  cout << (n - maxv) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,m=0,n=0;cin>>x;
    for(int i=-500;i<=500;i++)
        {
            for(int j=-500;j<=500;j++)
             {
               if(pow(i,5)-pow(j,5)==x)
                {
                    m=i;
                    n=j;
                break;}


             }

        }
        cout<<m<<" "<<n<<endl;

}


Measured memory_bytes: 4100
#define _GLIBCXX_DEBUG
#include <iostream>
using namespace std;

int main(void){
    int n, cnt = 0;
    string s;
    cin >> n >> s;
    for(int i=0; i<n-2; i++)
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') cnt++;
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int l=0,r=N-1;
  int ans=0;
  while(l<N&&r>=0) {
    while(l<N&&S[l]=='R') l++;
    while(r>=0&&S[r]=='W') r--;
    if(l<r) ans++;
    else break;
    l++;r--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3716
s = gets.chomp.chars
t = gets.chomp.chars

h1 = {}
h2 = {}

ans = "Yes"
t.size.times do |i|
  sc = s[i]
  tc = t[i]
  if h1[sc] && h1[sc] != tc
    ans = "No"
    break
  elsif h2[tc] && h2[tc] != sc
    ans = "No"
    break
  end
  h1[sc] = tc
  h2[tc] = sc
end

puts ans


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
   int a, b;
   char s;
   cin >> a >> s >> b;
   if(s == '+') cout << a+b << '\n';
   else{
       cout << a - b << '\n';
   }

    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//素数の判定
bool is_prime(int n) {
    if (n <= 1) {
        return false;
    }

    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {

    int x; cin >> x;

    while (!is_prime(x)) {
        ++x;
    }

    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(l,r) ((l)<=a&&a<=(r))
int main(void){
    vector <int> col(8);
    int fr = 0;
    int n; cin>>n;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(r(1,399)) col[0]++;
        else if(r(400,799)) col[1]++;
        else if(r(800,1199)) col[2]++;
        else if(r(1200,1599)) col[3]++;
        else if(r(1600,1999)) col[4]++;
        else if(r(2000,2399)) col[5]++;
        else if(r(2400,2799)) col[6]++;
        else if(r(2800,3199)) col[7]++;
        else if(r(3200,5000)) fr++;
    }
    int cnt1=0;
    for(int i=0;i<col.size();i++){
        if(col[i]) cnt1++;
    }
    if(cnt1==0){
        cout<<1<<' '<<fr<<endl;
        return 0;
    }
    cout<<cnt1<<' ';
    cout<<cnt1 + fr<<endl;
}


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

int main(){
  int n; 
  cin >> n;

  int x[150];
  int mn = 100, mx = 0;

  for(int i=0; i<n; ++i){
    cin >> x[i];
    mn = min(mn, x[i]);
    mx = max(mx, x[i]);
  }
  int mn1 = 10000000;
  for(int i=mn; i<=mx; ++i){
    int sum =0;
    for(int j=0; j<n; ++j){
      sum += (x[j] - i) * (x[j] -i); 
    }
    mn1 = min(mn1, sum);
  }

  cout << mn1;


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k,a,amax,key;
int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while(k != 0);
	return result;
}
main(){
    cin>>n>>k;
    bool p=1,pp=1;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>amax)amax=a;
        if(a==k){
          cout<<"POSSIBLE"<<endl;
          return 0;
        }
        if(i==0){
            key=a;
            continue;
        }
        key=gcm(key,a);
    }
    if(k%key!=0)p=0;
    if(amax<=k)pp=0;
    if(p and pp)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int N, c;

int main()
{
	int i, j;

	si(N);

	fl(i,0,N)
	{
		int temp;
		si(temp);
		if(temp % 2 == 1)
			c++;
	}

	if(c % 2 == 0)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#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


bool funami(string st, int p)
{
    if (p % 2) return false;

    rep(i, (st.size() - p) / 2) {
        if (st[i] != st[i+(st.size()-p)/2]) return false;
    }
    return true;
}

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

    string st;
    cin >> st;
    
    Rep(i, st.size()) {
        if (funami(st, i)) {
            cout << st.size() - i << endl;
            return 0;
        }
    }


    return 0;
}


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

struct node{
  struct node *prev;
  struct node *next;
  int key;
};

typedef struct node *NodePointer;
NodePointer nil;

NodePointer search(int k){
  NodePointer x;

  x=nil->next;
  while(x!=nil && x->key!=k){
    x=x->next;
  }

  return x;
}

void insert(int k){
  NodePointer x;

  x=malloc(sizeof(struct node));
  x->key=k;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

void deleteNode(NodePointer x){
  x->prev->next=x->next;
  x->next->prev=x->prev;
}

void delete(int k){
  NodePointer x;

  x=search(k);
  if(x==nil) return;
  deleteNode(x);
}

void deleteFirst(){
  NodePointer x;

  x=nil->next;
  deleteNode(x);
}

void deleteLast(){
  NodePointer x;

  x=nil->prev;
  deleteNode(x);
}

int main(){
  int n,i,k,flag=1;
  char c[20];
  NodePointer x;

  nil=malloc(sizeof(struct node));
  nil->prev=nil;
  nil->next=nil;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",c);
    if(c[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }else if(c[0]=='d'){
      if(strlen(c)>6){
	if(c[6]=='F') deleteFirst(); 
	  else if(c[6]=='L') deleteLast();
      }else{
	scanf("%d",&k);
	delete(k);
      }
    }
  }

  x=nil->next;
  while(1){
    if(x==nil) break;
    if(flag==0) printf(" ");
    printf("%d",x->key);
    x=x->next;
    flag=0;
  }
  printf("\n");

  return 0;
}

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

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

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (1e9+7)
#define INF (1e9)
#define LLINF (4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int N, K; input(N, K);
    if ((N - 1)*(N - 2) / 2 < K) cout << -1 << endl;
    else {
        vector<int> u, v;
        REP(i, N - 1) {
            u.emplace_back(1);
            v.emplace_back(i + 2);
        }
        int t = (N - 1)*(N - 2) / 2 - K;
        // t個消す
        if (t != 0) {
            FOR(i, 2, N) {
                FOR(j, i + 1, N + 1) {
                    u.emplace_back(i);
                    v.emplace_back(j);
                    t--;
                    if (t <= 0) break;
                }
                if (t <= 0) break;
            }
        }
        cout << u.size() << endl;
        REP(i, u.size()) {
            cout << u[i] << " " << v[i] << endl;
        }
    }
    getchar(); getchar();
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())

A = [None] * N
# インデックス：-1で先頭にアクセスするため前後反転
# 最初の選手を指す場合０になるように-1した値を保持
# 全組み合わせを試合し終わった時は−１になるようにする
for i in range(N):
    A[i] = [-1] + [int(x) - 1 for x in input().split()[::-1]]


def f(candi):
    
    played = []
    
    # 次に試合する可能性のある選手を順次チェック
    for n in candi:
        target = A[n][-1]
        if A[target][-1] == n:
            played.append(n)
        
    new_candi = set()    
    for n in played:
        # 試合ずみの組み合わせを削除
        A[n].pop()
        # 試合する人の候補に追加
        new_candi.add(n)
        # 次の対戦相手を試合の候補に追加
        if A[n][-1] != -1:
            new_candi.add(A[n][-1])
            
    return len(played), new_candi


answer = 0
# 最悪の試合数（二倍された値）
rest = N*(N-1)
# 試合する人の候補
play_candi = set(range(N))

while True:
    answer += 1
    x, play_candi = f(play_candi)
    # 行われた試合数を確認
    if x == 0:
        answer = -1
        break
        
    rest -= x
    if rest ==0:
        break
        
print(answer)


Measured memory_bytes: 34676
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {	 
		Scanner in = new Scanner(System.in);
		String s = in.next(), ans = "";
		int x = in.nextInt();
		for (int i = 0; i < s.length(); i += x){
		    ans += "" + s.charAt(i);
		}
		System.out.print(ans);
	}
}	
	


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

int main()
{
	int n,a[10000],i,b=0;
	cin>>n;
	for(i=0;i<2*n;i++)
	cin>>a[i];	
	sort(a,a+2*n);
	//cout<<min(a[2],a[3])<<"\n";
	for(i=0;i<2*n;i=i+2)
	{
		if(a[i]==a[i+1])
		b=b+a[i];	
		else	
		b=b+min(a[i],a[i+1]);
	}	
	cout<<b<<"\n";
	return 0;
}

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

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

    vl a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;  b[i]--;
        c[i] *= -1;
    }

    vl dist(n, INF);  // dist[v] : 頂点0から頂点vへの最短距離
    dist[0] = 0;
    rep(loop, n-1) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    vl negativeCycle(n);  // negativeCycle[v] : 頂点vを含む負閉路があるとき1
    rep(loop, n) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                negativeCycle[b[i]] = 1;
            }
            if(negativeCycle[a[i]]) {
                negativeCycle[b[i]] = 1;
            }
        }
    }

    if(negativeCycle[n-1]) {
        out("inf");
    }
    else {
        out(-dist[n-1]);
    }
    
    re0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String g[][] = new String[h][w];
		String f[] = new String[h];
		for(int i=0; i<h; i++){
			f[i] = sc.next();
		}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				g[i][j] = String.valueOf(f[i].charAt(j));
			}
		}

		int cc = 0;
		int countw[] = new int[h];
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(g[i][j].equals("."))countw[i]++;
			}
			if(countw[i]==w){
				for(int j=0; j<w; j++){
					g[i][j]="";
				}
			cc++;
			}
		}
		

		int counth[] = new int[w];
		for(int i=0; i<w; i++){
			for(int j=0; j<h; j++){
				if(g[j][i].equals("."))counth[i]++;
			}			
			if(counth[i]==h-cc){
				for(int k=0; k<h; k++){
					g[k][i]="";
				}
			}
		}

		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				System.out.print(g[i][j]);
			}
			if(countw[i]!=w)System.out.println("");
		}
	}
}

Measured memory_bytes: 28512
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

struct Node{
    int parent, left, right;
};

int max(int m, int n){
    if(m>n) return m;
    else return n;
}

int setheight(Node *T, int *H, int u){
    int h1=0;
    int h2=0;
    if(T[u].right != -1) h1 = setheight(T, H, T[u].right) + 1;
    if(T[u].left != -1) h2 = setheight(T, H, T[u].left) + 1; 
    H[u] = max(h1, h2);
    return H[u];
}

void setdepth(Node *T,int *D, int u, int p){
    D[u]=p;
    if(T[u].right!=-1) setdepth(T, D, T[u].right, p+1);
    if(T[u].left!=-1) setdepth(T, D, T[u].left, p+1);
}

int getsibling(Node *T, int u){
    if(T[u].parent==-1) return -1;
    else if(u==T[T[u].parent].right) return T[T[u].parent].left;
    else if(u==T[T[u].parent].left) return T[T[u].parent].right;
}




int main(){
    int n, i, j, k;
    Node *T;
    int *H, *DG, *D;
    scanf("%d", &n);
    T = (Node*)malloc(sizeof(Node)*n);
    H = (int*)malloc(sizeof(int)*n);
    DG = (int*)malloc(sizeof(int)*n);
    D = (int*)malloc(sizeof(int)*n);

    for(i=0;i<n;i++){
        T[i].parent = -1;
        T[i].left = -1;
        T[i].right = -1;
        DG[i]=0;
        D[i]=0;
    }

    for(i=0;i<n;i++){
        scanf("%d", &k);
        scanf("%d %d", &T[k].left, &T[k].right);
        if(T[k].right!=-1){
            T[T[k].right].parent = k;
            DG[k]++;
        }
        if(T[k].left!=-1){
            T[T[k].left].parent = k;
            DG[k]++;
        }
    }

    for(i=0;i<n;i++){
        if(T[i].parent==-1){
            k=i;
            break;
        }
    }

    //cout<<k<<endl;
    setheight(T, H, k);
    setdepth(T,D,k, 0);
    

    for(i=0;i<n;i++){
        //T[i].parent = -1;
        //T[i].left = -1;
        //T[i].right = -1;
        //cout<<T[i].parent<<" "<<T[i].left<<" "<<T[i].right<<endl;
        //cout<<D[i]<<endl;
    }


    for(int i=0;i<n;i++){
        if(T[i].parent==-1) cout<<"node "<<i<<": parent = "<<T[i].parent<<", sibling = "<<getsibling(T, i)<<", degree = "<<DG[i]<<", depth = "<<D[i]<<", height = "<<H[i]<<", root"<<endl;
        else if(T[i].right==-1 && T[i].left==-1) cout<<"node "<<i<<": parent = "<<T[i].parent<<", sibling = "<<getsibling(T, i)<<", degree = "<<DG[i]<<", depth = "<<D[i]<<", height = "<<H[i]<<", leaf"<<endl;
        else cout<<"node "<<i<<": parent = "<<T[i].parent<<", sibling = "<<getsibling(T, i)<<", degree = "<<DG[i]<<", depth = "<<D[i]<<", height = "<<H[i]<<", internal node"<<endl;
    }



free(T);
free(DG);
free(H);
free(D);

}


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

c = list(set(a))
c.sort()
if len(c) > 3:
    print('No')
    exit()

if len(c) == 1:
    if c[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(c) == 2:
    if c[0] == 0 and a.count(0) * 2 == a.count(c[1]):
        print('Yes')
    else:
        print('No')
else:
    if c[0] ^ c[1] == c[2] and a.count(c[0]) == a.count(c[1]) and a.count(c[1]) == a.count(c[2]):
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 14704
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void countdown(vector<int> &r, int k, int n, int &z) {
    //if(r[z] > 0){
    //    --r[z];
    //} else {
    //    --r[z-1];
    //    r[z] = k;
    //    if(r[z-1]==0) --z;
    //    else z = n-1;
    //}
    if (r[z] == 0) {
        r[z] = k;
        z--;
        r[z]--;
        if (r[z] != 0) {
            z = n-1;
        }
    } else if(r[z] > 0){
        r[z]--;
    } else {
        std::cerr << r[z-1] << r[z] << r[z+1] << std::endl;
    }
    return;
}

void solve(int k, int n) {
    if (k%2 == 0) {
        std::cout << k/2;
        for (int i = 0; i < n-1; i++) {
            std::cout << " " << k;
        }
        std::cout << std::endl;
        return;
    }
    vector<int> ret(n, (k+1)/2);
    int z = n-1;
    for (int i = 0; i < n/2; i++) {
        countdown(ret, k, n, z);
    }
    std::cout << ret[0];
    for (int i = 1; i < ret.size(); i++) {
        if (ret[i] == 0) {
            break;
        }
        std::cout << " " << ret[i];
    }
    std::cout << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int k, n;

    gettimeofday(&start,NULL);

    std::cin >> k >> n;
    solve(k, n);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ll n;cin >> n;
    vector<ll>a(n);
    for(int i = 0;i<n;i++) cin >> a[i];
    map<ll,ll>mp;vector<ll>p;
    mp[-1] = 3;
    for(int i = 0;i<n;i++){
        p.push_back(mp[a[i]-1]);
        mp[a[i]]++;
        mp[a[i]-1]--;
    }
    ll ans = 1;
    for(int i = 0;i<n;i++){
        ans *= (p[i])%mod;
        ans = (ans+mod)%mod;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 11012
#include<stdio.h>
#include<string.h>

int main()
{
    int k,x,i,j,m,len=0;
    scanf("%d %d",&k,&x);
    int pos[(2*k)-1];


    for(i=0;i<=k-1;i++)
    {
        if(x+i>1000000)
        {
            break;
        }

        pos[i]= x+i;

        m=i;

    }
    len = m;
    for(i=m+1,j=1;j<=k-1;i++,j++)
    {
        if(x-i< -1000000)
        {
            break;
        }

        pos[i]=x-j;

    }
    len = len + j;


    for(i=0;i<len;i++)
    {
        for(j=i+1;j<len;j++)
        {
            if(pos[i]>pos[j])
            {
                m=pos[i];
                pos[i]=pos[j];
                pos[j]=m;
            }
        }
    }

    for(i=0;i<len;i++)
    {

        printf("%d ",pos[i]);
    }
    return 0;
}


Measured memory_bytes: 1720
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(gg => int.Parse(gg)).ToArray();
            int count = 0;


            
                for (int i = 0; i < N; i++)
                {

                if(i == 0)
                {
                    count = h[i];
                }
                else if(i >= 1 && (h[i] - h[i - 1]) > 0)
                {
                    count += h[i] - h[i - 1];
                }
                    
                }
            
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 28160
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

const lli INF=1e18;
const lli N=2e5+5;
lli a[N]={0},b[N]={0};



int32_t main(){
    fast_io
    lli i = 0,j=0;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    
    vt v,v1,v2;
    lli a,b,c,d,e,f;

    lli k;
    cin >> k;
    lli ans=0;
    loope(i,1,k){
        loope(j,1,k){
            loope(p,1,k){
                ans+=gcd(i,gcd(j,p));
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	s := wordScanner(100001)
	s.Scan()
	str := s.Text()

	sample := strings.Repeat("10", 50001)

	fmt.Println(min(sub(str, sample), sub(str, sample[1:])))
}

func sub(s, t string) int {
	c := 0
	for i := range s {
		if s[i] != t[i] {
			c++
		}
	}
	return c
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	buf := make([]byte, n)
	s.Buffer(buf, n)
	return s
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


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

int main(){
  int n, m;
  cin >> n >> m;
  int a[n];
  priority_queue<int> pq;
  for ( int i = 0; i < n; i++){
    cin >> a[i];
    pq.push(a[i]);
  }

  for ( int i = 0; i < m; i++){
    int top = pq.top(); pq.pop();
    top = top/2;
    pq.push(top);
  }

  long long sum = 0;
  while(!pq.empty()){
    int top = pq.top(); pq.pop();
    sum += top;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>

int main(void)
{
	char s[5];
	int n = 0, i;
	scanf("%s", s);
	for (i = 0; i < 4; i++) {
		if (s[i] == '+') n++;
		else n--;
	}
	printf("%d", n);
	return 0;
}

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

using namespace std;

typedef long long ll;

template<typename T>
class CumulativeSum {
    const int n;
    std::vector<T> sum_data;
public:
    CumulativeSum(vector<T> data) : n(data.size()) {
        sum_data.resize(n + 1);
        for (int i = 0; i < n; i++) {
            sum_data[i + 1] = sum_data[i] + data[i];
        }
    }

    // 区間 [l, r) 番目の範囲の和を求める．(l = r のときは 0 を返す．)
    T sum(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        return sum_data[r] - sum_data[l];
    }
};

typedef CumulativeSum<ll> CumSum;


int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i], B[i] = max(0ll, A[i]);
    CumSum sum(A), sumMax(B);
    long long ans = 0;
    for(int i = 0 ; i + K <= N ; i++){
        ans = max(ans, sumMax.sum(0, i) + max(0ll, sum.sum(i, i+K)) + sumMax.sum(i+K, N));
    }

    cout << ans << endl;

}


Measured memory_bytes: 4208
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int main(){
  int D;
  int T;
  int S;
  rd(D);
  rd(T);
  rd(S);
  if(T*S >= D){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200813-1 [beta]

// --- original code ---
// {
//   int D, T, S;
//   rd(D, T, S);
//   wt(if[T*S >= D, "Yes", "No"]);
// }


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>

int main(){
	double X1,Y1;
	double X2,Y2;
	scanf("%lf %lf %lf %lf",&X1,&Y1,&X2,&Y2);
	printf("%lf\n",sqrt(pow(X1-X2,2)+pow(Y1-Y2,2)));
	return 0;
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int acnum[] = new int[n];
        Arrays.fill(acnum, 0);
        for (int i = 0; i < n - 1; i++) {
            String tmp = s.substring(i, i + 2);
            if (tmp.equals("AC")) {
                acnum[i]++;
            }
        }
        for (int i = 0; i < n - 1; i++) {
            acnum[i + 1] += acnum[i];
        }

        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = 0;
            if (l == 1) {
                ans = acnum[r - 2];
            } else {
                ans = acnum[r - 2] - acnum[l - 2];
            }
            System.out.println(ans);
        }

        sc.close();
    }
}


Measured memory_bytes: 77100
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

X = I()
print((X // 500) * 1000 + ((X - ((X // 500) * 500)) // 5) * 5)


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

int main(){
  string s;
  string t;
  int sn;
  cin >> s >> t;
  sn = s.size();
  
  int ans=0;
  
  for(int i=0; i<sn; i++){
    if(s.at(i)==t.at(i)){
      ans += 1;
    }
  }
  
  if(sn == ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 3596