akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 500005
int N,A[MXN];
map<pii,ll> DP;
//for x|x specially
ll psum[MXN];
map<int,ll> lsta;
map<int,int> lstp;
//===
ll Ans;
int xb;

ll modexp(ll x, ll y)
{
    ll Pow = x%MOD, rtn = 1;
    while(y)
    {
        if(y&1)rtn=(rtn*Pow)%MOD;
        y>>=1;
        Pow=(Pow*Pow)%MOD;
    }
    return rtn;
}

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

    cin>>N;
    FOR(i,1,N)
    {
        cin>>A[i];
        xb^=A[i];
    }
    int xf=0;
    Ans=1;
    FOR(i,1,N-1)
    {
        xf^=A[i];
        xb^=A[i];
        //0|0 case
        psum[i]=psum[i-1]+( xf==0 && xb==0 );

        ll za[4];
        za[1]=DP[mkp(xb?xb:xf,1)];
        za[2]=DP[mkp(xb?xb:xf,2)];
        za[3]=DP[mkp(xb,3)];

        //(even x)|x case
        if( xf==0 && xb!=0 )
        {
            Ans=(Ans+za[2])%MOD;
            DP[mkp(xb,1)]=(za[1]+za[2])%MOD;
        }
        //(odd x)|0 case
        if( xf!=0 && xb==0 )
        {
            DP[mkp(xf,2)]=(za[1]+za[2]+1)%MOD;
        }
        //(odd x)|x case
        if( xf==xb && xf )
        {
            if( lstp.find(xf)!=lstp.end() )
            {
                int lp = lstp[xf];
                ll la = lsta[xf];
                ll na = (la+za[3]*(psum[i-1]-psum[lp]))%MOD;
                Ans=(Ans+na)%MOD;

                lsta[xf]=na;
                DP[mkp(xf,3)]=(za[3]+na)%MOD;
            }
            else
            {
                DP[mkp(xf,3)]=lsta[xf]=1;
                Ans=(Ans+1)%MOD;
            }
            lstp[xf]=i;
        }
    }
    if(psum[N-1])
    {
        ll Zans=modexp(2,psum[N-1]);
        Ans=(Ans+Zans-1)%MOD;
    }
    cout<<Ans<<'\n';

    return 0;
}

/*
3
1 2 3

5
0 0 0 0 0
*/


Measured memory_bytes: 91392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;


ll dp[3001][3001];

ll sign[3001][3001],n,m;


string str,ptr;

void LCS()
{
        ll i,j;

        n=str.size(),m=ptr.size();


         for(i=1; i<=n; i++)
         {
             for(j=1; j<=m; j++)
             {
                if(str[i-1]==ptr[j-1])
                {
                    dp[i][j]=dp[i-1][j-1]+1;
                    sign[i][j]='c';
                }
                else if(dp[i-1][j]>=dp[i][j-1])
                {
                    dp[i][j]=dp[i-1][j];
                    sign[i][j]='u';
                }
                else
                {
                    dp[i][j]=dp[i][j-1];
                    sign[i][j]='l';
                }
             }
         }
}


string Find_string()
{
    ll i=n,j=m;

    string ans;



      while(i>0 and j>0)
      {
          if(sign[i][j]=='c')
          {
              ans+=str[i-1];
              i--;
              j--;
          }
          else if(sign[i][j]=='u')
            i--;

          else j--;
      }

     reverse(vll(ans));

     return ans;


}
int main()
{

   fastread();

   ll i,j,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;




   bool flag=true;


      cin>>str>>ptr;

      LCS();

      cout<<Find_string()<<endl;




}


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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    if(k == 0){
        ll ans = 0;
        rep(i,n){
            ans = max(ans, a[i]);
        }
        cout << ans << endl;
        return 0;
    }

    ll lb = 0, rb = 1e9 + 7;
    while(rb - lb > 1){
        ll mid = (rb + lb) / 2;
        ll cnt = 0;
        rep(i, n) {
            if (a[i] % mid == 0) cnt--;
            ll res = a[i] / mid;
            cnt += res;
        }
        if (cnt > k) {
            lb = mid;
        } else {
            rb = mid;
        }
    }
    cout << rb << endl;
}


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

