akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[305];
ll dp[305][305][305];
ll m[305][305];
ll up[305];

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> v;
    REP(i, N)
    {
        cin >> H[i];
        v.push_back(H[i]);
    }
    if (N == K)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    REP(i, N + 1)
    {
        REP(j, K + 1)
        {
            REP(k, v.size())
            {
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    REP(i, K + 1)
    {
        REP(j, v.size())
        {
            m[i][j] = v[j];
        }
    }

    REP(i, N)
    {
        REP(j, K + 1)
        {
            //   cout << "cost : ";
            REP(k, v.size())
            {
                if (v[k] == H[i])
                {
                    //! 変化なし
                    dp[i + 1][j][k] = std::min(m[j][k], dp[i + 1][j][k]);
                }
                else
                {
                    dp[i + 1][j + 1][k] = std::min(dp[i + 1][j + 1][k], m[j][k]);
                }
                //     cout << dp[i + 1][j][k] << " ";
            }
            // cout << endl;
        }
        REP(j, K + 1)
        {
            vector<ll> u(v.size()), d(v.size());
            REP(k, v.size())
            {
                if (k > 0)
                    u[k] = std::min(-v[k] + dp[i + 1][j][k], u[k - 1]);
                else
                    u[k] = -v[k] + dp[i + 1][j][k];
            }
            for (int k = v.size() - 1; k >= 0; k--)
            {
                if (k < v.size() - 1)
                    d[k] = std::min(dp[i + 1][j][k], d[k + 1]);
                else
                    d[k] = dp[i + 1][j][k];
            }

            //  cout << j << ":";
            REP(k, v.size())
            {
                m[j][k] = std::min(v[k] + u[k], d[k]);
                //  cout << m[j][k] << " ";
            }
            // cout << endl;
        }
    }

    ll min = INF;
    REP(i, K + 1)
    {
        REP(j, v.size())
        {
            min = std::min(min, dp[N][i][j]);
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 221184
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        if ("a".equals(s) || "i".equals(s) || "u".equals(s) || "e".equals(s) || "o".equals(s)) {
            System.out.println("vowel");
        } else {
            System.out.println("consonant");
        }
    }
}


Measured memory_bytes: 23764
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    static int[] a;
    // static int[] qu;

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        FS fs = new FS();
        int n = fs.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = fs.nextInt();
        }
        int q = fs.nextInt();
        //    qu = new int[q];
        for (int i = 0; i < q; i++) {
            sb.append(solve(0, fs.nextInt()) ? "yes\n" : "no\n");
        }
        System.out.print(sb.toString());
    }

    private static boolean solve(int p, int t) {
        if (t == 0) return true;
        if (t < 0 || p >= a.length) return false;
        return solve(p + 1, t - a[p]) || solve(p + 1, t);
    }

    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            return hasNextByte() ? buffer[ptr++] : -1;
        }

        private boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 24708
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll const MAX = BIT(22);
ll dp[MAX] = {};
ll a[30][30];
ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	return (x + y) % MOD;
}

ll bitcnt(ll x) {
	ll ans = 0;
	while (x > 0) {
		ans += (x & 1);
		x >>= 1;
	}
	return ans;
}

int main() {
	cin.tie(0);
	ll n;
	cin >> n;
	REP(i, 0, n - 1) {
		REP(j, 0, n - 1) {
			cin >> a[i][j];
		}
	}
	dp[0] = 1;
	ll m = BIT(n) - 1;
	REP(i, 0, m - 1) {
		ll t = bitcnt(i);
		REP(j, 0, n - 1) {
			if (a[j][t] == 1 && (BIT(j)&i) == 0) {
				dp[i ^ BIT(j)] = mod_p(dp[i^BIT(j)], dp[i]);
			}
		}
	}
	cout << dp[m] << endl;
}

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

