akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
ll mod = 1000000007;
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	map<P, int> m;
	int zz = 0;
	int az = 0;
	int bz = 0;
	rep(i, n){
		ll ia, ib;
		cin >> ia >> ib;
		a[i] = ia;
		b[i] = ib;
		if(ia != 0 && ib != 0){
			ll gcd = __gcd(ia, ib);
			ia /= gcd;
			ib /= gcd;
			m[{ia, ib}]++;
		}else if(ia == 0 && ib == 0){
			zz++;
		}else if(ia == 0){
			az++;
		}else{
			bz++;
		}
	}
	ll ans = 1;
	rep(i, n){
		ll ia, ib;
		ia = a[i];
		ib = b[i];
		ll sum = 0;
		if(ia != 0 && ib != 0){
			ll gcd = __gcd(ia, ib);
			ia /= gcd;
			ib /= gcd;
			int g0 = m[{ia, ib}];
			g0 += m[{-ia, -ib}];
			int g1 = m[{ib, -ia}];
			g1 += m[{-ib, ia}];
			m[{ia, ib}] = 0;
			m[{-ia, -ib}] = 0;
			m[{ib, -ia}] = 0;
			m[{-ib, ia}] = 0;
			sum += modpow(2, g0);
			sum += modpow(2, g1);
			sum--;
			if(sum >= mod) sum %= mod;
			ans *= sum;
			if(ans >= mod) ans %= mod;
//			cout << ans << ' ' << g0 << ' ' << g1 << endl;
		}
	}
	ll sum0 = 0;
	if(az != 0 && bz != 0){
		sum0 += modpow(2, az);
		sum0 += modpow(2, bz);
		sum0--;
	}else if(az != 0){
		sum0 += modpow(2, az);
	}else if(bz != 0){
		sum0 += modpow(2, bz);
	}
	if(az != 0 || bz != 0){
		if(sum0 >= mod) sum0 %= mod;
		ans *= sum0;
	}
	ans += zz;
	ans--;
	if(ans >= mod) ans %= mod;
	if(ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 56212
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
#define ull unsigned long long

struct Data
{
    ll A;
    ll B;
    bool operator<(const Data &rhs) const
    {
        return B < rhs.B;
    }
};

void solve()
{
    ll N;
    cin >> N;
    vector<Data> data(N);
    for (ll i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        data.at(i) = {a, b};
    }

    sort(data.begin(), data.end());
    ll now = data.at(N - 1).B;
    now -= data.at(N - 1).A;
    if (now < 0)
    {
        cout << "No" << endl;
        return;
    }
    for (ll i = N - 2; i >= 0; i--)
    {
        if (now > data.at(i).B)
        {
            now = data.at(i).B;
        }
        now -= data.at(i).A;
        if (now < 0)
        {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
}

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


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  cout << (N+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;
const ll lr=1000000000000000000;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;
ll a[n+1];
rep(i,n){
	cin>>a[i];
}

sort(a+1,a+n+1);


ll val=1;

rep(i,n){
	if(a[i]==0){
		cout<<0<<endl;
		return 0;
	}
if(lr/val<a[i]){
	cout<<-1<<endl;
	return 0;
}
val*=a[i];
if(val>lr){
	cout<<-1<<endl;
	return 0;
}

}



cout<<val<<endl;
}




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

map<string, bool>m;
int n;
char previ;
string cur;

int main()
{
    while(cin >> n)
    {
        m.clear();
        for(int i = 1; i <= n; i++)
        {
            cin >> cur;
            if(m.count(cur) || (i > 1 && cur[0] != previ))
            {
                cout << "No" << endl;
                break;
            }
            m[cur] = 1;
            previ = cur[cur.size() - 1];
            if(i == n)
                cout << "Yes" << endl;
        }
    }

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;

	int sum = 0;
	rep(i, n) {
		sum += i + 1;
	}

	out(sum);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
	string s;
	map<char, int> m;

	cin >> s;

	for (char c : s) {
		m[c]++;
	}

	if (m.size() == 2 && m[s[0]] == 2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	} 
	return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 ll a[n+10],b[n+10];
 rep(i,0,n){
  sc(a[i]);sc(b[i]);
 }
 ans=0;
 rrp(i,n,0){
  if((a[i]+ans)%b[i]==0)continue;
  ans+=b[i]-(a[i]+ans)%b[i];
  //cout<<i<<" "<<ans<<endl;
 }
 pr(ans);
  
return 0;}

Measured memory_bytes: 5192
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

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

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

func main() {
	n := nextLine()

	ok := true
	ss := strings.Split(n, "")

	for idx, item := range ss {
		if (idx+1)%2 != 0 {
			switch item {
			case "R", "U", "D":
			default:
				ok = false
				break
			}
		} else {
			switch item {
			case "L", "U", "D":
			default:
				ok = false
				break
			}
		}
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int a[1005];
int main()
{
    int n;
    int max,min,i;
    while(~scanf("%d",&n))
    {
        max=-1;min=1000000;
        for(i=0;i<n;i++)
        {

        scanf("%d",&a[i]);
        if(a[i]<min)
            min=a[i];
        if(a[i]>max)
            max=a[i];
        }
        if(n>1)
        printf("%d\n",max-min);
        else
            printf("0");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; int L = S.size(); // L <= 100001
	long long int dp[100100][2] = {}; 
	dp[0][0] = 2; dp[0][1] = 1; 
	long long int P = 1000000007; 
	for(int i = 1; i < L; i++){
		if(S[i] == '0'){
			dp[i][0] = dp[i-1][0]; 
			dp[i][1] = (dp[i-1][1] * 3) % P; 
		}
		if(S[i] == '1'){
			dp[i][0] = (dp[i-1][0] * 2) % P; 
			dp[i][1] = (dp[i-1][0] + dp[i-1][1] * 3) % P; 
		}
	}
	cout << (dp[L-1][0] + dp[L-1][1]) % P << endl; 
}

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

const int INF = 1e+9;

int main() {
	string s;
	int cnt = 0;
	while(cin >> s){
		string t = s;
		reverse(t.begin(), t.end());
		if(t == s)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int ans=1,prev=a[0],count=1;
    for(int i=1;i<n;i++){
        if(prev==a[i])count++;
        else{prev=a[i];count=1;}
        if(count%2)ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int n;
	while( cin >> n, n ){
		int cnt = 0;
		while( n != 6174 ){
			int a[4] = { (n/1000), (n/100)%10, (n/10)%10, n%10 };
			if( a[0] == a[1] && a[1] == a[2] && a[2] == a[3] ){
				cout << "NA" << endl;
				cnt = -1;
				break;
			}
			sort( a, a+4 );
			int s = a[0]*1000 + a[1]*100 + a[2]*10 + a[3];
			int l = a[3]*1000 + a[2]*100 + a[1]*10 + a[0];
			n = l-s;
			cnt++;
		}
		if( cnt >= 0 )
			cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

char a[302][302],b[302][302];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	ll ans=0;
	for(ll B=0;B<n;B++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				ll nex=j+B;
				nex%=n;
				b[i][nex]=a[i][j];
			}
		}
		bool ch=true;
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				if(b[i][j]!=b[j][i]){
					ch=false;
				}
			}
		}
		if(ch){
			ans+=n;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 384
from sys import stdin, setrecursionlimit


class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0:
            x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        p = self.parent
        if x != y:
            if x > y:
                x, y = y, x
            p[x], p[y] = p[x] + p[y], x

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

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


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    ans = n - m
    f = UnionFindTree(n)
    for _ in range(m):
        x, y, z = map(int, input().split())
        if f.same(x - 1, y - 1):
            ans += 1
        f.union(x - 1, y - 1)
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 50008
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   int n,k;
   cin>>n>>k;
   long long int sum=1;
   for(int i=1;i<=n;i++)
   {
        sum=min(2*sum,sum+k);
   }
   cout<<sum;



 return 0;
}








Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(D);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a) {
  int sum = 0;
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
  }
  return sum;
}

void solve() {
  int sum = 0, y = 0;
  for (int i = 0; i < 26; i++) {
    vi a(D, i);
    int x = simulate(a);
    if (x > sum) {
      sum = x;
      y = i;
    }
  }

  ans = vi(D, y);
}

int main() {
  input();
  solve();
  output();
}


Measured memory_bytes: 3728
#include <stdio.h>

int main() {
	int N, M;
	int sum = 0;
	int j;

	scanf("%d %d", &N, &M);
	for (int i = 0;i < M;i++) {
		scanf("%d", &j);
		sum = sum + j;
	}

	if (sum > N) {
		printf("-1");
	}
	else {
		printf("%d", N - sum);
	}

	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    ll x, y; cin >> x >> y;

    ll cnt = 0;

    while(x <= y){
        cnt++;
        x *= 2;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

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

int main() {
    init();
    ll N;
    cin >> N;
    vl P(N);
    rep(i, N) cin >> P[i];
    ll th = 40000;
    vl A(N), B(N);
    rep(i,N){
        A[i] = th * (i + 1);
        B[i] = th * (N - i);
    }
    rep(i,N){
        A[P[i] - 1] += i;
    }
    rep(i, N) cout << A[i] << " ";
    cout << endl;
    rep(i, N) cout << B[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  cout << x2-(y2-y1) << " " << y2+(x2-x1) << " ";
  cout << x1-(y2-y1) << " " << y1+(x2-x1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=a*(n/(a+b)),x=n%(a+b);
    cout<<ans+min(a,x);
    subt;
    return 0;
}

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

long long n;
string s;
int ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n >> s;
}

void solve(){
    for(int i = 0; i <= n - 3; i++)
        if(s.substr(i, 3) == "ABC")
            ans++;
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque

def main():
    n=int(input())
    Edges=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=map(int,input().split())
        a-=1; b-=1
        Edges[a].append(b)
        Edges[b].append(a)
    Depth=[-1]*n
    Depth[0]=0
    q=deque()
    q.append(0)
    while q:
        fr=q.popleft()
        for to in Edges[fr]:
            if Depth[to]==-1:
                Depth[to]=Depth[fr]+1
                q.append(to)
    Group=[[] for _ in range(2)]
    for i in range(n):
        Group[Depth[i]%2].append(i)
    l_even,l_odd=len(Group[0]),len(Group[1])
    Ans=[0]*n
    Used=[False]*(n+1)
    if l_even<=l_odd:
        if l_even<=n//3:
            tmp_3=3;tmp_others=1
            for i in Group[0]:
                Ans[i]=tmp_3
                Used[tmp_3]=True
                tmp_3+=3
            for i in Group[1]:
                while Used[tmp_others]:
                    tmp_others+=1
                Ans[i]=tmp_others
                Used[tmp_others]=True
            return Ans
    else:
        if l_odd<=n//3:
            tmp_3=3;tmp_others=1
            for i in Group[1]:
                Ans[i]=tmp_3
                Used[tmp_3]=True
                tmp_3+=3
            for i in Group[0]:
                while Used[tmp_others]:
                    tmp_others+=1
                Ans[i]=tmp_others
                Used[tmp_others]=True
            return Ans
    tmp_even=1;tmp_odd=2;tmp_others=3
    for i in Group[0]:
        if tmp_even<=n:
            Ans[i]=tmp_even
            tmp_even+=3
        else:
            Ans[i]=tmp_others
            tmp_others+=3
    for i in Group[1]:
        if tmp_odd<=n:
            Ans[i]=tmp_odd
            tmp_odd+=3
        else:
            Ans[i]=tmp_others
            tmp_others+=3
    return Ans
    
if __name__=='__main__':
    Ans=main()
    print(*Ans)

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

struct Edge {
    int to, cost;
};

vector<Edge> G[100000];
bool visited[100000];
int number[100000];

bool dfs(int v, int num) {
    visited[v] = true;
    number[v] = num;

    bool result = true;
    for (Edge& e : G[v]) {
        if (not visited[e.to]) {
            result &= dfs(e.to, num + e.cost);
        } else if (number[e.to] != num + e.cost) {
            result = false;
        }
    }
    return result;
}

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

    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int L, R, D;
        cin >> L >> R >> D;
        L--; R--;

        G[L].push_back((Edge){R, D});
        G[R].push_back((Edge){L, -D});
    }

    for (int v = 0; v < N; v++) {
        if (not visited[v] and not dfs(v, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

template<class T> struct dual_segment_tree {
	using F = function<T(T, T)>;
	using value_type = T;
private : 
	int n, hight;
	const F f;
	value_type ie;
	vector<value_type> node;

public : 
	dual_segment_tree (const F &f, const value_type &ie) : f(f), ie(ie) { }
	
	void resize (int _n) {
		n = 1; hight = 0;
		while (n < _n) { n <<= 1; hight++; }
		node.resize(2 * n);
		fill(node.begin(), node.end(), ie);
	}

	void resize (int _n, const value_type &e) {
		n = 1; hight = 0;
		while (n < _n) { n <<= 1; hight++; }
		node.resize(2 * n);
		fill(node.begin(), node.end(), ie);
		for (int i = n; i < 2 * n; i++) node[i] = e;
	}

	void build (auto l, auto r) {
		resize(r - l);
		for (int i = n; l != r; i++, l++) node[i] = (*l);
	}

	void propagate (int i) {
		if (node[i] == ie) return;
		node[i << 1 | 0] = f(node[i << 1 | 0], node[i]);
		node[i << 1 | 1] = f(node[i << 1 | 1], node[i]);
		node[i] = ie;
	}

	inline void apply (int i) {
		for (int j = hight; j > 0; j--) propagate(i >> j);
	}

	void update (int a, int b, const value_type &x) {
		apply(a + n); apply(b + n - 1);
		for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) { node[l] = f(node[l], x); l++; }
			if (r & 1) { r--; node[r] = f(node[r], x); }
		}
	}

	const value_type &operator[] (int i) {
		apply(i + n);
		return node[i + n];
	}

	void swap (dual_segment_tree &s) {
		(this->node).swap(s.node);
	}

};


int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &e : a) cin >> e;
	
	auto f = [](int a, int b) { return (a + b); };
	dual_segment_tree<int> seg(f, 0);
	seg.build(a.begin(), a.end());

	for (int _ = 0; _ < k; _++) {
		dual_segment_tree<int> buff(f, 0);
		buff.resize(n);
		for (int i = 0; i < n; i++) {
			int d = seg[i];
			buff.update(max(0, i - d), min(n, i + d + 1), 1);
		}
		bool fin = true;
		for (int i = 0; i < n; i++) {
			fin &= (buff[i] == n);
		}
		seg.swap(buff);
		if (fin) break;
	}
	
	for (int i = 0; i < n; i++) cout << seg[i] << ' ';
	
	return 0;
}

Measured memory_bytes: 8284
S = input()
a = int(S[0]+S[1])
b = int(S[2]+S[3])
if a > 12 and b >12:
  print('NA')
if (a == 0 and b >12) or (b ==0 and a > 12) or (a==0 and b ==0):
  print('NA')
elif a == 0:
  print('YYMM')
elif b == 0:
  print('MMYY')
elif  a <= 12 and b <= 12:
  print('AMBIGUOUS')
elif a <= 12 and b > 12:
  print('MMYY')
elif a > 12 and b <= 12:
  print('YYMM')

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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n;i++){
    int count=0;
    for(int j=i;j<n;j++){
      if(!(s.at(j)=='A'||s.at(j)=='T'||s.at(j)=='G'||s.at(j)=='C')) break;
      count=j-i+1;
    }
    ans=max(ans,count);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        string[] readSome = new string[3];
        readSome = Console.ReadLine().Split(' ');
        int W = int.Parse(readSome[0]);
        int H = int.Parse(readSome[1]);
        int N = int.Parse(readSome[2]);
        int a = 0;
        int xMin = 0;
        int xMax = W;
        int yMin = 0;
        int yMax = H;
        for (int i = 0; i < N; i++) {
            readSome = Console.ReadLine().Split(' ');
            a = int.Parse(readSome[2]);
            if (a == 1) {
                xMin = Math.Max(xMin,int.Parse(readSome[0]));
            } else if (a == 2) {
                xMax = Math.Min(xMax,int.Parse(readSome[0]));
            } else if (a == 3) {
                yMin = Math.Max(yMin,int.Parse(readSome[1]));
            } else {
                yMax = Math.Min(yMax,int.Parse(readSome[1]));
            }
        }
        W = Math.Max(xMax - xMin,0);
        H = Math.Max(yMax - yMin,0);
        Console.WriteLine(W*H);
    }
}

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

int main()
{
    int N,M;
    cin >> N >> M;
    vector<vector<int> > connect(N+1,vector<int>(N+1,0));

    for (int i=0; i<M; ++i)
    {
        int row,col;
        cin >> row >> col;
        connect[row][col] = connect[col][row] = 1;
        // cout << connect[row][col] << endl;
    }

    // for(int i=0; i<N; ++i)
    // {
    //     for (int j=0; i<N; ++j)
    //     {
    //         cout << connect[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    // cout << N << " " << M << endl;
    // for (int i=1; i<N+1; ++i)
    // {
    //     for (int j=1; j<N+1; ++j)
    //     {
    //         cout << connect[i][j] << " ";
    //     }
    //     cout << "" << endl;
    // }

    int cnt = 0;
    bool can = true;
    vector<int> v;
    for (int i=0; i<N-1; ++i)
    {
        v.push_back(i+2);
    }
    do {
        for (int i=0;i<v.size()-1;++i)
        {
            if( i==0 )
            {
                if(connect[1][v[i]] != 1)
                {
                    can = false;
                    break;
                }
            }

            if(connect[v[i]][v[i+1]] != 1)
            {
                can = false;
                break;
            }
        }
        if(can) ++cnt;
        can = true;
    } while (next_permutation(v.begin(), v.end()));


    // int pem = 0;
    // for (int bit=0; bit < (1<<N-1); ++bit)
    // {   
    //     vector<int> S;
    //     for (int i=0; i<N-1; ++i)
    //     {
    //         if(bit & (1<<i))
    //         {
    //             S.push_back(i);
    //         }
    //     }

    //     bool can = true;
    //     if (S.size() < N-1) continue; //すべての頂点を訪れているか
    //     for( int i=0; i<S.size(); ++i)
    //     {
    //         if(i==0)
    //         {
    //             if (connect[1][S[i]+2] != 1)
    //             {
    //                 can = false;
    //                 break;
    //             } 
    //         }
    //         else
    //         {
    //             if (connect[S[i-1]+2][S[i]+2] != 1)
    //             {
    //                 can = false;
    //                 break;
    //             } 
    //         }
    //     }

        // // bit の表す集合の出力
        // cout << bit << ": {";
        // for (int i = 0; i < (int)S.size(); ++i) {
        //     cout << S[i] << " ";
        // }
        // cout << "}" << endl;

        // if (can) ++pem;

    // }

    // for(int i=0; i<M; ++i)
    // {
    //     for (int j=0; i<M; ++j)
    //     {
    //         cout << connect[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << cnt << endl;
    return 0;
}

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

using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


int main() {

	string s,t;
	cin >> s >> t;

	vector<vector<ll>> dp(s.size()+1,vector<ll>(t.size()+1,0));
	rep(i,s.size()){
		rep(j,t.size()){
			if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
			chmax(dp[i+1][j+1],dp[i][j+1]);
			chmax(dp[i+1][j+1],dp[i+1][j]);
		}

	}


	string ans="";
/*
	debug(dp);
	if(dp[i][j]==0)return 0;
	while(i > 0 && j > 0){
		while(dp[i][j] == dp[i-1][j])i--;
		while(dp[i][j] == dp[i][j-1])j--;
		i--;
		j--;
		ans=s[i]+ans;
	}
	*/
	int i=s.size();
	int j=t.size();
	if(dp[i][j]==0)return 0;
	while(i > 0 && j > 0){
		if (dp[i][j] == dp[i - 1][j])i--;
		else if (dp[i][j] == dp[i][j - 1])j--;
		else {
			i--; j--;
			ans = s[i] + ans;
		}
	}
	p(ans);
	return 0;
}



Measured memory_bytes: 70784
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [readline().strip() for _ in range(N)]
    
    c = Counter(S)
    
    print(f'AC x {c["AC"]}')
    print(f'WA x {c["WA"]}')
    print(f'TLE x {c["TLE"]}')
    print(f'RE x {c["RE"]}')
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74924
h,w = map(int,input().split())
a = list(map(lambda x: int(x)-1, input().split()))
b = list(map(lambda x: int(x)-1, input().split()))
check1 = [0 for _ in range(h*w)]
check2 = [0 for _ in range(h*w)]
check  = [0 for _ in range(h*w)]
for x in a:
  check[x]  += 1
  check1[x] += 1
for y in b:
  check[y]  += 1
  check2[y] += 1
if max(check1) >= 2 or max(check2) >= 2:
  print(0)
  exit()
check.reverse()
m = [[0 for _ in range(w)] for _ in range(h)]
seen = [0 for _ in range(h*w)]
for i in range(h):
  for j in range(w):
    tmp = min(a[i],b[j])
    m[i][j] = tmp
    seen[tmp] += 1
#print(m)
seen.reverse()
mod = 10 ** 9 + 7
ans = 1
cnt = 0
#print(seen)
can = []
for k in range(h*w):
  cnt += seen[k]
  if check[k] == 0:
    ans *= cnt
    ans %= mod
    can.append(cnt)
  elif check[k] == 1:
    ans *= seen[k]
    ans %= mod
    can.append(seen[k])
  else:
    can.append(1)
  cnt -= 1
#print(seen)
#print(check)
print(ans)
#print(can)

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

int main(){
	int n,a = 100000;
	cin >> n;
	for( int i = 0; i < n; i++ ){
		a = a*0.05 + a;
		if(a % 1000 > 0){
			a = a / 1000 * 1000 + 1000;
		}
	}
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
const int N = 1e5 + 5;
int ans[N];
int h[N];
char grid[1009][1009];
int ans2[1009][1009];
int hap[N][3];
int ans3[N][3];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i = 0 ; i < n ; i++)cin>>h[i];
    ans[0]=0;

    for(int i = 1; i < n ; i++){
        ans[i] = 1e9;
        for(int j = i-1;j>=max(i-k,0);j--){
            ans[i] = min(ans[i],abs(h[i]-h[j])+ans[j]);
        }
    }
    cout<<ans[n-1];
//    int n;
//    cin>>n;
//    for(int i = 0 ; i < n ; i++)cin>>h[i];
//
//    for(int i = 0 ; i < n ; i++){
//        ans[i] = 1;
//        for(int j = 0 ; j < i ; j++){
//            if(h[i]>h[j])ans[i] = max(ans[j]+1,ans[i]);
//        }
//    }
//    int mx = 0;
//    for(int i = 0 ; i < n ; i++)if(ans[i]>mx)mx=ans[i];
//    cout<<mx;
//    int h,w;
//    cin>>h>>w;
//    for(int i = 0 ; i < h ; i++){
//        for(int j = 0 ; j < w ; j++)cin>>grid[i][j];
//    }
//    ans2[0][0]=1;
//    for(int i = 0 ; i < h ; i++){
//        for(int j = 0 ; j < w ; j++){
//
//            if(grid[i][j]=='#'){
//                ans2[i][j]=0;
//                continue;
//            }
//            if(j)ans2[i][j] =  ((ans2[i][j]%mod) + (ans2[i][j-1]%mod))%mod;
//            if(i)ans2[i][j] =  ((ans2[i][j]%mod) + (ans2[i-1][j]%mod))%mod;
//        }
//    }
//    cout<<ans2[h-1][w-1];
//    int n;
//    cin>>n;
//    for(int i = 0 ; i < n ; i++){
//        for(int j = 0 ; j < 3 ; j++)cin>>hap[i][j];
//    }
//    ans3[0][0] = hap[0][0]; ans3[0][1] = hap[0][1]; ans3[0][2] = hap[0][2];
//    for(int i = 1 ; i < n ; i++){
//        ans3[i][0] = max(ans3[i-1][1],ans3[i-1][2])+hap[i][0];
//        ans3[i][1] = max(ans3[i-1][0],ans3[i-1][2])+hap[i][1];
//        ans3[i][2] = max(ans3[i-1][0],ans3[i-1][1])+hap[i][2];
//    }
//    cout<<max(ans3[n-1][0],max(ans3[n-1][1],ans3[n-1][2]));
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	in := nextInt
	type Point struct {
		x, y int
	}

	n := in()
	pb := make([]Point, n)
	for i := 0; i < n; i++ {
		pb[i].x = in()
		pb[i].y = in()
	}

	m := make(map[Point]int)
	for a := 0; a < n; a++ {
		for b := 0; b < n; b++ {
			if a == b {
				continue
			}

			x := pb[a].x - pb[b].x
			y := pb[a].y - pb[b].y
			m[Point{x, y}]++
		}
	}

	max := 0
	for _, v := range m {
		if max < v {
			max = v
		}
	}

	ans := n - max

	fmt.Println(ans)
}

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 anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto & a : A)
    cin >> a;
  sort(A.begin(), A.end());
  if ((0 == N%2) && (1 != A[0]))
  {
    cout << 0;
    return 0;
  }
  else if ((0 != N%2) && (0 != A[0]))
  {
    cout << 0;
    return 0;
  }
  int i = ((0 == N%2) ? 0 : 1);
  int j = ((0 == N%2) ? 1 : 2);
  for (; i < N; i += 2, j += 2)
  {
    if ((j != A[i]) || (j != A[i + 1]))
    {
      cout << 0;
      return 0;
    }
  }
  int cnt = 1;
  for (int k = 0; k < N/2; ++k)
  {
    cnt <<= 1;
    cnt = cnt%1000000007;
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 2003
#define MOD 1000000007

int n, m;
int s[N], t[N];

vector<P> ps;

ll data[N+30];
ll get(int k) {
  ll s = 0;
  while(k) {
    s = (s + data[k]) % MOD;
    k -= k & -k;
  }
  return s % MOD;
}
void add(int k, ll x) {
  while(k <= m) {
    data[k] = (data[k] + x) % MOD;
    k += k & -k;
  }
}

int main() {
  cin >> n >> m;
  rep(i, n) cin >> s[i];
  rep(i, m) cin >> t[i];
  rep(i, n) {
    rep(j, m) {
      if(s[i] == t[j]) {
        ps.push_back(P(i, -j));
      }
    }
  }
  sort(ALL(ps));
  ll s = 0;
  for(P &pr : ps) {
    int p = pr.first, q = -pr.second;
    ll v = get(q+1) + 1;
    add(q+2, v); s = (s + v) % MOD;
  }
  cout << (s + 1) % MOD << endl;
  return 0;
}

Measured memory_bytes: 34660
#include<bits/stdc++.h>
using namespace std;
main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    string S, T;
    cin >> S;
    cin >> T;
    int count = 0;
    for(int i = 0; i < 3; i++) {
    	if(S[i] == T[i]) {
    		count++;
		}
	}
	cout << count << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int N = int.Parse (Console.ReadLine ());

            int[] count = new int[100000];

            for (int x = 1; x < 100; x++)
            {
                for (int y = 1; y < 100; y++)
                {
                    for (int z = 1; z < 100; z++)
                    {
                        int k = x * x + y * y + z * z + x * y + y * z + z * x;
                        count[k] += 1;
                    }
                }
            }

            for (int i = 1; i <= N; i++)
            {
                Console.WriteLine (count[i]);
            }
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 27972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1005;
const int mod=1e9+7;
char c[maxn][maxn];
int dp[maxn][maxn];
int arr[maxn][maxn];

int solve(){
    int m,n;
    cin>>m>>n;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
            if(c[i][j]=='.'){
                dp[i][j]=0;
            }
            else {
                dp[i][j]=-1;
            }
        }
    }


    dp[0][0]=1;
    for(int i=0;i<m;i++){
       for(int j=0;j<n;j++){
        if(dp[i][j]==-1) continue;
        if(dp[i+1][j]!=-1) dp[i+1][j]+=dp[i][j]%mod;
        if(dp[i][j+1]!=-1) dp[i][j+1]+=dp[i][j]%mod;
       }
    }
   
    cout<< dp[m-1][n-1]%mod<<endl;
}


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

    solve();
    return 0;
    }


Measured memory_bytes: 7040
//============================================================================
// Name        : f.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n,s;cin>>n>>s;
	vector<int> a(n);
	vector<long long> v(s,0);
	v[0]=1;
	long long ans=0;
	long long def=998244353;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<=s){
			ans+=(n-i)*v[s-a[i]];
//			cout<<n-i<<' '<<v[s-a[i]]<<endl;
			ans%=def;
		}
		for(int j=s-1;j>=0;j--){
			if(j==0){
				v[j]=i+2;
				break;
			}
			if(j-a[i]>=0){
				v[j]+=v[j-a[i]];
				v[j]%=def;
			}
		}
