akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    bool is_prime[1000000];

    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<1000000;i++){
        is_prime[i]=true;
    }

    for(int i=2;i*i<1000000;i++){
        if(is_prime[i]){
            for(int j=i*i;j<1000000;j+=i){
                is_prime[j]=false;
            }
        }
    }

    int cnt=0;
    int n_prime[1000000];
    for(int i=0;i<1000000;i++){
        if(is_prime[i]) cnt++;

        n_prime[i]=cnt;
    }

    while(true){
        int n;
        cin>>n;

        if(cin.eof()) break;

        cout<<n_prime[n]<<endl;
    }

    return 0;
}


Measured memory_bytes: 8000
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        int[][] x = new int[N][3];
	        for (int i=0 ; i<N; i++) {
	            x[i][0] = Integer.parseInt(sc.next());
	            x[i][1] = Integer.parseInt(sc.next());
	            x[i][2] = Integer.parseInt(sc.next());
	        }
	        Arrays.sort(x, (b, c) -> Integer.compare(c[2], b[2]));
	        
	        for(int i=0;i<101;i++) {
	        	for(int j=0;j<101;j++) {
	        		long ans=x[0][2]+Math.abs(x[0][0]-i)+Math.abs(x[0][1]-j);
	        		boolean flg=true;
	        		for(int k=1;k<N;k++) {
	        			if(ans!=x[k][2]+Math.abs(x[k][0]-i)+Math.abs(x[k][1]-j)) {
	        				if(x[k][2]==0&&Math.abs(x[k][0]-i)+Math.abs(x[k][1]-j)>=ans)continue;
	        				flg=false;
	        				break;
	        			}
	        		}
	        		if(flg==true) {
	        			System.out.print(i);
	        			System.out.print(" ");
	        			System.out.print(j);
	        			System.out.print(" ");
	        			System.out.println(ans);
	        			return;
	        		}
	        	}
	        }

	        

	        
	        

	    }
	    
	    

	}

Measured memory_bytes: 28628
#include<bits/stdc++.h>
#include<bitset>
#include<random>
#include<time.h>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
  int n;
  cin>>n;
  int a, b;
  cin>>a>>b;
  ll sum = 0;
  repn(i, 1, n)
  {
    int c = i;
    int s = 0;
    while(c != 0)
    {
      s += c % 10;
      c = c / 10;
    }
    if(s >= a && s <= b) sum += i;
  }
  cout<<sum<<endl;
}


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

int main() {
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  if(a<b)b=a;
  if(b<c)c=b;
  if(c<d)d=c;
  if(d<e)e=d;
  cout<<(n+e-1)/e+4<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int h1,m1,h2,m2,k ; cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll ans = 60*(h2-h1-1) + m2 + (60-m1) - k;
    cout << ans << endl;
}


Measured memory_bytes: 3592
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
one = a.index(1)
# 個数
hidari = one
migi = n - (one+1)
# k回ためす
mini = 10**10
for i in range(k):
    hidarii = hidari - i
    migii = migi - (k - 1 - i)
    if hidarii < 0 or migii < 0:
        continue
    #if hidarii == 0 and migii == 0:
    #    mini = 0
    if hidarii == 0:
        cnt = (migii - 1)//(k-1) + 1
    elif migii == 0:
        cnt = (hidarii - 1)//(k-1) + 1
    else:
        cnt = (migii - 1)//(k-1) + 1 + (hidarii - 1)//(k-1) + 1
    mini = min(cnt, mini)
print(mini + 1)