int main() {
    int n, tp = 0, hp = 0;
    cin >> n;
    REP(i, n) {
        string t, h;
        cin >> t >> h;
        int r = strcmp(t.c_str(), h.c_str());
        if (r == 0) {tp++; hp++;}
        else if (r > 0) tp += 3;
        else hp += 3;}
    cout << tp << " " << hp << endl;
}

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    int a[3][3];
    int ab[3][3]={};
    REP(i,3)REP(j,3)cin>>a[i][j];
    int n;
    cin>>n;
    int b;
    REP(i,n){
        cin>>b;
        REP(j,3)REP(k,3) if(a[j][k]==b)ab[j][k]=1;
    }

    int bl;
    REP(i,3){
        bl=1;
        REP(j,3) bl&=ab[i][j];
        if(bl){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    REP(j,3){
        bl=1;
        REP(i,3) bl&=ab[i][j];
        if(bl){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    bl=1;
    REP(i,3) bl&=ab[i][i];
    if(bl){
        cout<<"Yes"<<endl;
        return 0;
    }
    bl=1;
    REP(i,3) bl&=ab[i][2-i];
    if(bl){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
H,N,*AB = map(int, open(0).read().split())
dp = [0]+[10**8]*H
for n in range(N):
  A,B = AB[2*n:2*(n+1)]
  for h in range(1,H+1): dp[h] = min(dp[h],dp[max(0,h-A)]+B)
print(dp[-1])

Measured memory_bytes: 42476
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<double> v(N);
    for(int i=0; i<N; i++) {
        cin >> v[i];
    }
    
    sort(v.begin(), v.end());

    double ans = v[0];
    for(int i=0; i<N; i++) {
        ans = (ans + v[i]) * 0.5;
    }

    printf("%.10lf\n", ans);
    return 0;
}


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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, ans = 0;
  string s;
  cin >> s;
  //vector<int> v(n), c(n);
  //if(1) {}
  //
  //for(int i = 0; i < n; i++){}
  cout << ((s.at(2) == s.at(3) && s.at(4) == s.at(5))? "Yes" : "No") << endl;
}

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

int main(){
    int N;
    cin >> N;
    int a = N / 100;
    int b = N - a * 100;
    int c = b / 10;
    int d = b - c * 10;
    if(a == 7 || c == 7 || d == 7){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 3620
/// Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_cxx;


#define FASTIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt", "w+", stdout)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define DBG printf("hey!!!\n")
#define all(x) (x).begin(), (x).end()
#define fap(x) cout << " -- " << #x << ": " << (x) << "\n"
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))



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



const ll MAX= 998244353;
const ll MAX2=1271309838631957LL;
long double PI = acosl(-1);
const ll INF = 1e15;
const int NMAX = 1e5+5;
const int MAXLG = log2(NMAX)+1;
const int oo = 1e9+10;
const int sz = 100005;
const int MOD = 10000019;
const double EPS = 1e-9;

/// code starts from here

void solve(){
    int N, W;
    cin >> N >> W;
    vector<ll> value;
    vector<int> weight;

    for(int i = 0; i < N; i++){
        ll v;
        int w;
        cin >> w >> v;
        value.push_back(v);
        weight.push_back(w);
    }

    vector<ll> dp[NMAX];

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= W; j++){
            dp[i].push_back(0);
        }
    }
    for(int i = 0; i < N; i++){
        dp[i][0] = 0;
    }
    for(int i = 0; i < W; i++){
        dp[0][i] = 0;
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++){
            if(weight[i-1] <= j){
                dp[i][j] = max(dp[i-1][j], value[i-1]+dp[i-1][j-weight[i-1]]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[N][W] << endl;
}

int main(){
    //IN;
    FASTIO;

    solve();




}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[][] A = new int[H][];
		for(int i=0;i<H;i++){
			A[i] = new int[W];
		}
		
		int cnt = 0;
		for(int i=0;i<H;i++){
			int b = 0;
			for(int j=0;j<W;j++){
				if(S[i][j] == '#'){
					cnt++;
					b = cnt;
				}
				A[i][j] = b;
			}
			b = 0;
			for(int j=W-1;j>=0;j--){
				if(A[i][j] != 0) b = A[i][j];
				if(A[i][j] == 0) A[i][j] = b;
			}
		}
		
		for(int i=0;i<H;i++){
			if(A[i][0] == 0){
				if(i > 0){
					for(int j=0;j<W;j++){
						A[i][j] = A[i-1][j];
					}
				}
			}
		}
		for(int i=H-1;i>=0;i--){
			if(A[i][0] == 0){
				if(i < H-1){
					for(int j=0;j<W;j++){
						A[i][j] = A[i+1][j];
					}
				}
			}
		}
		
		for(int i=0;i<H;i++){
			Console.WriteLine(String.Join(" ",A[i]));
		}
		
	}
	int H,W,K;
	String[] S;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; K = d[2];
		S = new String[H];
		for(int i=0;i<H;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

void vecout(vector<int>A){
for(int i=0 ; i<A.size() ;i++){
if(i) cout<< " " ; cout << A[i]; }
cout << endl;}

int main(){
int n,v,j; cin>>n;
  vector<int>vec(n);
  for(int i=0;i<n;i++) cin>>vec[i];
   vecout(vec);
  for(int i=1 ; i<n ;i++){
v=vec[i];
    j=i-1;
    while(j>=0&&vec[j]>v){
    vec[j+1]=vec[j];
      j--;
    }
    vec[j+1]=v;    
 vecout(vec);
}
}


Measured memory_bytes: 3164
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a[N],b[N],ans;
long long sum1,sum2;
vector<int> v;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]>b[i])
			v.push_back(a[i]-b[i]),sum1+=(a[i]-b[i]);
		else if(a[i]<b[i])
			ans++,sum2+=(b[i]-a[i]);
	}
	if(sum2>sum1)
	{
		cout<<-1;
		return 0;
	}
	sort(v.begin(),v.end());
	for(int i=v.size()-1;i>=0;i--)
		if(sum2>0)
		{
			ans++;
			sum2-=v[i];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
def main():
    from collections import defaultdict
    from collections import Counter
    import sys

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    d = Counter(a)
    e = defaultdict(int)

    func = lambda x: x * (x - 1) // 2 if x >= 2 else 0
    v = tuple(d.values())
    base = sum(tuple(map(func, v)))

    for k, v in d.items():
        if v <= 1:
            e[k] = base - 0
        else:
            e[k] = base - (v - 1)

    p = [str(e[x]) + '\n' for x in a]
    q = ''.join(p)
    print(q)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44272
#include <iostream>
#include <vector>
#include <algorithm>

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back

using namespace std;

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

	vector<ll> lucas(n);
	lucas[0] = 2;
	lucas[1] = 1;
	for (int i = 2; i < n; i++) {
		lucas[i] = lucas[i - 1] + lucas[i - 2];
	}
	cout << lucas[n - 1] << endl;
}

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




int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	int mn = 1e9, mx = -1e9;
	for (int& i : a) {
		cin >> i;
		mn = min(mn, i), mx = max(mx, i);
	}
	int mxa = 1e9;	
	for (int j = -100; j <= 100; ++j) {
		ans = 0;
		for (int& i : a) {
			ans += pow((i - j), 2);
		}
		mxa = min(mxa, ans);
	}
	cout << mxa;

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long N;
	scanf("%ld", &N);
	
	long X;
	for (X = N * 10 / 11; X <= N; X++) {
		if (X * 108 / 100 == N) break;
	}
	
	if (X <= N) printf("%ld\n", X);
	else printf(":(\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func sum_digits(n int) int {
	if n < 10 {
		return n
	} else {
		return n%10 + sum_digits(n/10)
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	if n%sum_digits(n) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll x,ll y){return (x%y==0)?y:gcd(y,x%y);}

ll lcm(ll x,ll y){return x*y/gcd(x,y);}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-b/c-b/d+b/lcm(c,d)-((a-1)-(a-1)/c-(a-1)/d+(a-1)/lcm(c,d))<<endl;
}


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

int main() {
	string s;
	cin >> s;
	vector<int>a;
	for (int i = 0; i < s.length(); i++)a.push_back((int)s.at(i) - '0');
	ll sum = 0;
	for (int bit = 0; bit < (1 << a.size()-1); bit++) {
		vector<int> l(0);
		for (int i = 0; i < a.size() - 1; i++) {
			if (bit & (1 << i))l.push_back(1);
			else l.push_back(0);
		}
		ll res = a.at(0);
		for (int i = 0; i < l.size(); i++) {
			if (l.at(i) == 0)res *= 10;
			else {
				sum += res;
				res = 0;
			}
			res += a.at(i + 1);
		}
		sum += res;
	}
	cout << sum << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var V = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var M = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var ans = 0;
        for(var i = 0; i < N; i++ )
        {
            if (V[i] > M[i])
            {
                ans += V[i] - M[i];
            }
        }

        Console.WriteLine(ans);

 


    // var N = int.Parse(Console.ReadLine());
    // var S = Console.ReadLine().ToArray();

}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long


int32_t main(){
        ios_base::sync_with_stdio(false);cin.tie(0);
        int k;cin >> k;
        int res=0;
        for(int i=1;i<=k;i++){
                for(int j=1;j<=k;j++){
                        int temp = __gcd(i,j);
                        if(temp==1){
                                res+=k;
                        }else{
                                for(int l=1;l<=k;l++){
                                        int tt=__gcd(temp,l);
                                        res+=tt;
                                }
                        }
                }
        }
        cout << res <<endl;
        return 0;
}

Measured memory_bytes: 3652
def main():
    N, MOD = 200002, 998244353 
    n, m, k = map(int, input().split())

    fact, finv = [1] * N, [1] * N
    for i in range(1, N):
        fact[i] = fact[i - 1] * i % MOD

    finv[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
    for i in range(N - 2, -1, -1):
        finv[i] = finv[i + 1] * (i + 1) % MOD

    def C(n, r):
        return fact[n] * finv[r] * finv[n - r] % MOD

    ans = pow(m, n, MOD)
    for r in range(1, n - k):
        ans -= C(n - 1, r - 1) * m * pow(m - 1, r - 1, MOD)
        ans %= MOD

    print(ans)

main()

Measured memory_bytes: 84804
// C - One-stroke Path

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

struct Node {
	vector<int> neighbor;
};

int N, M;
int ans = 0;
vector<Node> nodes;
unordered_set<int> visited;

void search(int node_idx) {
	if (visited.size() == N) {
		ans++;
		return;
	}

	for (int next_node_idx : nodes[node_idx].neighbor) {
		// 未訪問なら探索
		if (visited.find(next_node_idx) == visited.end()) {
			visited.insert(next_node_idx); // 訪問済みにする
			search(next_node_idx);
			visited.erase(next_node_idx); // 探索が終わったら未訪問に戻す
		}
	}
}

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

	nodes = vector<Node>(N);

	int a, b;
	for (int i=0; i<M; i++) {
		cin >> a >> b;
		a--;
		b--;
		nodes[a].neighbor.push_back(b);
		nodes[b].neighbor.push_back(a);
	}

	visited.insert(0);
	search(0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }




// ***************************************


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

    int y;
    if(x >=400 && x <= 599) y = 8;
    else if(x >= 600 && x <= 799) y = 7;
    else if(x >= 800 && x <= 999) y = 6;
    else if(x >= 1000 && x <= 1199) y = 5;
    else if(x >= 1200 && x <= 1399) y = 4;
    else if(x >= 1400 && x <= 1599) y = 3;
    else if(x >= 1600 && x <= 1799) y = 2;
    else if(x >= 1800 && x <= 1999) y = 1;

    cout << y << endl;

    return 0;
}


Measured memory_bytes: 3592
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

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

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 103;
int n, m, dp[N][N];
char c[N][N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> c[i][j];
        }
    }
    dp[1][1] = (c[1][1] == '#');
    for (int i = 2; i <= n; i++) {
        dp[i][1] = dp[i - 1][1] + (c[i - 1][1] == '.' && c[i][1] == '#');
    }
    for (int j = 2; j <= m; j++) {
        dp[1][j] = dp[1][j - 1] + (c[1][j - 1] == '.' && c[1][j] == '#');
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 2; j <= m; j++) {
            dp[i][j] = min(dp[i - 1][j] + (c[i][j] == '#' && c[i - 1][j] == '.'), dp[i][j - 1] +
             (c[i][j] == '#' && c[i][j - 1] == '.'));
        }
    }
    cout << dp[n][m];
}


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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int q;
  cin>>q;

  vector<set<int>> d(26,set<int>({1000000}));
  rep(i,n) d[s[i]-'a'].insert(i);

  rep(num,q){
    int type;
    cin>>type;
    if(type==1){
      int i;
      char c;
      cin>>i>>c;
      i--;
      d[s[i]-'a'].erase(i);
      d[c-'a'].insert(i);
      s[i]=c;
    }else{
      int l,r;
      cin>>l>>r;
      l--;
      int res=0;
      rep(i,26){
        int x,y;
        if(d[i].empty()) continue;
        x=*d[i].lower_bound(l);
        y=*d[i].lower_bound(r);
        if(y>x) res++;
      }
      cout<<res<<endl;
    }
  }
}