int main(){
    long long A=0,  ans=0;
    string S;
    cin >> S;

    for(long long i=0;;i++){
	if(S[i+1]=='\0')
	    break;

	if(S[i]=='A')
	    A++;
	else if(S[i]=='B' && S[i+1]=='C'){
	    ans += A;
	    i++;
	}else{
	    A=0;
	}
    }

    cout << ans << endl;
}



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

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<long long> vec = {a*c, a*d, b*c, b*d};
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  cout << vec.at(0) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int c = a+b;
    if(a%3==0 || b%3==0 || c%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void GCD(int x, int y, int c)
{
	if(y == 0)
	{
		cout << x << " " << c << endl;
		return;
	}
	GCD(y, x % y, c + 1);
}

void solve()
{
	int x, y;
	while(cin >> x >> y, x || y)
	{
		if(x >= y)
		{
			GCD(x, y, 0);
		}
		else
		{
			GCD(y, x, 0);
		}
	}
}

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

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

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

        int sum = 0;
        final List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            final int s = scanner.nextInt();
            sum += s;
            list.add(s);
        }

        list.sort(Comparator.comparingInt(Integer::intValue));
        if (sum % 10 != 0) {
            System.out.println(sum);
        } else {
            for (final int value : list) {
                if (value % 10 != 0) {
                    System.out.println(sum - value);
                    return;
                }
            }
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N,K;
  cin >> N >> K;
  cout << ll(min(N%K,abs(N%K-K))) << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

 
int main() {
    fastio
    ll k;
    cin>>k;

    ll ans = -1;
    ll cur = 7;
    for(int i = 1; i<=1000000; ++i) {
    	if(cur % k == 0) {
    		ans = i;
    		break;
    	}
    	cur = cur*10 + 7;
    	cur %= k;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
class UnionFindSet:
    def __init__(self):
        self.dic = dict()

    def find(self,x):
        #xがedgeを持っているかどうかの判定
        if x not in self.dic:
            return x
        else:
            self.dic[x] = self.find(self.dic[x])
            return self.dic[x]

    def union(self,x,y):
        fx = self.find(x)
        fy = self.find(y)
        if fx != fy:
            self.dic[fx] = fy

n, m = map(int,input().split())
p = [None] + list(map(int,input().split()))
s = UnionFindSet()
#最小全域木の作成
for _ in range(m):
    x,y = map(int,input().split())
    s.union(x,y)

ans = 0
for i in range(1,n+1):
    if(s.find(i) == s.find(p[i])):
        ans += 1
print(ans)


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

int main() {
  int N;
  cin >> N;
  
  int ta=0, hana=0;
  string a, b;
  for(int i=0; i<N; i++) {
    cin >> a >> b;
    if (a < b) hana += 3;
    if (a == b) ta+= 1, hana += 1;
    if (a > b) ta += 3;
  }
  cout << ta << " " << hana << endl;
  
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define M 1000000007
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define MAX 1000005
#define fs first
#define sc second 
#define N 3
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
typedef vector <ll> vi;



int main()
{
// freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
 cin.tie(0);
 string str;
cin>>str;
if(str[0]== str[2])
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;

}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ");
        var A = long.Parse(input[0]);
        var B = (long)Math.Round(double.Parse(input[1]) * 100);

        Console.WriteLine(A * B / 100);
    }
}


Measured memory_bytes: 27396
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();

        // 主処理
        String result = String.valueOf(s1.charAt(0)).toUpperCase() + String.valueOf(s2.charAt(0)).toUpperCase()
                + String.valueOf(s3.charAt(0)).toUpperCase();

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

char A[51][51];
char B[51][51];

void solve()
{
    int N;
    cin >> N;
    int M;
    cin >> M;

    REP0(i, N)
    {
        REP0(j, N)
        {
            cin >> A[i][j];
        }
    }

    REP0(i, M)
    {
        REP0(j, M)
        {
            cin >> B[i][j];
        }
    }

    int diff = N - M + 1;

    REP0(i, diff)
    {
        REP0(j, diff)
        {
            bool ok = true;
            REP0(k, M)
            {
                REP0(l, M)
                {
                    ok = ok and A[i + k][j + l] == B[k][l];
                }
            }
            if (ok)
            {
                cout << "Yes" << endl;
                return;
            }
        }
    }

    cout << "No" << endl;
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    int k;cin>>k;
    long int sum=0; 
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;
        
        if(x<=k/2)
        {
            sum+=2*(x);
        }
        else
        {
            sum+=2*(k-x);   
        }
        
    }
    cout<<sum;
}


Measured memory_bytes: 256
import sys
A = []
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a)

N = int(input())
B = []
for n in range(N):
    b = int(input())
    B.append(b)

for y in range(3):
    for z in range(3):
        for x in B:
            if x == A[y][z]:
                A[y][z] = -1

