akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec<int> a(N), b(N);
  REP(i, N) cin >> a[i] >> b[i];
  reverse(ALL(a));
  reverse(ALL(b));
  int cnt = 0;
  REP(i, N) {
    int tmpcnt = (a[i] + cnt) % b[i];
    tmpcnt = tmpcnt == 0 ? 0 : b[i] - tmpcnt;
    cnt += tmpcnt;
    // DEBUG(cnt);
  }
  print(cnt);
}

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

int main() {
	int a,b,c,k;cin>>a>>b>>c>>k;
	int max;
	int ans=0;
	if(a<b){
		ans+=a;
		if(b<c){
			ans+=b;
			max=c;
		}else{
			ans+=c;
			max=b;
		}
	}else{
		ans+=b;
		if(a<c){
			ans+=a;
			max=c;
		}else{
			ans+=c;
			max=a;
		}
	}
	for(int i=0;i<k;i++){
		max*=2;
	}
	ans+=max;
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int temp;
    int arr[30]={0};
    for(int i=0;i<4;i++)
    {
        temp=s[i]-'A';
        arr[temp]++;
    }

    int flag=0;

    for(int i=0;i<26;i++)
    {
        if(arr[i]==2)flag++;
    }

    if(flag==2)cout<<"Yes";
    else cout<<"No";



}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> cnt(1e5+1);
    ll sum = 0;
    FOR(i, n){
        int ai;
        cin >> ai;
        sum += ai;
        cnt[ai] += 1;
    }
    int q;
    cin >> q;
    FOR(i, q){
        ll b, c;
        cin >> b >> c;
        sum -= cnt[b]*b;
        sum += cnt[b]*c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3720
// ABC 081 B
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#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())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int func(int n){
  int a=0;
  while(n%2==0){n/=2;a++;}
  return a;
}
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int n;
  cin >> n;
  VI a(n);
  int temp;
  REP(i,n){
    cin >> temp;
    a[i]=func(temp);
  }
  cout << MIN_EL(a) << endl;
  return 0;
}


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