Measured memory_bytes: 27256
#include <iostream>

#define MOD 2019
using namespace std;

typedef long long ll;
ll N,M;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> N >> M;
    if((N - 1) / 2019 != M / 2019) /// N - 1 is to assure the case when N is a multiple of 2019
        cout << 0;
    else
    {
        ll Min = (1 << 30);
        /// its pointless to iterate over more than 1009*2018 elements, cause the multiplications would repeat
        for(ll i = N; i <= min(N + 2018,M); ++i)
            for(ll j = i + 1; j <= min(N + 2018,M); ++j)
                Min = min(Min,(i*j)%MOD);
        cout << Min;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define FINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
string S;
int cnt[26];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> S;
  REP(i,N) cnt[S[i]-'a']++;
  int ans = 1;
  REP(i,26) (ans *= cnt[i]+1) %= MOD;
  ans--;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<vector>
//#include<unordered_map> 
#include<map>
using namespace std ;
typedef long long ll ;

int main(){
    long double a ;
   cin >> a ;
   cout << 2*a*3.14159265 << endl  ;
   
    return 0 ;
}

Measured memory_bytes: 3788
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,m,n) for(int i=m;i<n;i++)

int main(){
	string S;
	cin >> S;
	int length = S.length();
	int ans = 0;
	REP(i,length){
		if(i%2 == 0){
			if(S[i] == '0'){
				
				++ans;
			}
		}else {
			if(S[i] == '1'){
				++ans;
			}
		}
	}
	if(ans > length/2){
		ans = length -ans;
	}
	cout << ans<<endl;
	return 0;
}

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