Measured memory_bytes: 14008
int main()
{
    int N=0;      //input ball
    int K=0;      //input robbot tybe B Base
    int x[100]; //output move min
    
    int doub=0;
    int move_sum=0;
    
    int i; //used to for
  
    // 入力
    scanf("%d", &N);
    scanf("%d", &K);
    for(i=0; i<N; i++){
      scanf("%d", &x[i]);
      if(x[i] < (K - x[i])){
      doub = x[i];
      }
      else { 
      doub = K-x[i];
      }
      move_sum = move_sum + (doub * 2);
    }
    // 出力
    printf("%d\n", move_sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for (;;) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		int mi = 100000000;
		int ma = 0;
		int sum = 0;
		rep(i, n) {
			int a;
			cin >> a;
			mi = min(a, mi);
			ma = max(a, ma);
			sum += a;
		}
		sum -= (mi + ma);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;

int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
         
    // }
    ll n;
    cin>>n;
    vector<pair<ll,ll>>v(n);
    for(int i=0;i<n;i++)
    cin>>v[i].first>>v[i].second;
    for(int i=0;i<n-2;i++)
    {
        int flag=1;
        for(int j=i;j<n&&j<i+3;j++)
        {
            if(v[j].first!=v[j].second)
            flag=0;
        }
        if(flag)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 3652
A,B,K = map(int,input().split(' '))

for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A -= 1
        B += A//2
        A = A//2
    else:
        if B % 2 != 0:
            B -= 1
        A += B//2
        B = B//2
print("{} {}".format(A,B))

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	long n = sc.nextLong();
      	int cnt = 0;
      	int bor = 1;
      	int ans = 0;
      	long div = 2;
      	while(true){
          if( n % div == 0 ){
            //System.out.println(n);
            n /= div;
            cnt++;
            if( cnt == bor ){
              ans++;
              cnt = 0;
              bor++;
            }
          }else{
            div++;
            cnt = 0;
            bor = 1;
            if( div > n ){
            	break;
            }
            if( div * div > n  ){
              div = n;
            }
          }
          
        }
      System.out.println(ans);
	}
}

Measured memory_bytes: 27196
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
bool check(vector<int> v,int m,int x)
{
	if(v.empty())
	return false;
	for(int i=1;i<=m;i++)
	{
		if(v[i]<x)
		return false;
	}
	return true;
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n,m,x;
	 cin>>n>>m>>x;
	 int dp[n][m+1];
	 for(int i=0;i<n;i++)
	 {
	 	//cin>>dp[i][0];
	 	for(int j=0;j<=m;j++)
	 	{
	 		cin>>dp[i][j];
	 	}
	 }
	 int minCost=INT_MAX;
	 for(int b=0;b<(1<<n);b++)
	 {
	 	vector<int> v(m+1);
	 	for(int i=0;i<n;i++)
	 	{
	 		if((b&(1<<i))!=0)
	 		{
	 			//cout<<i<<" ";
	 			for(int j=0;j<=m;j++)
	 			{
	 				v[j]+=dp[i][j];
	 			}
	 		}
	 	}
	 	//cout<<'\n';
	 	if(check(v,m,x) && v[0]<minCost)
	 	minCost=v[0];
	 }
	 if(minCost==INT_MAX)
	 cout<<-1;
	 else
	 cout<<minCost;
	
	 return 0;
}

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

using namespace std;

typedef pair<int,int> pii;

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


int main(){
	map<string,vector<int> > m;
	string s;
	vector<string> v;
	char c[1000];
	int n;
	while(~scanf("%s%d",c,&n)){
		s=string(c);
		if(m[s].size()==0)v.push_back(s);
		m[s].push_back(n);
	}
	sort(v.begin(),v.end());
	rep(i,v.size()){
		cout << v[i] << endl;
		int l=m[v[i]].size();
		sort(m[v[i]].begin(),m[v[i]].end());
		rep(j,l)
			printf("%d%c",m[v[i]][j],j==l-1?'\n':' ');
	}
	return 0;
}

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

int eyeTest(double eyesight);

int main()
{
    double l;
    double r;
    int result_left[4] = {};
    int result_right[4] = {};
    while(cin >> l >> r)
    {
        result_left[eyeTest(l)]++;
        result_right[eyeTest(r)]++;
    }
    for(int i=0; i<4; i++)
    {
        cout << result_left[i] << " " <<result_right[i] << endl;
    }
    return 0;
}

int eyeTest(double eyesight)
{
    int ret_value;

    if(isgreaterequal(eyesight, 1.1))
    {
        ret_value = 0;
    }
    else if(isgreaterequal(eyesight, 0.6))
    {
        ret_value = 1;
    }
    else if(isgreaterequal(eyesight, 0.2))
    {
        ret_value = 2;
    }
    else
    {
        ret_value = 3;
    }
    return ret_value;
}

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

    # [0,i), [i,j), [j,k), [k, n)
    tot = sum(a)
    ret = tot

    i, k = 1, 3
    p, q, r, s = a[0], a[1], a[2], tot - sum(a[:3])

    for j in range(2, n - 1):
        while (i + 1 < j) and (abs(p - q + a[i] * 2) < abs(p - q)):
            p += a[i]
            q -= a[i]
            i += 1

        while (k + 1 < n) and (abs(r - s + a[k] * 2) < abs(r - s)):
            r += a[k]
            s -= a[k]
            k += 1

        ret = min(ret, max(p, q, r, s) - min(p, q, r, s))

        q += a[j]
        r -= a[j]

    print(ret)


if __name__ == '__main__':
    main()


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> vec (N);
    for(int i = 0;i < N;i++){
        cin >> vec[i];
    }
    double near = INF;
    int good = 0;
    for(int i = 0;i < N;i++){
//        cout << near << " > "  << abs(A - (T - vec[i] * 0.006)) << "?" << endl;
        if(abs(A - (T - vec[i] * 0.006)) < near){
            good = i;
            near = abs(A - (T - vec[i] * 0.006));
        }
    }
    cout << good+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;

ll n, m, k, fac[nax], faciv[nax], iv[nax];

ll pangkat (ll x, ll y){
	if(y == 0){
		return 1;
	}
	ll temp = pangkat(x, y / 2) % mod;
	temp = (temp * temp) % mod;
	if(y % 2 == 1){
		return (temp * x) % mod;
	}
	else{
		return temp;
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> m >> k;
	iv[1] = 1;
	for(ll i = 2; i <= n; i++){
		iv[i] = (mod - (mod / i) * iv[mod%i] % mod) % mod;
	}
	fac[0] = 1ll;
	for(ll i = 1; i <= n; i++){
		fac[i] = (i * fac[i-1]) % mod;
	}
	faciv[0] = 1;
	faciv[1] = 1;
	for(ll i = 2; i <= n; i++){
		faciv[i] = (faciv[i-1] * iv[i]) % mod;
	}
	ll ans = 0;
	for(ll i = 0; i <= k; i++){
		ll pilih = (fac[n - 1] * faciv[n-1-i] % mod) * faciv[i] % mod;
		ll comp = pangkat(m - 1, n - i - 1) % mod * m % mod;
		ll res = (pilih * comp) % mod;
		ans = (ans + res) % mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 8272
#include <stdio.h>
int main(void)
{
	int a, b, c, i;
	int count = 0;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	for (i = a; i <= b; i++) {
		if (c % i == 0) {
			count += 1;
		}
	}
	printf("%d\n", count);

	return 0;
}

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

using namespace std;

int main(void){
  int N;
  cin >> N;
  if(N & (N - 1)){
    cout << "Yes" << "\n";
  }else{
    cout << "No" << "\n";
    return 0;
  }
  cout << 1 << " " << 2 << "\n";
  cout << 2 << " " << 3 << "\n";
  cout << 3 << " " << N + 1 << "\n";
  cout << N + 1 << " " << N + 2 << "\n";
  cout << N + 2 << " " << N + 3 << "\n";
  for(int i = 4; i < N; i += 2){
    cout << i << " " << i + 1 << "\n";
    cout << i + 1 << " " << N + 1 << "\n";
    cout << i + N << " " << N + 1 << "\n";
    cout << i + 1 + N << " " << i + N << "\n";
  }
  if(N % 2 == 0){
    int b = 1;
    int NN = N;
    while(NN > 1){
        NN >>= 1;
        b <<= 1;
    }
    cout << N << " " << b + N << "\n";
    cout << 2 * N << " " << (b ^ N ^ 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
#define INF 1e9
using namespace std;
//for (int i = 0; i < N; i++){}
long long N, K;

int main() {
    cin >> N >> K;
    long long h[N];
    long long c[N];
    for (long long i = 0; i < N; i++){
        cin >> h[i];
        c[i] = INF;
    }

    c[0] = 0;
    c[1] = abs(h[1] - h[0]);
    for(long long i = 2; i < N; i++){
        for(long long j = 1; j <= K; j++){
            if((i - j) >= 0){
                c[i] = min(c[i], c[i-j] + abs(h[i] - h[i-j]));
            }else{
                break;
            }
        }
	}

    cout << c[N-1] << endl;
}

Measured memory_bytes: 1792
using System;


namespace atcoderれんしゅー
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');
            var answer = 0.0;
            for(int i=0;i < num;i++)
            {
                answer += 1 / double.Parse(a[i]);
            }
            Console.WriteLine(1 / answer);
            
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s, t;


int main()
{
	cin >> s;
	a = 0;
	rep(i, s.size())
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L')
				a++;
		}
		else
			if (s[i] == 'R')
				a++;
	}
	s = a > 0 ? "No" : "Yes";
	cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1000000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   vi a(n);
   rep(i,0,n)cin>>a[i];
   vi b(n);
   rep(i,0,n)cin>>b[i];
   reverse(all(b));
   vi v;
   vi val;
   for(int i=0;i<n;i++)
   {
       if(a[i]==b[i])
       {
           val.pb(i);
       }
   }
   if(val.size()>0)
   {for(int i=0;i<n;i++)
   {
       if(a[i]!=b[i] && a[i]!=a[val[0]] && b[i]!=a[val[0]])
       {
           v.pb(i);
       }
   }
   }
   if(val.size()>v.size())
   {
       cout<<"No"<<endl;
   }
   else
   {
       cout<<"Yes"<<endl;
       int j=0;
       for(int i=0;i<val.size();i++)
       {
           swap(b[val[i]],b[v[j]]);
           j++;
       }
       for(auto x:b)
        cout<<x<<" ";
       cout<<endl;
   }

}


Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int h, w; cin >> h >> w;
	vector<vector<vector<Int>>> dp(h, vector<vector<Int>>(w, vector<Int>(160*80+1, 0)));
	vector<vector<Int>> a(h, vector<Int>(w, 0));
	for(Int i=0; i<h; ++i)
		for(Int j=0; j<w; ++j)
			cin >> a[i][j];
	for(Int i=0; i<h; ++i)
		for(Int j=0; j<w; ++j){
			Int t; cin >> t;
			a[i][j] = abs(a[i][j] - t);
		}
	dp[0][0][a[0][0]] = 1;
	vector<Int> dx = {0, 1};
	vector<Int> dy = {1, 0};
	for(Int i=0; i<h; ++i)
		for(Int j=0; j<w; ++j){
			for(Int k=0; k<2; ++k){
				Int nx = i+dx[k];
				Int ny = j+dy[k];
				if(nx < h && ny < w){
					for(Int l=0; l<160*80+1; ++l){
						if(dp[i][j][l] == 1){
							dp[nx][ny][l+a[nx][ny]] = 1;
							dp[nx][ny][abs(l-a[nx][ny])] = 1;
						}
					}
				}
			}
		}
	Int ans = -1;
	for(Int i=0; i<160*80+1; ++i)
		if(dp[h-1][w-1][i] == 1){
			ans = i;
			break;
		}
	cout << ans << "\n";
}

Measured memory_bytes: 651532
#include <algorithm>
#include <string>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <cassert>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

int main(void)
{
    unsigned long long int x, y;
    cin >> x >> y;
    int i = 1;
    while (((unsigned long long int)(x << i)) <= y)
    {
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/


int prime[1000000] ;
vector < int > pr;
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            pr.pb(i);
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}


void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n)
{
    ll a = 0, b = 1, c, i;
    if( n == 0)
        return a;
    for (i = 2; i <= n; i++)
    {
        c = (a + b);
        a = b;
        b = c;
    }
    return b;
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair<long long,ll> &a , const pair<ll ,ll > &b){
    if(a.first == b.first)  return a.second < b.second;
    return a.first > b.first;

    return false;
}

void solve(){
    ll n;
    in(n);string str;
    int ac = 0 , wa = 0 ,tle = 0 ,re = 0;
    f(i,n){
    in(str);
    if(str == "AC") ++ac;
    else
    if(str == "WA") ++wa;
    else
    if(str == "TLE") ++tle;
    else
        ++re;
    }

    cout<<"AC x "<<ac<<el;
    cout<<"WA x "<<wa<<el;
    cout<<"TLE x "<<tle<<el;
    cout<<"RE x "<<re<<el;
}


int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644
def r;gets.split.map &:to_i;end
def rr(n);n.times.map{yield r};end

N,Q = r
G = Array.new(N){[]}
CNT = Array.new(N,0)

rr(N-1) do |a,b|
  a-=1;b-=1
  G[a] << b
  G[b] << a
end

rr(Q) do |v,x|
  v-=1
  CNT[v] += x
end

visited = Array.new(N)
queue = [[0,0]] # idx,weight
while queue.size > 0
  i,w = queue.shift
  visited[i] = true
  CNT[i] += w
  G[i].each do |j|
    next if visited[j]
    queue << [j, CNT[i]]
  end
end

puts CNT.join(" ")

Measured memory_bytes: 36036
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;
//絶対値
ll ze(ll x,ll y){
    return max(x,y)-min(x,y);
};
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    pair<int,int> mx = {0,-1};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(mx.first < a[i]) mx = {a[i],i};
    }    
    pair<int,int> ans ={mod,-1};
    for(int i = 0; i < n; i++){
        if(mx.second == i) continue;
        int can = min(ze(mx.first/2,a[i]),ze((mx.first+1)/2,a[i]));
        if(ans.first > can) ans = {can,a[i]};
    }
    cout << mx.first << " " << ans.second << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll n,m,ans;
  cin>>n>>m;
  vll L(m),R(m);
  for (ll i=0;i<m;i++) {
    cin >>L[i]>>R[i];
  }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  ans=max(R[0]-L[m-1]+1,(ll)0);
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
"use strict";

new Promise(function(resolve, reject) {
    let content = "";
    process.stdin.on("data", chunk => { content += chunk; })
    process.stdin.on("end", () => { resolve([content, process.stdout]); });
}).then(function([cin, cout]) {
    const data = cin.split("\n").map(elt => elt.split(" ")).filter(elt => elt.length === 2);
    data.map(elt => elt.map(e => parseInt(e))).forEach(elt => {
        cout.write(`${elt.reduce((car, cdr) => car + cdr, 0).toString().length}\n`);
    });
});



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}

int nextInt() {
  int x; scanf("%d", &x); return x;
}

int T[100000 + 10];

int main2() {
  int N = nextInt();
  int C = nextInt();
  int K = nextInt();
  REP(i, N) T[i] = nextInt();
  sort(T, T + N);
  int ans = 0;
  int c = 0;
  int limit = -1;
  REP(i, N) {
    int t = T[i];
    if (limit < t || c == C) {
      ans++;
      c = 0;
      limit = t + K;
    }
    c++;
  }
  cout << ans << endl;

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 640
/**
 *    author:  tourist
 *    created: 26.11.2019 09:10:09       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
 public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable {
 public:
  int n;
  vector<vector<T>> mat;
  F func;

  SparseTable(const vector<T>& a, const F& f) : func(f) {
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    mat.resize(max_log);
    mat[0] = a;
    for (int j = 1; j < max_log; j++) {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++) {
        mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
      }
    }
  }

  T get(int from, int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 32 - __builtin_clz(to - from + 1) - 1;
    return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> e(m);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    --x; --y;
    e[i] = make_tuple(z, x, y);
  }
  sort(e.begin(), e.end());
  long long ans = 0;
  vector<int> fi(n);
  iota(fi.begin(), fi.end(), 0);
  vector<int> ne(n, -1);
  vector<int> nc(n, -1);
  dsu d(n);
  for (auto& ee : e) {
    int x = get<1>(ee);
    int y = get<2>(ee);
    int z = get<0>(ee);
    x = d.get(x);
    y = d.get(y);
    if (x != y) {
      d.p[x] = y;
      ne[x] = fi[y];
      nc[x] = z;
      fi[y] = fi[x];
      ans += z;
    }
  }
  int start = fi[d.get(0)];
  vector<int> order(n);
  vector<int> val(n - 1);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    if (i < n - 1) {
      val[i] = nc[start];
    }
    order[i] = start;
    pos[start] = i;
    start = ne[start];
  }
  SparseTable<int> st(val, [&](int i, int j) { return max(i, j); });
  int tt;
  cin >> tt;
  while (tt--) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    x = pos[x];
    y = pos[y];
    if (x > y) {
      swap(x, y);
    }
    cout << ans - st.get(x, y - 1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 6400
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    num=A[x-1]+B[y-1]-c
    ans=min(num,ans)
print(ans)

Measured memory_bytes: 24800
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;
const int mod = 998244353;

int main(){
    int k, n; cin >> k >> n;
    int dist = 0;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n){
        dist = max(dist, a[i + 1] - a[i]);
    }
    dist = max(dist, a[0] + (k - a[n-1]));
    cout << k - dist << endl;
}



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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = Integer.parseInt(scan.next());
		int K = Integer.parseInt(scan.next());
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = Integer.parseInt(scan.next());
		}
		Arrays.sort(h);
		int[] h_diff = new int[N - 1];
		for (int i = 0; i < N - 1; i++) {
			h_diff[i] = Math.abs(h[i + 1] - h[i]);
		}

		int diffMin = 0;
		for (int i = 0; i < K - 1; i++) {
			diffMin += h_diff[i];
		}
		int diff = 0;
		for (int i = 1; i < N - K + 1; i++) {
			diff = 0;
			for (int j = i; j < i + K - 1; j++) {
				diff += h_diff[j];
			}
			if (diff < diffMin) {
				diffMin = diff;
			}
		}
		System.out.println(diffMin);
	}
}


Measured memory_bytes: 48076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int h, w;
    cin >> w >> h;
    vector<pair<ll, int>> v;
    rep(i, w) {
        ll p;
        cin >> p;
        v.emplace_back(p, 0);
    }
    rep(i, h) {
        ll q;
        cin >> q;
        v.emplace_back(q, 1);
    }
    sort(all(v));

    ll cnt = (ll)(w + 1) * (h + 1) - 1;
    ll zero = h + 1, one = w + 1;
    ll ans = 0;
    for (auto p : v) {
        ll x = p.first;
        int k = p.second;
        if (k == 0 && zero > 0 && cnt > 0) {
            ans += x * min(zero, cnt);
            one--;
            cnt -= min(zero, cnt);
        }
        if (k == 1 && one > 0 && cnt > 0) {
            ans += x * min(one, cnt);
            zero--;
            cnt -= min(one, cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6256
//https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_L

#include <bits/stdc++.h>

using namespace std;

long long MOD = 1e9 + 7;

long long f[1010][1010];

int main() {
    long long n;//ボール
    long long k;//箱
    cin >> n >> k;

    if (n < k) {
        cout << 0 << endl;
        return 0;
    }

    f[0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            f[i][j] = f[i][j - 1];
            if (i >= j) {
                f[i][j] = (f[i][j] + f[i - j][j] + MOD) % MOD;
            }
        }
    }

    cout << f[n - k][k] << endl;
    return 0;
}

/*
 * DPL_5_Jで定義したf[n][k]がほぼそのまま使える。
 * まずすべての箱に1個ずつボールを入れ，
 * 次に残ったn-k個のボールをk個以下の箱
 * （空箱あり）に入れる。
 * f[n-k][k]
 * ただし，n<kのときは0通り。
 */


Measured memory_bytes: 10992
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n;
    cin >> n;
    int q = sqrt(n) + 1;
    int res = -1;
    for (int i = 1; i < q; i++) {
        if (n % i == 0) {
            string s = to_string(n / i);
            res = s.size();
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int n, m, a, b;
  std::cin >> n >> m >> a >> b;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if ((i < b && j < a) || (i >= b && j >= a)) std::cout << "1";
      else std::cout << "0";
    }
    std::cout << std::endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

	vector< vector<int> > jobs(m+1);
	for (int i = 0; i < n; i++){
		int a, b;
		cin >> a >> b;
		if (a > m) continue;
		jobs[a].push_back(b);
	}
	
	long ans = 0;
	priority_queue<int> q;
	for (int i = 1; i <= m; i++){
		for (auto j : jobs[i])
			q.push(j);
		if (q.empty()) continue;
		ans += q.top();
		q.pop();
	}

	cout << ans << endl;
}



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

int main(){
    int ans=0,sum=0;
    long long k;
    string s;
    cin >>s>>k;
    
    int i=0;
    while (s[i]=='1')i++;

    if(k < i+1){
        cout << "1" << endl;
    }else{
        cout << s[i] << endl;
    }
    
    


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

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

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve1()
{
    int n, m; cin >> n >> m;
    vector<int> p(n), x(m), y(m);
    UnionFind g(n+1);
    rep(i, n) cin >> p[i];
    rep(i, m) {
         cin >> x[i] >> y[i];
         g.unite(x[i], y[i]);
    }

    ll ans = 0;

    rep(i, n) {
        if(g.same(i+1, p[i])) {
            ans ++;
        }
    }

    cout << ans << endl;

}

int main()
{
    solve1();
}


Measured memory_bytes: 4764
import java.util.Scanner;

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

    String S = scanner.next();
    String T = scanner.next();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    String U = scanner.next();
    if (U.equals(S)) A--;
    else B--;
    System.out.printf("%d %d\n", A, B);
  }
}


Measured memory_bytes: 22100
let reverse_string s =
    let length = String.length s in
    let t      = Buffer.create length in
    let last   = length - 1 in
    for i = 0 to last do
        Buffer.add_char t s.[last-i]
    done ;
    Buffer.contents t

let () =
    let s          = read_line () in
    let reversed_s = reverse_string s in
    Printf.printf "%s\n" reversed_s

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

int main()
{
    int p, q, r, sum = 0;
    cin >> p >> q >> r;

    sum = max(max(p, q), r);
    if(p == sum)
        cout << q + r << endl;
    else if(r == sum)
        cout << p + q << endl;
    else cout << r + p << endl;

    return 0;
}

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

int main(){ 
  int n;
  cin>>n;
  
  vector<ll> v(n);
  for(int i = 0;i < n ;i++)
    cin>>v[i];
  sort(v.begin(),v.end());
  ll com = 0;
  if(n >= 2) {
    com+=v[n-1];
  }
  
  for(int i = 3; i <= n; i++) {
    com+=v[n - ((i + 1)/2)];
  }
     
  cout<<com<<"\n";
      
  return 0;
}

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

vector<ll> c;

bool getFlag357Number(string x) {
	bool exist3 = false;
	bool exist5 = false;
	bool exist7 = false;
	for (ll i = 0; i < x.size(); i++) {
		if (x[i] == '3') exist3 = true;
		else if (x[i] == '5') exist5 = true;
		else if (x[i] == '7') exist7 = true;		
	}
	bool res;
	if (exist3 && exist5 && exist7) return true;
	else return false;
}

void get357Number(string s_prev) {

	if (s_prev.size() == 10) {
		return;
	}

	for (ll i = 0; i <= 2; i++) {

		if (i == 0) {
			string s_now = s_prev + '3';
			if (getFlag357Number(s_now)) {
				c.emplace_back(stoll(s_now));
			}
			get357Number(s_now);
		}
		else if (i == 1) {
			string s_now = s_prev + '5';
			if (getFlag357Number(s_now)) {
				c.emplace_back(stoll(s_now));
			}
			get357Number(s_now);
		}
		else { // i == 2
			string s_now = s_prev + '7';
			if (getFlag357Number(s_now)) {
				c.emplace_back(stoll(s_now));
			}
			get357Number(s_now);
		}
	}
}


int main() {

	ll n; cin >> n;
	
	string s = "";

	get357Number(s);
	sort(c.begin(), c.end());

	ll ans;
	for (ll i = 0; i < c.size(); i++) {
		if (c[i] <= n) {
		}
		else {
			ans = i;
			break;
		}
	}

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

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

int ans = 0;

struct co {
        int n;
        int x[15];
        int y[15];
    };

int chng(int n)
{
    return (n == 1) ? 0 : 1;
}

int cnt(int T[], int N)
{
    int sum = 0;
    for (int i = 0; i < N; i++){
        sum += (T[i] == 1) ? 1 : 0;
    }
    return sum;
}

int judge(co P[], int N, int T[])
{
    for(int i = 0; i < N; i++)
    {
        if (T[i] == 1){
            for (int j = 0; j < (P[i].n); j++)
            {
                if(T[(P[i].x[j]) - 1] != P[i].y[j]) return 0;
            }
        }
    }
    return 1;
}

void CmbRecursion(co P[], int a[], int n, int depth)
{
    if (depth == n)
    {
        if(judge(P, n, a) == 1 && cnt(a, n) > ans){
            ans = cnt(a,n);
        }
        return;
    }
    CmbRecursion(P, a, n, depth + 1);
    a[depth] = 1;
    CmbRecursion(P, a, n, depth + 1);
    a[depth] = 0;
}


int main()
{
    int N;
    
    scanf("%d", &N);
    co P[N];
    int T[N];
    for (int i = 0 ; i < N; i++)
    {
        scanf("%d", &P[i].n);
        for (int j = 0; j < P[i].n; j++)
        {
            scanf("%d", &P[i].x[j]);
            scanf("%d", &P[i].y[j]);
        }
        T[i] = 0;
    }

    CmbRecursion(P, T, N, 0);

    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
a = list()
for i in range(n):
    a.append(list(map(int, input().split())))
b = list()
for i in range(m):
    b.append(int(input()))
for i in range(n):
    ans = 0
    for j in range(m):
        ans += a[i][j] * b[j]
    print(ans)


Measured memory_bytes: 6008
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}


// ------------------------------------------------------------------------

fn main() {
    let r = parse_line::<u32>();

    println(3 * r * r);
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int x = scanner.nextInt();

        ArrayList<Reference> refs = new ArrayList<>();

        for(int i = 0; i < n; i++){
            Reference ref = new Reference();
            ref.price = scanner.nextInt();
            for(int j = 0; j < m; j++){
                ref.algolisms.add(scanner.nextInt());
            }
            refs.add(ref);
        }

        int[] temp = new int[m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                temp[j] += refs.get(i).algolisms.get(j);
            }
        }

        int[] ucheck = Arrays.stream(temp).filter(num -> num >= x).toArray();
        if (ucheck.length != temp.length) {
            System.out.println(-1);
            return;
        }
        int[] understangings = new int[m];
        int sum = 0;

        int min1 = dfs(refs, refs.get(0), true, understangings, x, sum, 0);
        int min2 = dfs(refs, refs.get(0), false, understangings, x, sum, 0);

        sum = Math.min(min1, min2);
        System.out.println(sum);
    }

    public static int dfs(ArrayList<Reference> refs, Reference ref, boolean choice, int[] understandings, int x, int sum, int node) {
        int[] understandings1 = understandings.clone();
           if (choice) { //その参考書を選択する場合
                sum += ref.price;
                for (int j = 0; j < understandings1.length; j++) { //参考書を選択したため理解度アップ
                    understandings1[j] += ref.algolisms.get(j);
                }
                int[] ucheck = Arrays.stream(understandings1).filter(num -> num >= x).toArray();
                if (ucheck.length == understandings1.length) { //全てのアルゴリズムの理解度がx以上か確かめる
                    return sum;
                }
            }

        node++;
        int[] understandings2 = understandings1.clone();
        if(node < refs.size()) {
                int sum1 = dfs(refs, refs.get(node), true, understandings1, x, sum, node);
                int sum2 = dfs(refs, refs.get(node), false, understandings2, x, sum, node);
                return Math.min(sum1, sum2);
            }

        if(choice) {
            int[] ucheck = Arrays.stream(understandings1).filter(num -> num >= x).toArray();
            if(ucheck.length != understandings1.length){
                return Integer.MAX_VALUE;
            }
        }else{
            int[] ucheck = Arrays.stream(understandings2).filter(num -> num >= x).toArray();
            if(ucheck.length != understandings2.length){
                return Integer.MAX_VALUE;
            }
        }
        return sum;
    }
}

class Reference{
    int price = 0;
    ArrayList<Integer> algolisms = new ArrayList<>();
}


Measured memory_bytes: 46636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    cin>>x>>y;
    if(y%2==1){
        cout<< "No" <<endl;
    }
    else if(x*4<y){
        cout<< "No" <<endl;
    }
    else if(x*2>y){
        cout<< "No" <<endl;
    }
    else{
        cout<< "Yes" <<endl;
    }
}

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

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var n = s.Length;

            var ans = 0L; //左からB1e5個、W1e5個とかだと、Σ[i=1→1e5]i * 1e5 ～1e10になって、intだとオーバーフローする
            var Wcounter = 0;

            for(int i = 0; i < n; i++)
            {
                if(s[i] == 'W')
                {
                    ans += i - Wcounter; 
                    Wcounter++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

#define NIL NULL

Node root;

void insert(Node);
void inorder(Node);
void preorder(Node);
Node find(Node,int);


int main(){
  char command[20];
  int i,n,v,j;
  Node z;
  
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(strcmp(command,"insert") == 0){
      scanf("%d",&v);
      z = malloc(sizeof(struct node));
      z->key = v;
      z->left = NIL;
      z->right = NIL;
      insert(z);
    }else if(strcmp(command,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(strcmp(command,"find") == 0){
      scanf("%d",&v);
      if(find(root,v) != NIL)printf("yes\n");
      else printf("no\n");
    }
    
  
  }

  
  return 0;
}

void insert(Node z){
  Node y = NIL;
  Node x = root;
  while(x!=NIL){
    y = x;
    if(z->key<x->key){
      x = x->left;      
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(Node root){
  if(root != NIL){
    inorder(root->left);
    printf(" %d",root->key);
    inorder(root->right);
  }

}

void preorder(Node root){
  if(root == NIL){
    return;
  }
  printf(" %d",root->key);
  preorder(root->left);
  preorder(root->right);
}

Node find(Node root ,int x){
  if(root == NIL || x == root->key){
    return root;
  }
  if(x < root->key){
    return find(root->left,x);
  }else{
    return find(root->right,x);
  }
  
}



Measured memory_bytes: 20452