for i in range(3):
    if A[i] == [-1, -1, -1]:
        print("Yes")
        sys.exit(0)
for i in range(3):
    if A[0][i] + A[1][i] + A[2][i] == -3:
        print("Yes")
        sys.exit(0)
if A[0][0] + A[1][1] + A[2][2] == -3:
    print("Yes")
    sys.exit(0)
if A[2][0] + A[1][1] + A[0][2] == -3:
    print("Yes")
    sys.exit(0)
    
print("No")

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll a,b;
    cin>>a>>b;
    if((a-b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================


int main(){
  string s; cin >> s;
  int n = s.size(), nxtW = 0;
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(s.at(i) == 'W'){
      ans += (i - nxtW);
      nxtW++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    string str; cin >> str;

    auto first = str.begin();
    auto last = str.end();
    int cnt = 0;
    while (first != prev(last)) {
        if (*first != *(next(first))) {
            cnt++;
        }
        first++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define wl(n) while(n--)
#define fr(i,a,b) for(i=a;i<b;i++)
#define rev(i,a,b) for(i=b-1;i>=a;i--)

#define mem(a,i) memset(a,i,sizeof(a))
typedef pair<int,int> ii;
#define mp make_pair
#define ll long long
#define MOD 1000000007
#define pb push_back
#define psh push
#define nl printf("\n")
#define fi first
#define sec second

#define si(n) scanf("%d",&n);

#define ss(s) scanf("%s",s)
#define sc(c) scanf("%c",&c)
#define sf(f) scanf("%lf",&f)

#define pi(n) printf("%d\n", n)

#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pf(f) printf("%lf\n", f)
#define INF (1LL<<52)
map<int,string>CharMap;
void num2str()
{
	
	CharMap[0]="0";
	CharMap[1]="1";
	CharMap[2]="2";
	CharMap[3]="3";
	CharMap[4]="4";
	CharMap[5]="5";
	CharMap[6]="6";
	CharMap[7]="7";
	CharMap[8]="8";
	CharMap[9]="9";
}
string to_string(ll n)
{
	string s="";
	while(n>0)
	{
	   int x=n%10;
	   n/=10;
	   s=CharMap[x]+s;	
	}
	return s;
}
ll pow1(ll x,ll y)
{
    if(y==0)
    return 1;
    ll temp= pow1(x,y/2)%MOD;
    if(y%2==0)
    return (temp*temp)%MOD;
    else
    return (((temp*temp)%MOD)*x)%MOD;
}

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	num2str();
	ll x, cnt,rem;
	cin>>x;
	
	rem = x%11;
	cnt = (x/11)*2;
	if(rem > 0)
	{
		if(rem <= 6)
			cnt++;
		else
			cnt+=2;
	}
	cout<<cnt;nl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		if (S.length() == T.length() - 1 && S.equals(T.substring(0, T.length() - 1))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


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

using namespace std;

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

  int odd = 1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    odd *= (a & 1 ? 1 : 2);
  }

  cout << (int)pow(3, n) - odd << endl;

  return 0;
}

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

int main()
{
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> l(q);
  vector<int> r(q);
  int i;
  for(i = 0; i < q; i++)
  {
    cin >> l.at(i) >> r.at(i);
  }
  vector<int> frontsum(n);
  frontsum.at(0) = 0;
  for(i = 1; i < n; i++)
  {
    if(s.at(i-1) == 'A' && s.at(i) == 'C')
    {
      frontsum.at(i) = frontsum.at(i-1)+1;
    }
    else
    {
      frontsum.at(i) = frontsum.at(i-1);
    }
  }
  vector<int> backsum(n);
  backsum.at(n-1) = 0;
  for(i = n-2; i >= 0; i--)
  {
    if(s.at(i) == 'A' && s.at(i+1) == 'C')
    {
       backsum.at(i) = backsum.at(i+1)+1;
    }
    else
    {
       backsum.at(i) = backsum.at(i+1);
    }
  }
  int sum = frontsum.at(n-1);
  for(i = 0; i < q; i++)
  {
    cout << sum - frontsum.at(l.at(i)-1) - backsum.at(r.at(i)-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 60) - 1;

#include <bits/stdc++.h>
using namespace std;

string to_string(string s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    vector<ll> b(N);
    ll ans = infll;

    for (int i = 0; i < N; i++)
    {
        ll sum = 0;
        for (int j = 0; j < N; j++)
        {
            if (i == 0)
            {
                b[j] = a[j];
            }
            else
            {
                int ind = (N + j - i) % N;
                b[j] = min(b[j], a[ind]);
            }
            sum += b[j];
        }
        //debug_out(b);
        ans = min(sum + x * i, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vso(x) sort( x.begin() , x.end() )
#define vre(x) reverse( x.begin() , x.end() ) ;
#define aso(x) sort( x , x + x.size() )
#define are(x) reverse( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    //ull h = 798568968205 ; srand(h) ;
    //int t ; cin >> t ; while(t--){}
    
    string s ; cin >> s ;
    if ( s[5] == s[4] && s[3] == s[2] ) cout << "Yes\n" ;
    else cout << "No\n" ;
 }

Measured memory_bytes: 256
package main

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

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	S := io.nextString()
	switch S {
	case "Sunny":
		io.PutString("Cloudy")
	case "Cloudy":
		io.PutString("Rainy")
	case "Rainy":
		io.PutString("Sunny")
	}
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 640
n, w = map(int, input().split())

value = [0]*1001
wight = [0]*1001
for i in range(n):
    V, W = map(int, input().split())
    value[i] = V
    wight[i] = W

dp = [[0]*(w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j >= wight[i]:
            dp[i+1][j] = max(dp[i][j-wight[i]] + value[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])



Measured memory_bytes: 41892
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int n;
  cin >> n;
  bool found = false;

  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i * j == n) {
        found = true;
        break;
      }
    }
    if (found) {
      break;
    }
  }

  cout << (found ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	string s;
	cin >> k;
	cin >> s;
	int a = s.length();
	if(a<=k)
		cout << s << endl;
	else
		{
			for(int i=0;i<k;i++)
				cout << s[i];
			cout << "...";	
			}	
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int i;
    bool a, b, c;
    string S, ans;

    a = false;
    b = false;
    c = false;
    
    cin >> S;

    for (i = 0; i < 3; i++)
    {
        if (S[i] == 'a')
            a = true;
        if (S[i] == 'b')
            b = true;
        if (S[i] == 'c')
            c = true;
    }

    if (a && b && c)
        ans = "Yes";
    else
        ans = "No";

    cout << ans << endl;

    return 0;
}

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

int main(){
int a,b;
cin >> a >> b;
 
if(a>b){
cout << "a > b" << endl;
}
else if(a==b){
cout << "a == b" << endl;
}

else{
cout << "a < b" << endl;
}
return 0;
}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long[] b = new long[n];

            b[0] = 0;
            for (int i = 0; i < n; i = i + 2)
            {
                //奇数番目はプラス（添字は偶数）
                b[0] += a[i];

            }
            for (int i = 1; i < n; i = i + 2)
            {
                //偶数番目はマイナス（添字は奇数）
                b[0] -= a[i];

            }
            for (int i = 1; i < n; i++)
            {
                b[i] = 2 * a[i-1] - b[i-1];
            }



            Console.WriteLine(string.Join(" ", b));
        }
    }
}

Measured memory_bytes: 33884
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n;
    cin >> n;
    // [先頭の桁][末尾のけた]
    int c[9][9];
    rep(i,9)rep(j,9) c[i][j] = 0;
    ll first, last, num;
    rep(i,n) {
        // 数字
        num = i + 1;
        // 末尾の桁
        last = num % 10;
        // 末尾の桁が0なら飛ばす
        if (!last) continue;
        // 先頭の桁
        while (num >= 10) num /= 10;
        first = num;
        c[first-1][last-1]++;
    }
    ll ans = 0;
    rep(i,9)rep(j,9) ans += c[i][j] * c[j][i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	vector<vector<int>>field(N, vector<int>(N,0));//field[l][r]:=[l.r]に電車
	vector<vector<int>>anss(N, vector<int>(N, 0));
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		field[l][r]++;
	}
	for (int i = 0; i < N; i++) {
		int p = 0;
		for (int j = 0; j < N; j++) {
			p = p + field[i][j];
			field[i][j] = p;
		}
	}
	for (int j = 0; j < N; j++) {
		int p = 0;
		for (int i = 0; i < N; i++) {
			p = p + field[i][j];
			field[i][j] = p;
		}
	}
	for (int i = 0; i < K; i++)
	{
		int p,q;//調べる領域を指定する座標
		cin >> p >> q;
		p--; q--;
		int res = 0;
		if (p == 0) {
			res = field[q][q];
		}
		else {
			res = field[q][q] - field[p - 1][q] - field[q][p - 1] + field[p - 1][p - 1];
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/

void go(){
    int a,b,c;
    R(a,b,c);
    W(c/a*b);
}


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

int main()
{
	long long x, sum=0;
	cin >> x;
	for(long long i=0; i<999999999; i++){
		sum += i;
		if(sum >= x){
			cout << i;
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n,a[200111],pos[200111];
int dp[200111];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)
	{
		geti(a[i]);
		pos[a[i]]=i;
	}
	int ans=n;
	for(int i=1;i<=n;i++)
	{
		dp[a[i]]=(pos[a[i]-1]<pos[a[i]]?dp[a[i]-1]:0)+1;
		ans=min(ans,n-dp[a[i]]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
#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))
//-------------------------------------------------------


class SCC {
public:
	static const int MV = 1<<17;
	vector<vector<int> > SC; int NV,GR[MV],rev[MV];
private:
	vector<int> E[MV], RE[MV], NUM; int vis[MV];
public:
	void init(int NV) { this->NV=NV; for(int i=0;i<MV;i++) { E[i].clear(); RE[i].clear();}}
	void add_edge(int x,int y) { E[x].push_back(y); RE[y].push_back(x); }
	void dfs(int cu) { vis[cu]=1; for(int i=0;i<E[cu].size();i++) if(!vis[E[cu][i]]) dfs(E[cu][i]); NUM.push_back(cu); }
	void revdfs(int cu, int ind) { int i; vis[cu]=1; GR[cu]=ind;  rev[cu]=ind;
		FOR(i,RE[cu].size()) if(!vis[RE[cu][i]]) revdfs(RE[cu][i],ind);}
	void scc() {
		int c=0; SC.clear(); SC.resize(MV); NUM.clear();
		ZERO(vis); for(int i=0;i<NV;i++) if(!vis[i]) dfs(i);
		ZERO(vis); for(int i=NUM.size()-1;i>=0;i--) if(!vis[NUM[i]]){
			revdfs(NUM[i],c);  c++;
		}
	}
};

int N;
int X[101010],Y[101010];
int id[101010][2];
int mi;
vector<pair<int,int>> E;

SCC sc;
void add(int c,int x,int y,int l=0,int r=1<<16,int k=1) { // x<=i<y
	if(x>=y) return;
	if(r<=x || y<=l) return;
	if(x<=l && r<=y) {
		sc.add_edge(c,k);
	}
	else {
		add(c,x,y,l,(l+r)/2,k*2);
		add(c,x,y,(l+r)/2,r,k*2+1);
	}
}

int ok(int v) {
	int i,j;
	int A=1<<16, B=1<<15;
	sc.init(1<<17);
	v--;
	for(i=2;i<1<<16;i++) {
		sc.add_edge(i,i*2);
		sc.add_edge(i,i*2+1);
	}
	
	FOR(i,N) {
		sc.add_edge(A+id[i][0]+B,A+id[i][1]);
		sc.add_edge(A+id[i][1]+B,A+id[i][0]);
		
		int x=lower_bound(ALL(E),make_pair(X[i]-v,0))-E.begin();
		int y=lower_bound(ALL(E),make_pair(X[i]+v+1,0))-E.begin();
		add(A+id[i][0],x+B,id[i][0]+B);
		add(A+id[i][0],id[i][0]+1+B,y+B);
		x=lower_bound(ALL(E),make_pair(Y[i]-v,0))-E.begin();
		y=lower_bound(ALL(E),make_pair(Y[i]+v+1,0))-E.begin();
		add(A+id[i][1],x+B,id[i][1]+B);
		add(A+id[i][1],id[i][1]+1+B,y+B);
	}
	sc.scc();
	FOR(i,B) if(sc.GR[A+i]==sc.GR[A+i+B]) return 0;
	return 1;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		if(X[i]>Y[i]) swap(X[i],Y[i]);
		E.push_back({X[i],i});
		E.push_back({Y[i],i+(1<<14)});
	}
	sort(ALL(E));
	FOR(i,N) {
		id[i][0]=lower_bound(ALL(E),make_pair(X[i],i))-E.begin();
		id[i][1]=lower_bound(ALL(E),make_pair(Y[i],i+(1<<14)))-E.begin();
	}
	
	
	int ret=0;
	for(i=29;i>=0;i--) if(ok(ret+(1<<i))) ret+=1<<i;
	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);
	solve(); return 0;
}


Measured memory_bytes: 31096
def scoring(last, c, s, t, d, score):
    score += s[d][t[d]-1]
    for i in range(len(c)):
        score -= c[i] * (d+1 - last[d][i])
    return score

score = 0
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(i) for i in input().split()])
t = []
for i in range(D):
    t.append(int(input()))

last = [[0 for i in range(len(c))] for j in range(D+1)] # last[d][i]

for d in range(D):
    last[d][t[d]-1] = d+1

    for i in range(len(c)):
        last[d+1][i] = last[d][i]

    score = scoring(last, c, s, t, d, score)
    print(score)





Measured memory_bytes: 9328
#include<cstdio>

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d", &n);
	int c[5] = {};
	for(int i = 0; i < n; i++){
		char s[20]; scanf("%s", s);
		if(s[0] == 'M') c[0]++;
		if(s[0] == 'A') c[1]++;
		if(s[0] == 'R') c[2]++;
		if(s[0] == 'C') c[3]++;
		if(s[0] == 'H') c[4]++;
	}
	ll res = 0;
	for(int i = 0; i < 3; i++) for(int j = i + 1; j < 4; j++)
		for(int k = j + 1; k < 5; k++) res += (ll)c[i] * c[j] * c[k];
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 128
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
ll mod=1000000007;

ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
bool issafe(int x,int y,int n,int m){
    //if(a=='#')return 0;
    if(x<0||x>=n)return 0;
    if(y<0||y>=m)return 0;
    return 1;
}
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    string s[n];
    forn(i,n)cin>>s[i];
    //cout<<"MC"<<endl;
    int vis1[n][m];
    memset(vis1,0,sizeof(vis1));
    int in1=-1,in2=-1;
    int ans=0;
    forn(i,n){
        forn(j,m){
            if(s[i][j]=='.'&&vis1[i][j]==0){
                int vis[n][m];
                memset(vis,0,sizeof(vis));
                vis[i][j]=1;
                queue<PI> que;
                que.push({i,j});
                int ma=0;
                while(!que.empty()){
                    int r,c;
                    r=que.front().first;
                    c=que.front().second;
                    que.pop();
                    for(int k=0;k<4;k++){
                        if(issafe(r+dx[k],c+dy[k],n,m)&&vis[r+dx[k]][c+dy[k]]==0&&s[r+dx[k]][c+dy[k]]=='.'){
                            vis[r+dx[k]][c+dy[k]]=vis[r][c]+1;
                            que.push({r+dx[k],c+dy[k]});
                            if(vis[r+dx[k]][c+dy[k]]>ma){
                                ma=vis[r+dx[k]][c+dy[k]];
                                in1=r+dx[k];
                                in2=c+dy[k];
                            }
                        }
                    }
                }
                ans=max(ans,ma);
            }
        }
    }
    //forn(i,n){forn(j,m)cout<<vis[i][j]<<" ";cout<<endl;}
    //cout<<in1<<" "<<in2<<endl;
    /*int ans=0;
    memset(vis,0,sizeof(vis));
                vis[in1][in2]=1;
                queue<PI> que;
                que.push({in1,in2});
                //int ma=0;
                while(!que.empty()){
                    int r,c;
                    r=que.front().first;
                    c=que.front().second;
                    que.pop();
                    for(int k=0;k<4;k++){
                        if(issafe(r+dx[k],c+dy[k],n,m)&&vis[r+dx[k]][c+dy[k]]==0&&s[r+dx[k]][c+dy[k]]=='.'){
                            vis[r+dx[k]][c+dy[k]]=vis[r][c]+1;
                            que.push({r+dx[k],c+dy[k]});
                            if(vis[r+dx[k]][c+dy[k]]>ans){
                                ans=vis[r+dx[k]][c+dy[k]];
                                //in1=r+dx[k];
                                //in2=r+dy[k];
                            }
                        }
                    }
                }*/
                if(ans>0)cout<<ans-1;
                else cout<<0;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main()
{
	int n, a, b, c, d;
	int  ans;

	while(cin >> n)
	{
		ans = 0;
	for(a = 0; a < 10; a++)
	{
			for(b = 0; b < 10; b++)
			{
					for(c = 0; c < 10; c++)
					{
							for(d = 0; d < 10; d++)
							{
								if(a + b + c + d == n)
									ans ++;
							}
					}
			}
	}
		cout << ans << endl;
	
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int s[300005];
queue<int> q1;
priority_queue<P,vector<P>,greater<P> > q2;

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	bool s1=true;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		a--;
		s[a]=i+1;
		q2.push(make_pair(a,i+1));
	}
	while(!q2.empty()){
		a=q2.top().second,q2.pop();
		for(i=1;i<a;i++)q1.push(a);
	}
	for(i=0;i<n*n;i++){
		if(s[i]!=0){
			if(!q1.empty() && s[i]==q1.front()){s1=false;break;}
			for(j=s[i];j<n;j++)q1.push(s[i]);
			continue;
		}
		if(q1.empty()){
			s1=false;
			break;
		}
		s[i]=q1.front(),q1.pop();
	}
	print_Yes_No(s1);
	if(s1)array_show(s,n*n);
}


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

vector<int> graph[100001];
int dp[100001];

int dfs(int src) {
    if(dp[src] != -1) {
        return dp[src];
    }

    bool leafNode = true;
    int childAns = 0;
    for(int child : graph[src]) {
        leafNode = false;
        childAns = max(childAns, dfs(child));
    }

    return dp[src] = leafNode? 0 : 1+childAns;
}

int longestPath(int v) {
    int ans = 0;

    memset(dp,-1,sizeof dp);

    for (int i = 1; i <= v; ++i)
    {
        ans = max(ans, dfs(i));
    }
    return ans;
}


int main() {
    int v,e;
    cin>>v>>e;

    while(e--) {
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }

    cout << longestPath(v) << "\n";

    return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>

int main(){
  int a,b,x=0;
  char op;

  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?'){
      break;
    }
    else if (op == '+'){
      x = a + b;
    }
    else if (op == '-'){
      x = a - b;
    }
    else if (op == '*'){
      x = a * b;
    }
    else if (op == '/'){
      x = a / b;
    }

    printf("%d\n",x);
  }

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int,int> pr;
typedef pair<pr , pr > ppr;
typedef pair<int,vector<int> > pv;
int num[5]={},numTimes[5]={},numbers,alls;
vector<pv > p; 
void search(int times,int gets[5]){
	if(times==numbers){
	
		int sum=0;
		for(int i=0;i<numbers;i++)
			sum+=num[i]*gets[i];
		if(sum==10){
			pv a;
			a.first=-1;
			for(int i=0;i<numbers;i++){
				a.second.push_back(gets[i]);
				if(a.first==-1 && gets[i]!=0)
				a.first=100-num[i];
			}
				
		p.push_back(a);
		}
	}
	else{
		for(int i=0;i<=numTimes[times] && i<=10 ;i++){
		gets[times]=i;
		search(times+1,gets);
		}
	}
}
int findAns(int x,int times[]){
	if (x==p.size())
		return 0;
	int maxim=0,ans=1;
	int ar[5];
	for(int i=0;i<5;i++)
	ar[i]=p[x].second[i];
	for(int i=0;i<numbers;i++){
		if(ar[i]>times[i])
			ans=0;
		times[i]-=ar[i];
	}
	if(ans)
	maxim=max(maxim,1+findAns(x,times));
	for(int i=0;i<numbers;i++)
		times[i]+=ar[i];
	maxim=max(maxim,findAns(x+1,times));
	return maxim;
}
int solved(vector<pr> v){
		int ans=0;
		for(int i=0;i<v.size();i++){
			num[i]=v[i].first;
			numTimes[i]=v[i].second;
		}
		sort(v.begin(),v.end());
		numbers=v.size();
		int gets[5]={};
		alls=0;
		for(int i=0;i<numbers;i++)
		alls+=num[i]*numTimes[i];
		sort(p.begin(),p.end());
		search(0,gets);
		return findAns(0,numTimes);
}
int main() {
	// your code goes here
	int n,tmp;
	while(cin >> n && n!=0){
		p.clear();
		for(int i=0;i<5;i++){
			num[i]=0;
			numTimes[i]=0;
		}
		
		numbers=0;
		vector<pr > v;
		int nums[10]={},sum=0;
		for(int i=0;i<n;i++){
			cin >> tmp;
			nums[tmp]++;
		}
		for(int i=1;i<=4;i++)
			if(nums[i] && nums[10-i]){
				int manju=min(nums[i],nums[10-i]);
				sum+=manju;
				nums[i]-=manju;
				nums[10-i]-=manju;
			}
		sum+=nums[5]/2;
		nums[5]%=2;
		while(nums[3]>=2 && nums[4] >= 1){
			nums[3]-=2;
			nums[4]-=1;
			sum++;
		}
		for(int i=1;i<=8;i++)
			if(nums[i])
				v.push_back(pr(i,nums[i]));
		cout << sum+solved(v) << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  double t, a;
  cin >> t >> a;

  vector<double> v(n);
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    v[i] = abs(a - (t - h * 0.006));
  }
  int ans = min_element(v.begin(), v.end()) - v.begin() + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))
heapify(A)

for i in range(M):
    heappush(A, (-1*heappop(A))//2*-1)

print(-sum(A))

Measured memory_bytes: 72216
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int h,w;
  cin>>h>>w;
  if(h%3==0||w%3==0){
    cout<<0<<endl;
    exit(0);
  }
  int h1=h/3;
  int ans=INF;
  if(w%2==1&&(h-h1)%2==1){
    int max1,min1;
    if(w<h-h1){
      max1=max(w*(h-h1+1)/2,w*h1);
      min1=min(w*(h-h1-1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
    else{
      max1=max((w+1)*(h-h1)/2,w*h1);
      min1=min((w-1)*(h-h1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
  }
  else ans=min(abs(w*(h-h1)/2-h1*w),ans);
  h1++;
  if(w%2==1&&(h-h1)%2==1){
    int max1,min1;
    if(w<h-h1){
      max1=max(w*(h-h1+1)/2,w*h1);
      min1=min(w*(h-h1-1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
    else{
      max1=max((w+1)*(h-h1)/2,w*h1);
      min1=min((w-1)*(h-h1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
  }
  else ans=min(abs(w*(h-h1)/2-h1*w),ans);
  swap(h,w);
  h1=h/3;
  if(w%2==1&&(h-h1)%2==1){
    int max1,min1;
    if(w<h-h1){
      max1=max(w*(h-h1+1)/2,w*h1);
      min1=min(w*(h-h1-1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
    else{
      max1=max((w+1)*(h-h1)/2,w*h1);
      min1=min((w-1)*(h-h1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
  }
  else ans=min(abs(w*(h-h1)/2-h1*w),ans);
  h1++;
  if(w%2==1&&(h-h1)%2==1){
    int max1,min1;
    if(w<h-h1){
      max1=max(w*(h-h1+1)/2,w*h1);
      min1=min(w*(h-h1-1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
    else{
      max1=max((w+1)*(h-h1)/2,w*h1);
      min1=min((w-1)*(h-h1)/2,w*h1);
      ans=min(max1-min1,ans);
  }
  }
  else ans=min(abs(w*(h-h1)/2-h1*w),ans);
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
import java.io.*;
 
class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");
        String str=array[N-1];
        for(int i=N-2;i>-1;i--) str+=" "+array[i];
        System.out.println(str);
    }
}

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


int main()
{
    int N,K; cin >> N >> K;
    bool snuke[N];
    for (int i = 0; i < N; i++)
    {
        snuke[i] = true;
    }
    
    for (int i = 0; i < K; i++)
    {
        int d; cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a; cin >> a;
            snuke[a-1] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if(snuke[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
h, w, k = [int(s) for s in input().split() ]
squares = []
# . : 白
# # : 黒
for i in range(h):
    squares = squares + [s for s in input()]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        buf = [s for s in squares]
        for d in range(h):
            if (i>>d) & 1:
                for n in range(w):
                    buf[d * w + n] = 'x'

        for d in range(w):
            if (j>>d) & 1:
                for n in range(h):
                    buf[d + w * n] = 'x'

        if buf.count('#') == k:
            ans = ans + 1

print(ans)

Measured memory_bytes: 9248
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

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

int main(){
    int x,y;
    cin >> x >> y;
    cout << x + y - (gcd(x,y) - 1) << endl;
}


Measured memory_bytes: 3132
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc130_c

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a

w, h, x, y = map(int, input().strip().split())
area = w * h / 2
has_points = 0
if 2 * x == w and 2 * y == h:
    has_points = 1
# if abs(2*x-w) == 0 and h > 1:
#     has_points = 1
# elif abs(2*y-h) == 0 and w > 1:
#     has_points = 1
# elif w >= 3*abs(2*x-w) and h >= 3*abs(2*y-h):
#     has_points = 1
# elif gcd(abs(2*x-w), abs(2*y-h)) > 1:
#     has_points = 1

print(area, has_points)


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

int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  ll ans=0,lim=-1,tmp=0;
  ll a[n],b[m];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    if(k>=a[i]){
      ans++;
      k-=a[i];
    }
    else{
      lim=i;
      break;
    }
  }
  if(lim==-1)lim=n;
  int c=0;
  while(k>=b[c] && c<m){
    k-=b[c];
    c++;
    ans++;
  }
  tmp=ans;
  for(int i=1;lim-i>=0;i++){
    k+=a[lim-i];
    tmp--;
    while(k>=b[c] && c<m){
      k-=b[c];
      c++;
      tmp++;
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6752