int main(){
	int a, b;
  	cin >> a >> b;
  	
  	int ans = 10 * b;
  	bool res = false;
  	rep(i, 10){
      	if(floor(ans * 0.08) == a){
          res = true;
          break;
        }
    	ans++;
    } 
  
  	if(res){
    	cout << ans << endl;
	} else {
     	cout << -1 << endl; 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int n;
struct Point
{
    int x, y, ind;
    Point(int x, int y, int ind)
    {
        this->x = x;
        this->y = y;
        this->ind = ind;
    }
};

struct Edge
{
    int ed, w;
    Edge(int ed, int w)
    {
        this->ed = ed;
        this->w = w;
    }
    bool operator>(const Edge other) const
    {
        return w>other.w;
    }
};

vector <Point> v;
bool compx(Point p1, Point p2)
{
    return p1.x < p2.x;
}
bool compy(Point p1, Point p2)
{
    return p1.y < p2.y;
}

bool visit[101010];
vector <Edge> Tree[101010];
priority_queue <Edge, vector<Edge>, greater<Edge>> pq;
void add(int i)
{
    visit[i] = true;
    for (auto it:Tree[i])
        pq.push(it);
}

int Prim(int start)
{
    int mstlen = 0;
    add(start);
    while(!pq.empty())
    {
        int cur = pq.top().ed;
        int weight = pq.top().w;
        pq.pop();
        if (visit[cur])
            continue;
        else
        {
            mstlen+=weight;
            add(cur);
        }
    }
    return mstlen;
}


int main()
{
    scanf("%d",&n);
    for (int i = 0; i<n; i++)
    {
        int x,y;
        scanf("%d %d",&x,&y);
        v.push_back(Point(x,y,i+1));
    }
    sort(v.begin(),v.end(),compx);
    for (int i = 1; i<n; i++)
    {
        Tree[v[i].ind].push_back(Edge(v[i-1].ind,v[i].x-v[i-1].x));
        Tree[v[i-1].ind].push_back(Edge(v[i].ind,v[i].x-v[i-1].x));
    }
    sort(v.begin(),v.end(),compy);
    for (int i = 1; i<n; i++)
    {
        Tree[v[i].ind].push_back(Edge(v[i-1].ind,v[i].y-v[i-1].y));
        Tree[v[i-1].ind].push_back(Edge(v[i].ind,v[i].y-v[i-1].y));
    }
    cout << Prim(1);

}

Measured memory_bytes: 12532
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define IFOR(i,a) for(int i=(a);;i++)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INPUT \
FILE *fp; \
fp=fopen("input.text","r");



int main() {
    int A,B,X;
    cin >> A >> B;
    if (A==B) {
        X=A+B;
    }
    else if (A>B){
        X=2*A-1;
    }
    else X=2*B-1;
    cout << X << endl;
    return 0;
}



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



int main(){
    int i, j, k;
    int maxWeight, Items;
    scanf("%d %d",&Items, &maxWeight);
    long long int weight[Items+10];
    long long int value[Items+10];
    for(i = 1; i <= Items; i++)
    {
        scanf("%lld %lld",&weight[i],&value[i]);
    }
    long long int DP[Items+10][maxWeight+10];
    memset(DP, 0, sizeof(DP));

    for(i = 1; i <= Items; i++)
    {
        for(j = 0; j <= maxWeight; j++)
        {
            //SKIP
            DP[i][j] = DP[i-1][j];

            //Take
            if(weight[i] <= j)
            {
                DP[i][j] = max( DP[i][j], value[i] + DP[i-1][j - weight[i]] );
            }
        }
    }
    printf("%lld\n",DP[Items][maxWeight]);


    return 0;
}



Measured memory_bytes: 86144
def warshall_floyd(edge):
  e=edge
  for k in range(len(e)):
    for i in range(len(e)):
      for j in range(len(e)):e[i][j]=min(e[i][j],e[i][k]+e[k][j])
  return e
n,m,l=map(int,input().split())
edge=[n*[10**10]for _ in range(n)]
for i in range(n):edge[i][i]=0
for _ in range(m):
  a,b,c=map(int,input().split())
  a-=1;b-=1
  edge[a][b]=edge[b][a]=c
edge=warshall_floyd(edge)
edgee=[n*[10**10]for _ in range(n)]
for i in range(n):
  edgee[i][i]=0
  for j in range(n):
    if edge[i][j]<=l:edgee[i][j]=1
edgee=warshall_floyd(edgee)
q=int(input())
for _ in range(q):
  s,t=map(int,input().split())
  s-=1;t-=1
  ans=edgee[s][t]
  if ans==10**10:print(-1)
  else:print(ans-1)

Measured memory_bytes: 58968
// ABC160B - Golden Coins

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

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

	int answer = 0;
	int temp;

	answer += X / 500 * 1000;
	temp = X % 500;
	answer += temp / 5 * 5;

	cout << answer << endl;

	return 0;
}


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

ans = None
ans_dist = 1000000007
for Xref in range(1, 100 + 1):
    dist = 0
    for i, Xi in enumerate(X):
        dist += (Xi - Xref) ** 2
    #
    if ans_dist > dist:
        ans = Xref
        ans_dist = dist

print(ans_dist)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(a,b) for(ll i=a;i<b;i++)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	float n,x,t; cin >> n >> x >> t;
	ll k = (ceil(n/x))*t;
	cout << k;
	return 0;
}