//		for(int j=0;j<s;j++){
//			cout<<v[j]<<' ';
//		}cout<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define mod2 998244353
#define ll lli

using namespace std ;

#define N 200000+5 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

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

    lli n;
    cin>>n;

    lli a[n+1];
    loopl(i,1,n+1) cin>>a[i];

    lli b[n+1] = {0};
    lli cnt=0;
    for(lli i=n;i>=1;i--)
    {
        lli ans=0;
        for(lli j=2*i;j<=n;j+=i)
            ans += b[j];

        if(ans%2 == 0 && a[i]%2 == 1) b[i]=1;
        else if(ans%2 == 1 && a[i]%2 == 0) b[i]=1;

        if(b[i] == 1) cnt++;
    }

    cout<<cnt<<endl;
    loopl(i,1,n+1)
    {
        if(b[i] == 1) cout<<i<<" ";
    }
}



Measured memory_bytes: 3968
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
#print(A)
#print(N)
#print(B)
for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                A[j][k] = 0
#print(A)
for i in range(3):
    if (A[i][0] == A[i][1] == A[i][2] == 0):
        print("Yes")
        exit()
    if (A[0][i] == A[1][i] == A[2][i] == 0):
        print("Yes")
        exit()
if (A[0][0] == A[1][1] == A[2][2] == 0):
    print("Yes")
    exit()