int main()
{
	int n,m,s=0;
	cin>>n>>m;
	
	for(int i=1;i<n;i++)
		s+=i;
	
	for(int i=1;i<m;i++)
		s+=i;
	
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll a[100010];

int main(void){
	          ll i,j;

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

	      	  ll K;
	      	  cin >> K;
	      	  for(i=1;i<=K;i++) cin >> a[i];

	      	  if(a[K]!=2){
	      		  cout <<-1 << endl;
	      		  return 0;
	      	  }

	      	  ll p=2,q=3;
	      	  for(i=K-1;i>=1;i--){
	      		  bool f=false;
	      		  ll k1=(p+a[i]-1)/a[i],k2=q/a[i];
	      		  if(k1==0 || k2==0){
	      			  cout << -1 << endl;
	      			  return 0;
	      		  }
	      		  if(k1<=k2){
      				  p=k1*a[i];
      				  q=k2*a[i]+a[i]-1;
      				  f=true;
	      		  }else{
	      			  cout << -1 << endl;
	      			  return 0;
	      		}

	      		  if(!f){
	      			  cout << -1 << endl;
	      			  return 0;
	      		  }
	      	  }

	      	  cout << p << ' ' << q << endl;

	          return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
student = [[0, 0]] * n
for i in range(n):
    a, b = map(int, input().split())
    student[i] = [a, b]

point = [[0, 0]] * m
for i in range(m):
    a, b = map(int, input().split())
    point[i] = [a, b]

for i in student:
    min_d = abs(i[0] - point[0][0]) + abs(i[1] - point[0][1])
    min_i = 1
    for j in range(m):
        d = abs(i[0] - point[j][0]) + abs(i[1] - point[j][1])
        if min_d > d:
            min_d = abs(i[0] - point[j][0]) + abs(i[1] - point[j][1])
            min_i = j+1
    print(min_i)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    string S;
    ll K, size;
    cin >> S >> K;
    size = min((ll)S.size(), K);
    rep(i, size) {
        if (S[i] >= '2') {
            out(S[i]);
            return 0;
        }
    }
    out('1');
}

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

int64_t solve(const string &S, char a, char b, char c) {
    int N = S.size();
    int64_t A = 0, C = 0;
    int64_t res = 0;
    for(int i = 0; i < N; ++i) C += (S[i] == c);
    for(int i = 0; i < N; ++i) {
        if(S[i] == a) A++;
        if(S[i] == b) res += A * C;
        if(S[i] == c) C--;
    }
    return res;
}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int64_t ans = 0;
    ans += solve(S, 'R', 'G', 'B');
    ans += solve(S, 'B', 'G', 'R');
    ans += solve(S, 'B', 'R', 'G');
    ans += solve(S, 'G', 'R', 'B');
    ans += solve(S, 'G', 'B', 'R');
    ans += solve(S, 'R', 'B', 'G');
    for(int j = 1; j < N - 1; ++j) {
        for(int d = 0; d < N; ++d) {
            int i = j - d, k = j + d;
            if(i < 0 or k >= N) continue;
            if(S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) ans--;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int main(){

  int x, y;
  cin >> x >> y;
//グループを配列でとっておく
  int num[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if (num[x] == num[y]){/*x番目とy番目が同じならyes*/
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main() {
    int16_t n;
    cin >> n;
    int32_t p[n][11];

    int32_t a[n];

    for (int16_t i = 0; i < n; i++) {
        a[i] = 0;
        for (int16_t j = 0; j < 10; j++) {
            int16_t temp;
            cin >> temp;
            a[i] = (a[i] << 1) + temp;
        }
    }
    for (int16_t i = 0; i < n; i++) {
        for (int16_t j = 0; j <= 10; j++) {
            cin >> p[i][j];
        }
    }

    int32_t answer = -2147483648;
    for (int16_t i = 1; i < (1 << 10); i++) {
        int32_t temp = 0;
        for (int16_t j = 0; j < n; j++) {
            int16_t c = 0;
            for(int16_t k = 0; k < 10; k++) {
                c += ((a[j] & i) & (1 << k)) == (1 << k);
            }
            temp += p[j][c];
        }
        if (temp > answer) {
            answer = temp;
        }
    }

    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 384
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a,b,c;
char cho[100001][5][5][5];
string s[100001];
void output(int N,int A,int B,int C)
{
	if(s[N]=="AB")
	{
		if(cho[N][A][B][C]=='A')
		{
			output(N-1,A-1,B+1,C);
			cout<<'A'<<endl;
		}
		if(cho[N][A][B][C]=='B')
		{
			output(N-1,A+1,B-1,C);
			cout<<'B'<<endl;
		}
	}
	if(s[N]=="AC")
	{
		if(cho[N][A][B][C]=='A')
		{
			output(N-1,A-1,B,C+1);
			cout<<'A'<<endl;
		}
		if(cho[N][A][B][C]=='C')
		{
			output(N-1,A+1,B,C-1);
			cout<<'C'<<endl;
		}
	}
	if(s[N]=="BC")
	{
		if(cho[N][A][B][C]=='B')
		{
			output(N-1,A,B-1,C+1);
			cout<<'B'<<endl;
		}
		if(cho[N][A][B][C]=='C')
		{
			output(N-1,A,B+1,C-1);
			cout<<'C'<<endl;
		}
	}
}
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>a>>b>>c;
	a=min(2ll,a);
	b=min(2ll,b);
	c=min(2ll,c);
	cho[0][a][b][c]=1;
	for(int i=1;i<=n;++i)
	{
		cin>>s[i];
		if(s[i]=="AB")
		{
			for(int A=0;A<4;++A)
			{
				for(int B=0;B<4;++B)
				{
					for(int C=0;C<4;++C)
					{
						if(A>0&&cho[i-1][A-1][B+1][C])
						{
							cho[i][A][B][C]='A';
						}
						if(B>0&&cho[i-1][A+1][B-1][C])
						{
							cho[i][A][B][C]='B';
						}
					}
				}
			}
		}
		if(s[i]=="AC")
		{
			for(int A=0;A<4;++A)
			{
				for(int B=0;B<4;++B)
				{
					for(int C=0;C<4;++C)
					{
						if(A>0&&cho[i-1][A-1][B][C+1])
						{
							cho[i][A][B][C]='A';
						}
						if(C>0&&cho[i-1][A+1][B][C-1])
						{
							cho[i][A][B][C]='C';
						}
					}
				}
			}
		}
		if(s[i]=="BC")
		{
			for(int A=0;A<4;++A)
			{
				for(int B=0;B<4;++B)
				{
					for(int C=0;C<4;++C)
					{
						if(B>0&&cho[i-1][A][B-1][C+1])
						{
							cho[i][A][B][C]='B';
						}
						if(C>0&&cho[i-1][A][B+1][C-1])
						{
							cho[i][A][B][C]='C';
						}
					}
				}
			}
		}
	}
	for(int A=0;A<4;++A)
	{
		for(int B=0;B<4;++B)
		{
			for(int C=0;C<4;++C)
			{
				if(cho[n][A][B][C])
				{
					cout<<"Yes"<<endl;
					output(n,A,B,C);
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 28204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        if(e - a <= k)System.out.println("Yay!");
        else System.out.println(":(");

    }
}

Measured memory_bytes: 35752
#include <stdio.h>

//0:回文でない 1:回文
int divcomp(int n){
  int i=0, tmp[5]={0};
  while (n > 0){
    tmp[i] = n%10;
    n /= 10;
    i++;
  }
  if( tmp[0]==tmp[4] && tmp[1]==tmp[3] ){ return 1; }
  else		                            { return 0; }
}
//
int main(){
  int a,b,cnt=0;
  scanf("%d%d",&a,&b);
  for(int i=a; i<=b; i++){
    if( divcomp(i)==1 ){ cnt++; }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int n;

int main() {
	cin >> n;
	
	if (n % 2 == 0)	cout << 0.50000000 << endl;
	else {
		cout << ((double)(n + 1) / 2) / (double)(n) << endl;
	}


	return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());
        for(int i = 0; i <= X;i++){
            int j = X - i;
            if(2*i+4*j==Y){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
        return;
    }
}

Measured memory_bytes: 35672
# Problem C - Unification

# input
s = input()

# initialization
zero_count = 0
one_count = 0

# count
for i in range(len(s)):
    if s[i]=='0':
        zero_count += 1
    else:
        one_count += 1

# output
if zero_count>0 and one_count>0:
    if zero_count>=one_count:
        print(one_count*2)
    else:
        print(zero_count*2)
else:
    print(0)


Measured memory_bytes: 3188
mod = 10 ** 9 + 7

N, M = map(int, input().split())
_is_ok = [True for i in range(N + 1)]
for i in range(M):
    _is_ok[int(input())] = False
ways = [0 for i in range(N + 1)]
ways[0] = 1
if _is_ok[1]:
    ways[1] = 1
for i in range(N - 1):
    if _is_ok[i + 2]:
        ways[i + 2] = ways[i + 1] + ways[i]
    ways[i + 2] %= mod
print(ways[N])

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


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);

  for(long long i = 0; i < N; i++){
    cin >> A[i];
  }

  long long i;
  long long idx = 0;
  map<long long, long long> seen;

  for(i = 0; i < N; i++){
    if(seen.count(idx) > 0) goto result;

    seen[idx] = i;
    idx = A[idx]-1;
  }

  cout << -1 << endl;
  return 0;

  result:
  long long newidx;

  if (K < seen[idx]) {
    newidx = 0;

    for(long long j = 0; j < K; j++) {
      newidx = A[newidx]-1;
    }
  }
  else {
    newidx = idx;

    for(long long j = 0; j < ((K-seen[idx])%(i-seen[idx])); j++){
      newidx = A[newidx]-1;
    }
  }

  cout << newidx+1 << endl;
  return 0;
}


Measured memory_bytes: 17096
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'



int K, X;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

		cin >> K >> X;
		if (K*500 >= X){
			cout << "Yes" << newl;
		}
		else{
			cout << "No" << newl;
		}

	










	return 0;
}


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

int main() {
  int a;
  int x,y,z,w;
  cin >> a ;
  x = a/10;
  y= a % 1000;
  
  if ( x%111 == 0 || y%111 == 0 ) {
    cout << "Yes" ;
  }
  else {
    cout << "No" ;
  }

}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def main():
    S = input()
    ans = "Yes"
    T = [0]*30
    for s in S:
        T[ord(s)-ord("A")] += 1
    for i in range(30):
        if T[i] == 0 or T[i] == 2:
            pass
        else:
            ans = "No"
            break
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
     
     
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define forn(i,a,n) for(int i = a; i < n ; i++)
const int MOD = 1e9+7, N = 1e7 + 10;

int main() {
    int a,b;
    cin >> a >> b;
    cout << (6-a-b) << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> t(n+1, 0), x(n+1, 0), y(n+1, 0);
  rep(i, n) cin >> t[i+1] >> x[i+1] >> y[i+1];
  P now = make_pair(0, 0);
  rep(i, n) {
    int dist = abs(now.first - x[i+1]) + abs(now.second - y[i+1]);
    if(dist > t[i+1] - t[i] || (t[i+1] - t[i] - dist) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
    now.first = x[i+1];
    now.second = y[i+1];
  }
  cout << "Yes" << endl;
}


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

const long long Mod=1e9+7;

inline long long All(int x)
{
	long long res=1;
	for(int i=2;i<=x;i++) res=res*i%Mod;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	
	if(abs(n-m)>1) {cout<<0;return 0;}
	
	long long ans=All(n)*All(m);
	if(n==m) ans*=2;
	
	ans%=Mod;
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b,s=0,t=0;
  cin >> n >> m;
  for(int i=0; i<m; i++){
	cin >> a >> b;
	  if(a<n){
	  	t += n-a;
		s = max(s,n-a);
	  }
  }
  t -= s;
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long int


static long long c[1000001];

int main()
{
    ll N ;
    scanf("%lld",&N);

    memset(c,0,sizeof(c[0]) * N);

    for (ll i = 1; i<=N; i++)
        c[i]=i;

    for (ll i = 1; i<=N; i++)
    {
        if (c[i]%3==0 && c[i]%5==0)
            c[i]=0;

        else if (c[i]%3==0  && c[i]%5!=0)
            c[i]=0;
        else if (c[i]%3!=0  && c[i]%5==0)
            c[i]=0;
    }

    ll sum = 0;
    for (ll i = 1; i<=N; i++)
        sum+=c[i];

    printf("%lld",sum);

    return 0;

}


Measured memory_bytes: 9492
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <memory.h>
#include <stdlib.h>


int main(void)
{	
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	
	a=a-x;
	b=b-x;
	
	if(a<0){
		a*=-1;
	}
	if(b<0){
		b*=-1;
	}
	
	if(a>b){
		printf("B\n");
	} else{
		printf("A\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf,exp
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.862 #ループの時間制限  
A=26 #アルファベットの数
START=time.time()

TEMP=10 #アニーリング法の初期温度
ICE=0.000001 #アニーリング法で更新毎に減少する温度
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[True]+list(map(int,input().split())) #減る満足度のベース
S=[True]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<=TIME_LIMIT:
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    Delta=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    if (Delta>=0) or (Delta<0 and random()<exp(Delta/TEMP)):
        T[d]=q
    TEMP-=ICE
    
for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 92392
n = int(input())
p = list(map(int, input().split()))
i=0
ans =0
while i<n-1:
    if p[i]==i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
    i+=1
if p[n-1]==n:
    ans+=1
print(ans)


Measured memory_bytes: 20636
s = gets.chomp.split("")[0...-1]
ctn = []

(0..(s.count-2)).each do |i|
    (0..s[0..(-(1+i))].count/2).each do |i2|
       if s[0..(-(1+i))].join == (s[0..i2]*2).join
         ctn << s[0..(-(1+i))].count
       end
    end
end

puts ctn.max

Measured memory_bytes: 2556
def main():
    n = int(input())
    *v, = map(int, input().split())

    v0 = assemble(v[::2])
    v1 = assemble(v[1::2])

    if len(v0) == 1 and len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print(n // 2)
        else:
            print(0)
        return
    elif len(v0) == 1:
        if v0[0][0] == v1[0][0]:
            print(sum_v(v1, 1))
        else:
            print(sum_v(v1, 0))
        return
    elif len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print(sum_v(v0, 1))
        else:
            print(sum_v(v0, 0))
        return

    score = [[0, 0], [0, 0]]
    for i in range(2):
        for j in range(2):
            score[i][j] = sum_v(v0, i) + sum_v(v1, j)
            if v0[i][0] == v1[j][0]:
                score[i][j] = 10 ** 9
    print(min([min(s) for s in score]))


def assemble(v):
    dct = {}
    for vel in v:
        if vel in dct:
            dct[vel] += 1
        else:
            dct[vel] = 1
    return sorted(list(dct.items()), key=lambda x: x[1], reverse=True)


def sum_v(v, ii):
    return sum([vv[1] for i, vv in enumerate(v) if i != ii])


main()


Measured memory_bytes: 20336
//
// Created by Myabu on 2020/01/27.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int A, B;

    cin>>A>>B;

    int ans = 0;
    for (int i = A; i <= B; ++i) {
        string X = to_string(i);
        string Y = X;
        reverse(Y.begin(), Y.end());

        if(X == Y){
            ans ++;
        }
    }

    cout<<ans<<endl;


    return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll unsigned long long
#define endl "\n"

void solve()
{
	ll n,final=0;
	cin>>n;
	ll cnt[n+1]={0};
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i;j<=n;j+=i)
		{
			cnt[j]++;
		}
	}
	for(ll i=1;i<=n;i++) final+=cnt[i]*i;
	cout<<final;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 81768
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

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

    int ans = 1e+8;

    for (int t = 1; t <= N; ++t) {
        int s1 = 0;
        int s2 = 0;

        for (int i = 0; i < N; ++i) {
            if (i <= t) {
                s1 += W[i];
            } else {
                s2 += W[i];
            }
        }

        ans = min(ans, abs(s1 - s2));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, ans, temp;
    cin >> n;
    temp = n % 1000;
    if(temp==0){
        cout << "0\n";
    }else{
        cout << 1000-temp << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
# 凸包 Monotone Chain O(nlogn)
# 参考: https://matsu7874.hatenablog.com/entry/2018/12/17/025713
def get_convex_hull(points):
    def det(p, q):
        return p[0] * q[1] - p[1] * q[0]
    def sub(p, q):
        return (p[0] - q[0], p[1] - q[1])
    points.sort()
    ch = []
    for p in points:
        while len(ch) > 1:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(p, ch[-2])
            if det(v_cur, v_new) > 0:
                break
            ch.pop()
        ch.append(p)
    t = len(ch)
    for p in points[-2::-1]:
        while len(ch) > t:
            v_cur = sub(ch[-1], ch[-2])
            v_new = sub(p, ch[-2])
            if det(v_cur, v_new) > 0:
                break
            ch.pop()
        ch.append(p)
    return ch[:-1]
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
ps = [(0, 0)]
for x, y in XY:
    ps_new = ps[:]
    for x_, y_ in ps:
        ps_new.append((x+x_, y+y_))
    ps = get_convex_hull(ps_new)
ans = 0
for x, y in ps:
    ans = max(ans, x*x+y*y)
print(ans ** 0.5)

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

using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}

template <class T>
void print(T &x) { cout << x << "\n"; }

int dp[5005][5005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    for(int i=N-1; i>=0;i--){
        for(int j=N-1;j>i;j--){
            if (S[i] == S[j]){
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }
    int ans = 0;
    REP(i,N)REP(j,N){
        int len = min(j-i, dp[i][j]);
        ans = max(ans,len);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 194944
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int ceil(double num){
    if((double)((int)num) != num) return (int)num + 1;
    else return (int)num;
}

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(ceil((double)A / D) >= ceil((double)C / B)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n < 1200) cout << "ABC" << endl;
  else if(n < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m,k = inpm()
    uf = UnionFind(n)
    ok = [0 for _ in range(n)]
    block = []
    for _ in range(m):
        a,b = inpm()
        uf.union(a-1,b-1)
        ok[a-1] += 1
        ok[b-1] += 1
    for _ in range(k):
        c,d = inpm()
        block.append((c-1,d-1))
    ans = [-1 for _ in range(n)]
    for i in range(len(block)):
        [x,y] = block[i]
        if uf.same(x,y):
            ans[x] -= 1
            ans[y] -= 1
    for i in range(n):
        ans[i] += uf.size(i)-ok[i]
    print(*ans)
    
if __name__ == "__main__":
    main()

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int tot = 0;
    for(auto it : s)
        tot += it - '0';
    if(tot%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<stdio.h>
main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if(A == B && A != C) printf("Yes");
    else if(A == C && A != B) printf("Yes");
    else if(B == C && B != A) printf("Yes");
    else printf("No");
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D, N;
    cin >> D >> N;
    int base = 1;
    for(int i = 0; i < D; i++)
    {
        base *= 100;
    }
    if(N == 100)
    {
        N++;
    }
    cout << base * N << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0;i<n;i++)
typedef vector<long> vec;
int main(){
  long n,x;
   x=0;
  
  cin>>n;
  vec A(n);
  rep(i,n) cin>>A[i];
  sort(A.begin(), A.end());
  
  rep(i,n-1){if(A[i]==A[i+1])x++;}
  
  
  cout<<(x? "NO":"YES");
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char str[100005];

int main(){
    int a=0, b=0;
    scanf("%s", str);
    for(int i=0; i<strlen(str); i++){
        if(str[i] == '1')
            a++;
        else 
            b++;
    }
    printf("%d\n", a>b?2*b:2*a);
    return 0;
}


Measured memory_bytes: 384
w,a,b=map(int,input().split())
if a<b:
    if b-(a+w)>0:
        print(b-(a+w))
    else:
        print(0)
elif a>b:
    if a-(b+w)>0:
        print(a-(b+w))
    else:
        print(0)
else:
    print(0)


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

typedef long long ll;

int main() {
	ll N, K;
	std::cin >> N >> K;

	ll ans = N / K;
	ans *= ans * ans;
	if(K % 2 == 0) {
		ll sub = (K <= 2 * N) ? 1 : 0;
		sub += (2 * N - K) / (2 * K);
		sub *= sub * sub;
		ans += sub;
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int h,w;
  int h_flag[100] = {};
  int w_flag[100] = {};
  scanf("%d %d",&h,&w);
  scanf("\n");
  char c[100][100];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%c",&c[i][j]);
      if(c[i][j] == '#'){
        h_flag[i] = 1;
      }
      scanf("\n");
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if(c[i][j] == '#'){
        w_flag[j] = 1;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(h_flag[i] == 1){
      for(int j=0;j<w;j++){
        if(w_flag[j] == 1){
          printf("%c",c[i][j]);
        }
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    M=int(input())
    # M = N # Nを変更したくなければ
    log = 0
    while M >= 2:
        M = M // 2
        log += 1
    ans=0
    for i in range(log+1):
        ans+=2**i
    print(ans)


resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int median(int a, int b, int c)
{
	vi v;
	v.pb(a); v.pb(b); v.pb(c);
	sort(v.begin(),v.end());
	return v[1];
}

int p[200001];
int n;

bool solve(vector<bool>& vec)
{
	bool ans = vec[0];
	for(int i = 0; i < n - 1; i++)
	{
		if(vec[n-1+i]==vec[n+i]) return vec[n-1+i];
		if(vec[n-1-i]==vec[n-2-i]) return vec[n-1-i];
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	int ans = 0;
	for(int i = 0; i < 2*n-1; i++)
	{
		cin>>p[i];
	}
	int lo = 1; int hi = 2*n-1;
	while(lo <= hi)
	{
		int mid = (lo+hi)>>1;
		vector<bool> vec(2*n-1);
		for(int i = 0; i < 2*n - 1; i++)
		{
			vec[i] = (p[i]>=mid);
		}
		if(solve(vec))
		{
			lo = mid + 1;
			ans = mid;
		}
		else
		{
			hi = mid - 1;
		}
	}
	cout << ans << '\n';
}


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

ll solve() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    swap(X,Y);
    swap(X,Z);
    cout << X << " " << Y << " " << Z << "\n";
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

mina = min(A)
maxa = max(A)
AA = [0]*(maxa-mina+1)

for i in range(N):
    maxj = maxa//A[i]
    for j in range(1,maxj+1):
        AA[j*A[i]-mina]+=1

ans = 0

for i in range(N):
    if AA[A[i]-mina] == 1:
        ans += 1
        
print(ans)

Measured memory_bytes: 32228
# -*- coding: utf-8 -*-


from sys import stdin


############################################

import numpy as np
# read data for n sequences.
n = stdin.readline().split()
a = int(n[0])

out = np.zeros(1000000)
out[0] = int(a)

for i,x in enumerate(out[:-1]):
    # do func.
    if a%2 == 0:
        a/=2
    else:
        a=a*3+1
    # check if m exists   
    if a in out:
        answer = i+2
        break
    out[i+1]=int(a)
    
print(int(answer))

Measured memory_bytes: 14664
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 0

for k in range(60):
    zero = 0
    one = 0
    for i in range(N):
        # A[i]のk桁目のbitが0か1か取り出す
        x = (A[i] >> k) & 1
        if x == 0: zero += 1
        else: one += 1
    ans += (2**k * (zero * one)) % mod

print(ans % mod)

Measured memory_bytes: 122808
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C,D,K = MAP()
    print(C*60+D-A*60-B-K)

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
var
	s,t : String;
	i,sum: Integer;
begin
	readln(s);
    readln(t);
	sum := 0;
	for i := 1 to 3 do begin
    	begin
    	if s[i] = t[i] then 
        	Inc(sum);
        end;
	end;
    writeln(sum);
end.

Measured memory_bytes: 128
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 2e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

int solve()
{

	ll n ;
	cin >> n ;
	cout << (n+1)/2 ;
}
int main()
{
	fast;
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}

	return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=n%10;
	if(a==2||a==4||a==5||a==7||a==9) cout<<"hon";
	else if(a==0||a==1||a==6||a==8) cout<<"pon";
	else cout<<"bon";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>

typedef long long ll;

int main()
{
  ll N;
  std::cin >> N;

  ll sum = 0;
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ll a;
    std::cin >> a;
    sum += a;
    if (a == 0 || i == N) {
      ans += sum / 2;
      sum = 0;
    }
  }

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


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

int *p,*rank;
int V,E,sum=0,n=0;
struct edge {
    int u;
    int v;
    int cost;
};
edge *e;
bool operator<(const edge& x, const edge& y) {
        return x.cost < y .cost;
}

void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
}

void link(int x, int y) {
    if(rank[x] > rank[y]) p[y] = x;
    else {
        p[x] = y;
        if(rank[x] == rank[y]) rank[y] = rank[y]+1;
    }
}

int findSet(int x) {
    if(x != p[x]) p[x] = findSet(p[x]);
    return p[x];
}

void unit(int x, int y) {
    link(findSet(x), findSet(y));
}

int kruskal() {
    sort(e, e+E);
    for(int i=0; n != V-1; i++) {
        if(findSet(e[i].u) != findSet(e[i].v)) {
            unit(e[i].u,e[i].v);
            sum += e[i].cost;  n++;
        }
    }
}

int main() {
    int s,t,w;
    cin >> V >> E;
    p = new int[V];
    rank = new int[V];
    e = new edge[E];
    for(int i=0; i<V; i++) makeSet(i);
    for(int i=0; i<E; i++) {
        cin >> s >>t >> w;
        edge a = {s,t,w};
        e[i] = a;
    }
    kruskal();
    cout << sum << endl;
    delete[] p,rank,e;

    return 0;
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>

using namespace std;

int main() {

	int weight;
	int temp[10];
	temp[9] = 512;
	vector<int> ans;

	for (int i = 8; i >= 0; i--)
		temp[i] = temp[i + 1] / 2;

	while (cin >> weight) {

		ans.clear();

		for (int i = 9; i >= 0; i--) {

			if (weight - temp[i] >= 0) {

				weight -= temp[i];
				ans.push_back(temp[i]);

			}
		}

		for (int i = ans.size() - 1; i > 0; i--)
			cout << ans[i] << " ";

		cout << ans[0] << "\n";

	}
	return 0;

}




Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  int a[n+1];
  for (int i=1; i<=n; i++) cin >> a[i];
  int res = 1e9;
  for (int i=-100; i<=100; i++)
  {
    int sum = 0;
    for (int j=1; j<=n; j++)
    {
      sum += (i-a[j])*(i-a[j]);
    }
    res = min(res, sum);
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int64

readIntArray ()
|> fun [| n; a; b |] ->
    let x = n / (a + b) * a
    let y = n % (a + b)
    if y < a then x + y else x + a
|> printfn "%d"


Measured memory_bytes: 30044
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a>=1&&a<=13&&b>=1&&b<=13){
if(a==b)
cout<<"Draw"<<endl;
else if(a==1)
cout<<"Alice"<<endl;
else if(b==1)
cout<<"Bob"<<endl;
else if(a>b)
cout<<"Alice"<<endl;
else
cout<<"Bob"<<endl;
}
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	_, A, B, C, D := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	S := nextLine()
	if strings.Contains(S[A-1:C], "##") || strings.Contains(S[B-1:D], "##") {
		fmt.Println("No")
		return
	}
	if C > D && !strings.Contains(S[B-2:D+1], "...") {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}

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

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

func min(a int, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, r;
    cin >> n >> r;
    cout << r + 100 * max(0, 10 - n);
    return 0;
}


Measured memory_bytes: 3652
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        a: i64,
        b: f64,
    }

    let b = (b * 100.00f64 + 0.1) as i64;

    println!("{}", (a * b) / 100);
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    queue< pal > q;
    ll nn = floor(sqrt(n));
    ll min = n-1;
    for(ll i=1; i<=nn; i++){
        if(n % i == 0) {
            ll dis = i + n/i - 2;
            if (dis < min) min = dis;
        }
    }
    cout << min << endl;
}  

Measured memory_bytes: 256
N, Q = map(int, input().split())
s = input()
X = [0] * N
for i in range(1, N):
    X[i] = X[i-1] + (1 if s[i-1:i+1] == "AC" else 0)

for _ in range(Q):
    l, r = map(int, input().split())
    print(X[r-1]-X[l-1])

Measured memory_bytes: 9668