Measured memory_bytes: 3724
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 2e5+5;
vvi graph(N);
vi col(N,-1);
void dfs(ll u,ll p)
{
	rep(i,0,sz(adj[u]))
	{
		ll ch = adj[u][i];
		if(ch==p) continue;
		col[ch]=col[u]^1;
		dfs(ch,u);
	}
	return ;
}

int solve()
{
	ll n;cin>>n;
	rep(i,0,n-1)
	{
		ll x,y;cin>>x>>y;
		x--,y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	col[0]=0;
	dfs(0,-1);

	// rep(i,0,n) cout<<col[i]<<" ";
	// cout<<"\n";

	ll a=0,b=0;
	rep(i,0,n) if(col[i]==0) a++; else b++;

	ll f=0;
	if(a>b)
	{
		swap(a,b);
		f=1;
	}
	vi ans(n,-1);
	set<ll> nu;
	rep(i,1,n+1) nu.insert(i);
	if(a<=n/3)
	{
		ll cnt=1;
		rep(i,0,n) if(col[i]==f) ans[i]=3*(cnt++),nu.erase(ans[i]);
		rep(i,0,n) if(ans[i]==-1) ans[i] = *nu.begin() , nu.erase(ans[i]);
	}
	else
	{
		// cout<<1<<"\n";
		ll cnt1=0,cnt2=0,cnt=1;
		rep(i,0,n)
		{
			if(col[i]==f)
			{
				if(3*(cnt1)+1<=n) ans[i]=3*(cnt1++)+1;
				else ans[i] = 3*cnt++;

			} 
			else
			{
				if(3*(cnt2)+2<=n) ans[i]=3*(cnt2++)+2;
				else ans[i] = 3*cnt++;	
			} 
			nu.erase(ans[i]);
		} 
	}

	rep(i,0,n) cout<<ans[i]<<" ";





	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main(){
	char c;
	int ans1=0,ans2=0;
	for(int i=0;cin>>c;++i){
		if((i&1)!=c-'0')++ans1;
		else ++ans2;
	}
	cout<<min(ans1,ans2)<<"\n"s;
}

Measured memory_bytes: 256
n, m = map(int, raw_input().split())
l = map(int, raw_input().split())
INF = 1<<31
dp = [INF]*(n+1)
dp[0] = 0
for c in l:
    for i in range(n-c+1):
        if dp[i] != INF:
            dp[i + c] = min(dp[i] + 1, dp[i + c])
print dp[n]

Measured memory_bytes: 9336
i = gets.split.map(&:to_i)
gets.chomp.split('').each do |o|
  a, b, c, d, e, f = i
  i = case o
  when 'S' then [e, a, c, d, f, b]
  when 'E' then [d, b, a, f, e, c]
  when 'W' then [c, b, f, a, e, d]
  when 'N' then [b, f, c, d, a, e]
  end
end
p i[0]

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	int N, K;
	cin >> N >> K;
	int ans = 0;
	while (N>0) {
		N /= K;
		ans++;
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<stdio.h>
using namespace std;
int n;
list<int> l;
list<int>::iterator point(int a) {
	for (list<int>::iterator itr = l.begin(); itr != l.end(); itr++) {
		if (*itr == a)return itr;
	}
	return l.end();
}
int main() {
	int n;
	cin >> n;
	char s[20];
	int num;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'i') {
			cin >> num;
			l.push_front(num);
		}
		else if (s[6] == 'F')l.pop_front();
		else if (s[6] == 'L')l.pop_back();
		else {
			cin >> num;
			if (point(num) != l.end())
				l.erase(point(num));
		}
	}
	list<int>::iterator enditr = l.end();
	enditr--;
	for (list<int>::iterator itr = l.begin(); itr != enditr; itr++) {
		cout << *itr << " ";
	}
	cout << *enditr << endl;
	cin >> s;
	return 0;
}



Measured memory_bytes: 34332
import numpy as np

n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
s = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1) # 自分がnp.sumを利用したがどうしても正解になれなかった。なぜ？
    s += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(s % mod)

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