elif(A[0][2] == A[1][1] == A[2][0] == 0):
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N,A,B,C;
vector<int> L;

int dfs(int n,int a,int b,int c){
	if(n == N){
		if(!min({a,b,c})) return 1e9;
		return abs(A - a) + abs(B - b) + abs(C - c) - 30;
	}

	int x =	dfs(n + 1,a,b,c);
	int y = dfs(n + 1, a + L[n], b, c) + 10;
	int z = dfs(n + 1, a, b + L[n], c) + 10;
	int q = dfs(n + 1, a, b, c + L[n]) + 10;
	return min({x,y,z,q});
}

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

	cin >> N >> A >> B >> C;

	REP(i,N){
		int x;
		cin >> x;
		L.push_back(x);
	}

	cout << dfs(0,0,0,0) << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  ll cnt = 0;
  cnt += a[0] - 1;
  a[0] = 1;
  int can_sell_min = 2;
  FOR (i, 1, n) {
    int num_sell = (a[i] - 1) / can_sell_min;
    if (num_sell == 0) {
      can_sell_min = max(can_sell_min, a[i] + 1);
      continue;
    }
    cnt += num_sell;
  }
  printf("%lld\n", cnt);

  return 0;
}


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

int main(){
  int n ; cin >> n ;
  bool one = false ;
  int block ;
  int check = 1 ;
  int ans = 0 ;
  for(int i=0;i<n;i++){
    cin >> block ;
    if(block==1)
      one = true ;
    if(block==check){
      check++ ;
    }else{
      ans++ ;
    }
  }
  if(!one){
    cout << -1 << endl ;
    return 0 ;
  }
  cout << ans << endl ;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int P[202020],T[202020];
ll V0[202020],V1[202020];
ll ret;

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;


pair<double,int> hoge(int v) {
	if(V0[v]==0) return {1e9,v};
	else return {1.0*V1[v]/V0[v],v};
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(i=1;i<N;i++) {
		cin>>P[i];
		P[i]--;
	}
	
	set<pair<double,int>> S;
	FOR(i,N) {
		cin>>x;
		V0[i]=(x==0);
		V1[i]=(x==1);
		T[i]=i;
		if(i) S.insert(hoge(i));
	}
	
	while(S.size()) {
		int cur=S.begin()->second;
		S.erase(S.begin());
		
		int par=uf[P[cur]];
		if(T[par]) S.erase(hoge(par));
		ret+=V1[par]*V0[cur];
		V0[cur]=V0[par]=V0[cur]+V0[par];
		V1[cur]=V1[par]=V1[cur]+V1[par];
		T[cur]=T[par];
		P[cur]=P[par];
		uf(par,cur);
		if(T[uf[par]]) S.insert(hoge(uf[par]));
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 21488