int main() {
    char wea[30];
    scanf("%s", wea);
    if (!(strcmp(wea, "Cloudy")))
        puts("Rainy\n");
    else if (!(strcmp(wea, "Sunny")))
        puts("Cloudy\n");
    else
        puts("Sunny\n");

    return 0;
}


Measured memory_bytes: 128
using System;

namespace ABC148B
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string b, c;
            string[] ss = Console.ReadLine().Split(' ');
            b = ss[0];
            c = ss[1];
            
            
            for (int i = 0; i <= a - 1;i++)
            {
                Console.Write(b.Substring(i, 1));
                Console.Write(c.Substring(i, 1));
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
#define MOD 1000000007ll
using namespace __gnu_pbds;
using namespace std;

int n,a[200010];

inline int my_pow(int x,int y)
{
	if(y==0) return 1;
	if(y==1) return x;
	int res=my_pow(x,y/2);
	if(y%2==0) return (res*res)%MOD;
	else return (((res*res)%MOD)*x)%MOD; 
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	int sum=0ll;
	for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];
	sum%=MOD;
	sum=(sum*sum)%MOD;
	for(int i=1;i<=n;i++) sum-=(a[i]*a[i])%MOD;
	sum%=MOD;
	if(sum<0ll) sum+=MOD;
	sum=(sum*my_pow(2ll,MOD-2ll))%MOD;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5212
li = input()
for bit in range(1 << 3):
    f = li[0]

    for i in range(3):
        if bit & (1 << i):
            f += "+"
        else:
            f += "-"
        f += li[i+1]

        if i == 2:
            ans = int(f[0])
            for i in range(6):
                if f[i] == "+":
                    ans += int(f[i+1])
                elif f[i] == "-":
                    ans -= int(f[i+1])
            if ans == 7:
                print(f + "=7")
                exit()

Measured memory_bytes: 3064
# https://not-522.appspot.com/contest/5948125671849984

s = gets # ?tc????
t = gets # coder

ans = 'UNRESTORABLE'

def apply(s, t, i)
  res = []
  k = 0
  j = 0
  s.gsub("\n", "").split("").each do |a|
    if k < i || k > (i + t.length - 2)
      res << a
    else
      res << t.gsub("\n", "").split("")[j]
      j += 1
    end
    k += 1
  end
  res.join
end

kouho = []
(s.length - t.length + 1).times do |i|
  res = true
  (t.length - 1).times do |k|
    next if s[k + i] == '?'
    next if s[k + i] == t[k]
    res = false
    break
  end
  kouho << apply(s, t, i) if res
end

ans = []
if kouho == []
  puts 'UNRESTORABLE'
else
  kouho.each do |sample|
    ans << sample.gsub('?', 'a')
  end
end
puts ans.sort.first




Measured memory_bytes: 1916
#include <vector>
#include <algorithm>
#include <map>
#include <iostream>

using namespace std;

int MOD = 1e9 + 7;

long long pow(long long a, long long b) {
    if (b == 0) {
        return 1;
    }
    long long tmp = pow(a, b / 2);
    tmp = tmp * tmp % MOD;
    if (b % 2) {
        tmp = tmp * a % MOD;
    }
    return tmp;
}

int main() {
    int n;
    cin >> n;
    long long nd = 1;
    vector<long long> a(n);
    map<int, int> mx;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        long long cur = a[i];
        for (long long j = 2; j * j <= a[i]; ++j) {
            if (a[i] % j == 0) {
                int cnt = 0;
                while(a[i] % j == 0) {
                    a[i] /= j;
                    ++cnt;
                }
                mx[j] = max(mx[j], cnt);
            }
        }
        if (a[i] > 1) {
            mx[a[i]] = max(mx[a[i]], 1);
        }
        a[i] = cur;
    }
    for (auto x : mx) {
        nd = nd * pow(x.first, x.second) % MOD;
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += nd * pow(a[i], MOD - 2) % MOD;
        ans %= MOD;
    }

    cout << ans << '\n';
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;

int main(){
  int n;
  ll k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<int> s;
  vector<int> ord(n+1,-1);
  int c=1,l=0;
  int v=1;
  while(ord[v]==-1){
    ord[v]=s.size();
    s.push_back(v);
    v=a[v-1];
  }
  c=s.size()-ord[v];
  l=ord[v];
  if(k<l) cout<<s[k]<<endl;
  else{
    k-=l;
    k%=c;
    cout<<s[l+k]<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 5848
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
//long long int n , m;
long long int f[100];
long long int di(long long int deep)
{
	f[0] = 2, f[1] = 1;
	if(deep == 0 || deep == 1) return f[deep];
	else if(f[deep] != 0) return f[deep];
	else
		return f[deep] = di(deep - 1) + di(deep - 2);
}
int main()
{
	long long int n ,m;
	while(~scanf("%lld", &n))
	{
		m = di(n);
		printf("%lld\n", m);
	}
}

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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

pair<int,int> calc(string s) {
    pair<int,int> ans;
    int cur = 0;
    for(char ch : s) {
        if(ch == '(') {
            cur++;
        } else {
            cur--;
        }
        min_self(ans.first, cur);
    }
    ans.second = cur;
    return ans;
}

bool go(vector<string> brac) {

    vector<pair<int,int>> a;
    for(string s : brac) {
        a.push_back(calc(s));
    }

    sort(a.rbegin(), a.rend());
    int cur = 0;
    for(pair<int,int> pp : a) {
        if(cur + pp.first < 0) {
            return false;
        } else {
            cur += pp.second;
        }
    }
    return true;
}

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

    int n;
    cin >> n;
    vector<string> open, close;
    int tot = 0;
    forn(i, n) {
        string s;
        cin >> s;
        pair<int,int> pp = calc(s);
        if(pp.second >= 0) {
            open.push_back(s);
        }
        else if(pp.second < 0) {
            close.push_back(s);
        }
        tot += pp.second;
   }

    if(tot != 0) {
        cout << "No\n";
        exit(0);
    }
   for(string& s : close) {
       reverse(s.begin(), s.end());
       for(char& ch : s) {
           if(ch == '(') {
             ch = ')';
           } else {
             ch = '(';
           }
       }
   }

   bool ok = go(open) && go(close);
   cout << (ok ? "Yes\n" : "No\n");

}













// Those who say they can, and those who say they can't - are both usually right.

// Read statement carefully
// Solve on paper first!
// Overflows (long long)

// Author: blondie

Measured memory_bytes: 73524
n = gets.to_i
s = gets.chomp
m = Array.new(n-1,0)
for j in 0..n-2
    s1 = s[0..j]
    s2 = s[(j+1)..(n-1)]
	for i in "a".."z"
  		if s1.include?(i) && s2.include?(i)
  		    m[j] += 1
        end
    end 
end
puts m.max

Measured memory_bytes: 2044
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		List<List<Integer>> graph = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			graph.add(new ArrayList<>());
		}
		
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			a--;
			b--;
			graph.get(a).add(b);
			graph.get(b).add(a);
		}
		
		int[] guide = new int[n];
		int[] dist = new int[n];
		Arrays.fill(dist, n);
		
		Queue<Integer> que = new ArrayDeque<Integer>();
		for (int i = 0; i < graph.get(0).size(); i++) {
			int nv = graph.get(0).get(i);
			que.add(nv);
			guide[nv] = 1;
			dist[nv] = 1;
		}
		
		while (!que.isEmpty()) {
			int v = que.poll();
			
			List<Integer> list = graph.get(v);
			int size = list.size();
			for (int i = 0; i < size; i++) {
				int nv = list.get(i);
				if (dist[v] + 1 < dist[nv]) {
					dist[nv] = dist[v] + 1;
					que.add(nv);
					guide[nv] = v + 1;
				}
			}
		}
		
		System.out.println("Yes");
		for (int i = 1; i < guide.length; i++) {
			System.out.println(guide[i]);
		}
	}
}


Measured memory_bytes: 66364
n = int(input())

flg = False
cnt = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    
    if cnt == 3:
        flg = True

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184