akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   long long N,K;
   cin >> N >> K;
   long long A[N];
   long long S = 0;
   for (int i = 0; i < N; i++)
   {
      cin >> A[i];
      S+=A[i];
   }
   vector<int> cand;
   for(int i = 1; i*i <= S; i++){
      if(S%i==0){
         cand.emplace_back(i);
         cand.emplace_back(S/i);
      }
   }
   sort(cand.begin(),cand.end());
   reverse(cand.begin(),cand.end());
   for(int c: cand){
      vector<pair<int,int>> ps;
      ll pos =0;
      ll neg =0;
      for(int i=0;i<N;i++){
         int p = A[i]%c;
         ps.push_back(make_pair(p,c-p));
         pos+=c-p;
      }
      sort(ps.begin(),ps.end());
      long long score = max(0LL,pos);
      for(pair<int,int> p: ps){
         neg += p.first;
         pos -= p.second;
         score = min(score, max(neg,pos));
      }
      //cout << c << ": " << score << endl;
      if(score<=K){
         cout << c << endl;;
         return 0;
      }
   }

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


Measured memory_bytes: 3668
# ABC142D - Disjoint Set of Common Divisors
from fractions import gcd


def prime_factors(x: int) -> list:
    if x % 2:
        max_prime, factors = 0, []
    else:
        max_prime, factors = 2, [2]
        while x % 2 == 0:
            x //= 2
    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            max_prime = i
            factors.append(i)
            while x % i == 0:
                x //= i
    if x > 2:  # when x is prime greater than 2
        factors.append(x)
    return factors


def main():
    # compute the number of prime factors of gcd(A, B)
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(prime_factors(g)) + 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 5180
import math
def check1(N):
    if N == 0:
        return 0
    n = int(math.log10(N))
    return 9*n+(N//(10**n))
def check2(N):
    if N == 0:
        return 0
    n = int(math.log10(N))
    return n*(n-1)/2*81+(N//(10**n)-1)*n*9+check1(N%(10**n))
def check3(N):
    if N == 0:
        return 0
    n = int(math.log10(N))
    summ = 0
    if n >= 3:
        for i in range(n):
            summ += i*(i-1)/2
    return summ*729+(N//(10**n)-1)*n*(n-1)/2*81+check2(N%(10**n))
def main():
    N = int(input())
    K = int(input())
    if K == 1:
        print(int(check1(N)))
    elif K == 2:
        print(int(check2(N)))
    elif K == 3:
        print(int(check3(N)))
        
main()

Measured memory_bytes: 3064
n,k,q = list(map(int, input().split()))

A = [0] * n
ans = ['No'] * n

for i in range(q):
    x = int(input())
    A[x - 1] = A[x - 1] + 1

for j in range(n):
    if (k + A[j] - q>0):
        ans[j] = 'Yes'
    print(ans[j])

Measured memory_bytes: 5448
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	map<string,int> mp;
	string s,t; cin>>s>>t;
	int a,b; cin>>a>>b;
	mp[s]=a;
	mp[t]=b;
	string k; cin>>k;
	mp[k]--;
	cout<<mp[s]<<" "<<mp[t]<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>){
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        val l = (1..n).map{sc.nextInt()}

        var ans = 0
        for(i in 0 until n){
                for(j in i+1 until n){
                        ans += l[i]*l[j]
                }
        }
        println(ans)
}

Measured memory_bytes: 31264
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i+=2)
    if(a[i]&1)
      ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main()  {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	S := scanner.Text()

	counter := 0

	for i:=0; i < int(math.Floor(float64(len(S) / 2))); i++ {
		if(S[i:i+1] != S[len(S)-(i+1):len(S)-i]) {
			counter++
		}
	}

	fmt.Println(counter)
}

Measured memory_bytes: 1776
import numpy as np
even = np.zeros(100001, dtype=np.int64)
odd = np.zeros(100001, dtype=np.int64)

n = int(input())
v = list(map(int, input().split()))

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)


Measured memory_bytes: 29460
using System;
using System.Linq;
public class Program {
  public static void Main() {
    var nk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var ans = Math.Ceiling((nk[0]-1)/(double)(nk[1]-1));
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 21984
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
vector<pair<int,int> > v;
char g[1005][1006];
int dist[1005][1006];
bool vis[1005][1006];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int h,w; cin>>h>>w;
	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; j++) {
			cin>>g[i][j];
			if(g[i][j]=='#') {
				v.push_back({i,j});
			}
			dist[i][j]=10000000;
		}

	}
	queue<pair<int,int> > q;

	for(auto l:v) {
		q.push({l.first,l.second});
		dist[l.first][l.second]=0;
	}

	while(!q.empty()) {
		auto z=q.front();
		int i=z.first;
		int j=z.second;
		q.pop();
		if(vis[i][j]) {
			continue;
		}
		vis[i][j]=1;
		for(int k=0; k<4; k++) {
			int nx=i+dx[k];
			int ny=j+dy[k];
			if(nx>=1&&nx<=h&&ny>=1&&ny<=w) {
				if(g[nx][ny]=='#') {
					continue;
				}
				dist[nx][ny]=min(dist[nx][ny],dist[i][j]+1);
				q.push({nx,ny});
			}
		}
	}
	int mx=0;
	for(int i=1; i<=h; i++) {
		for(int j=1; j<=w; j++) {
			mx=max(dist[i][j],mx);
		}
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 22120
#include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#include <queue>

using namespace std;

int cal(int x, char ope, int y){
    if(ope=='+'){
        return x+y;
    }
    if(ope=='*'){
        return x*y;
    }
    if(ope=='-'){
        return x-y;
    }
}

char o1;
char o2;
char o3;

int out_case(char num[]){
    char o[3]={'+','*','-'};
    for(int x=0; x<3; x++){
        for(int y=0; y<3; y++){
            for(int z=0; z<3; z++){
                o1=o[x];
                o2=o[y];
                o3=o[z];
                
                
                int a, b, c, d;
                a=num[0]-'0';
                b=num[1]-'0';
                c=num[2]-'0';
                d=num[3]-'0';
                
                if(cal(cal(cal(a,o1,b),o2,c),o3,d) == 10)return 1; // (((A * B) * C) * D)
                if(cal(cal(a,o1,cal(b,o2,c)),o3,d) == 10)return 2; // ((A * (B * C)) * D)
                if(cal(a,o1,cal(b,o2,cal(c,o3,d))) == 10)return 3; // (A * (B * (C * D)))
                if(cal(a,o1,cal(cal(b,o2,c),o3,d)) == 10)return 4; // (A * ((B * C) * D))
                if(cal(cal(a,o1,b),o2,cal(c,o3,d)) == 10)return 5; // ((A * B) * (C * D))
            }
        }
    }
    return 0;
}

int main() {
    char num[4];
    
    
    while(cin>>num[0]>>num[1]>>num[2]>>num[3]){
        //cout<<num[0]<<endl;
        if(num[0]=='0'&&num[1]=='0'&&num[2]=='0'&&num[3]=='0'){
            break;
        }else{
            sort(num,num+4);
            int ans=0;
            do{
                ans = out_case(num);
                if(ans != 0)break;
            }while(next_permutation(num, num+4));
            if(ans == 0)cout << 0 << endl;
            else if(ans == 1)printf("(((%c %c %c) %c %c) %c %c)\n",num[0],o1,num[1],o2,num[2],o3,num[3]);
            else if(ans == 2)printf("((%c %c (%c %c %c)) %c %c)\n",num[0],o1,num[1],o2,num[2],o3,num[3]);
            else if(ans == 3)printf("(%c %c (%c %c (%c %c %c)))\n",num[0],o1,num[1],o2,num[2],o3,num[3]);
            else if(ans == 4)printf("(%c %c ((%c %c %c) %c %c))\n",num[0],o1,num[1],o2,num[2],o3,num[3]);
            else if(ans == 5)printf("((%c %c %c) %c (%c %c %c))\n",num[0],o1,num[1],o2,num[2],o3,num[3]);

        }
        
    }
    
    
    return 0;
}

Measured memory_bytes: 1192
R, C, K = map(int, input().split())
V = [[0] * (R + 1) for _ in range(C + 1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[c][r] = v

X = [[0] * 4 for _ in range(R + 1)]
for i in range(1, C + 1):
    Vi = V[i]
    for j in range(1, R + 1):
        v = Vi[j]
        Xj = X[j]
        if v:
            Xj[3] = max(Xj[3], Xj[2] + v)
            Xj[2] = max(Xj[2], Xj[1] + v)
            Xj[0] = max(Xj[0], max(X[j-1]))
            Xj[1] = max(Xj[1], Xj[0] + v)
        else:
            Xj[0] = max(Xj[0], max(X[j-1]))

print(max(X[R]))

Measured memory_bytes: 141164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		long start = now();

		String ans = solve(n, a);
		cout.println(ans);

		trace("elapsed", now() - start);
	}

	private static String solve(int n, int[] a) {
		int m4 = 0;
		int m2 = 0;
		for (int x : a)
			if (x % 4 == 0)
				m4 += 1;
			else if (x % 2 == 0)
				m2 += 1;
		if (m4 + m2 / 2 >= n / 2)
			return "Yes";
		return "No";
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 34324
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include <iomanip>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<double> p;
    double dp[3010][3010];
    dp[0][0]=1.0;
    cin>>n;
    p.resize(n);
    rep(i,n) cin>>p[i];
    rep(i,n){
        rep(j,i+1){
            dp[i+1][j+1]+=dp[i][j]*p[i];
            dp[i+1][j]+=dp[i][j]*(1.0-p[i]);
        }
    }
    double ans=0.0;
    for(int i=(n+1)/2;i<=n;i++){
        ans += dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


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

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

	vector <string>s(n);
	int a, b, c, d;
	a = 0;
	b = 0;
	c = 0;
	d = 0;

	for (int i = 0; i < n; i++) {
		cin >> s.at(i);

		string o = "WA";

		if (s[i] == "AC") {
			a++;
		}

		else if (s[i] == "WA") {
			b++;
		}

		else if (s[i] == "TLE") {
			c++;
		}

		else if (s[i] == "RE") {
			d++;
		}
	}

	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
}

Measured memory_bytes: 6428
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  int a, b;
  cin >> a >> b;
  int c;
  if (a == 1 && b == 2) c = 3;
  if (a == 1 && b == 3) c = 2;
  if (a == 2 && b == 1) c = 3;
  if (a == 2 && b == 3) c = 1;
  if (a == 3 && b == 1) c = 2;
  if (a == 3 && b == 2) c = 1;
  cout << c << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

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

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll k;
  cin >> k;
  ll ans = 0;
  rep(i, k) rep(j, k) rep(m, k) {
    ll a = gcd(i+1, j+1);
    ll b = gcd(a, m+1);
    ans += b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long power(long long x, long long y) 
{ 
    long long res = 1;    
    x=x%mod;
    while(y>0) 
    { 
        if(y & 1) 
        res=(res*x)%mod; 
        y=y/2; 
        x=(x*x)%mod;   
    } 
    return res; 
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n;
      long long a[n];
      for(i=0;i<n;i++)
      {
          cin>>a[i];
          sum=(sum+a[i])%mod;
          count=(count+(a[i]*a[i])%mod)%mod;
      }
      sum=(sum*sum)%mod;
      ans=(sum-count+mod)%mod;
      ans=(ans*(power(2,mod-2)))%mod;
      cout<<ans;
	return 0;
}

Measured memory_bytes: 5168
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using lint=int64_t;

int main()
{
	int N;
	lint A[310][310]={};
	lint ans=0;

	cin >> N;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			cin >> A[i][j];
			ans+=A[i][j];
		}
	}
	ans/=2;

	lint dist[310][310]={};
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			dist[i][j]=A[i][j];
	
	for(int k=0;k<N;k++)
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			bool need=true;
			for(int k=0;k<N;k++)
			{
				if(k==i || k==j)continue;

				if(dist[i][j]<A[i][j])
				{
					cout << -1 << endl;
					return 0;
				}
				if(dist[i][k]+dist[k][j]==dist[i][j])
				{
					need=false;
					break;
				}
			}

			if(!need)ans-=A[i][j];
		}
	}
	
	cout << ans << endl;
	return 0;
}


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

int main()
{
  int m[3];
  int n;

  while (cin >> m[0] >> m[1] >> m[2], m[0] || m[1] || m[2]){
    sort(m, m + 3);
    int S = m[0] * m[0] + m[1] * m[1];
    int n, num;
    cin >> n;
    while (n--){
      cin >> num;
      int size = num * num * 4;
      cout << (S < size ? "OK" : "NA") << endl;
    }
  }
  return (0);
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = 1003;
int mat[N][N];
int n,m;
ll dp[N][N];
ll f(int i,int j)
{
       if(i==0 && j==0){return 1;}
       if(i==-1 || j==-1){
              return 0;
       }
       if(dp[i][j] != -1){return dp[i][j];}
       if(mat[i][j] == 0){return dp[i][j] = 0;}
       return dp[i][j] = (f(i-1,j)+f(i,j-1))%mod;
}

int main()
{
       cin>>n>>m;
       fri(i,0,n){
              fri(j,0,m){
                     char xx;
                     cin>>xx;
                     mat[i][j] = (xx=='.');
              }
       }
       memset(dp,-1,sizeof dp);
       cout<<f(n-1,m-1)<<endl;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[109][109];
bool h[109],l[109];
bool mach;
int main()
{
	scanf("%d%d",&n,&m);
	for(int j=1;j<=n;j++)
		scanf("%s",a[j]);
	for(int j=1;j<=n;j++)
	{
		mach=0;
		for(int i=0;i<m;i++)
			if(a[j][i]=='#')
			{
				mach=1;
				break;
			}
		if(mach==0) h[j]=1;
	}
	for(int i=0;i<m;i++)
	{
		mach=0;
		for(int j=1;j<=n;j++)
			if(h[j]==0 && a[j][i]=='#')
			{
				mach=1;
				break;
			}
		if(mach==0) l[i]=1;
	}
	for(int j=1;j<=n;j++)
	{
		if(h[j]==1) continue;
		for(int i=0;i<m;i++)
			if(l[i]==0) printf("%c",a[j][i]);
		puts("");
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll>X(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> X[i];
	}

	ll ans = 0;

	for (ll i = 1; i < N; i++)
	{
		ans += min((X[i] - X[i - 1]) * A, B);
	}

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

Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;


int main(){
    ll K;cin>>K;
    ll d[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<d[K-1]<<endl;


}

Measured memory_bytes: 256
#include<cstdio>

int main(){
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if(A + B < C + D)
		printf("Right\n");
	else if(A + B > C + D)
		printf("Left\n");
	else
		printf("Balanced\n");
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    Set<String> b = new HashSet<String>();
    for (int i=0;i<a;i++){
      String t = scan.next();
      b.add(t);
    }
    System.out.println(b.size());
  }

}


Measured memory_bytes: 78420
def inpl(): return [int(i) for i in input().split()]

H, W, D = inpl()
S = dict([])
for i in range(H):
    a = inpl()
    for j in range(W):
        S[a[j]] = [i,j]

dist = [[0] for i in range(D+1) ]
for i in range(1,D+1):
    for j in range(1,1+(H*W-i)//D):
        dist[i].append(dist[i][-1] +\
        (abs(S[i+j*D][0]-S[i+(j-1)*D][0])+abs(S[i+j*D][1]-S[i+(j-1)*D][1])))
Q = int(input())
ans = []
for i in range(Q):
    l, r = inpl()
    mod = l % D
    if mod == 0 : mod = D
    l, r = (l-mod)//D, (r-mod)//D
    ans.append(dist[mod][r]-dist[mod][l])
for i in ans:
    print(i)

Measured memory_bytes: 31904
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100000];
  int asum=0,bsum=0;
  rep(i,n){
    cin>>a[i];
    asum+=a[i];
  }
  int b[100000];
  b[0]=0;
  repi(i,1,n){
    b[i]=a[i]-b[i-1];
    bsum+=b[i];
  }
  rep(i,5){
    // cout<<b[i]<<endl;
  }
  int ans;
  ans=asum-(bsum*2);
  ans/=2;
  rep(i,n){
    if(i%2==0) b[i]+=ans;
    else b[i]-=ans;
  }
   cout<<b[n-1]*2<<" ";
  rep(i,n-1){
    cout<<b[i]*2;
    if(i!=n-2) cout<<" ";
  }
  cout<<endl;
  return 0;
}


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

typedef long long int ll;
// priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

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

	ll co = 0;
	ll n;
	cin>>n;

	string s;
	cin>>s;

	char ch = ']';

	for(int i=0;i<n;++i)
	{
		if(s[i] == ch)	continue;
		ch = s[i];
		co++;
	}

	cout<<co<<"\n";

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<' ';
	if(a+b<=n) cout<<0<<endl;
	else cout<<-n+a+b<<endl;
}

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

int main(){
  string S;
  cin >>S;
  
  map<char,int> mp;
  
  int len = S.size();
  string ans = "yes";
  rep(i,0,len){
    char s = S[i]; 
    mp[s]++;
    if(mp[s]==2){
      ans = "no";
      break;
    }
  }
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int N;cin>>N;
  int ans=0;
  for(int i=0;i<N+1;i++)ans+=i;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(raw_input())
a=sorted(map(int, raw_input().split()))

if a.count(0) == n:
    print "Yes"
elif n % 3 != 0:
    print "No"
else:
    if len(set(a[0:n/3])) == 1 and len(set(a[n/3:n/3*2])) == 1 and len(set(a[n/3*2:n])) == 1:
        if a[0] ^ a[n/3] == a[n/3*2]:
            print "Yes"
        else:
            print "No"
    else:
        print "No"


Measured memory_bytes: 11292
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(a-x)>abs(b-x))
	{
		cout<<"B"<<endl;
	}
	else
	{
		cout<<"A"<<endl;
	} 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  ll have = 1000LL;
  vll v;
  ll mini = a[0];
  ll check = true;
  bool down = true;
  bool up = true;
  if(a[0]<a[1]) down = false;
  else up = false;
  rep(i,n-1) {
    if(down && a[i]>a[i+1]) {
      mini = a[i+1];
      continue;
    }
    else if(up && a[i]<a[i+1]) continue;
    else if(down && a[i]<a[i+1]) {
      mini = a[i];
      down = false;
      up = true;
    }
    else if(up && a[i]>a[i+1]) {
      v.push_back(mini);
      v.push_back(a[i]);
      down = true;
      up = false;
      mini = a[i+1];
    }
  }
  if(mini!=a[n-1] && mini<a[n-1]) {
    v.push_back(mini);
    v.push_back(a[n-1]);
  }
  ll m = v.size();
  rep(i,m) {
    ll p = have/v[i];
    have -= p*v[i];
    have += p*v[i+1];
    i++;
  }
  if(have<1000LL) cout << 1000 << endl;
  else cout << have << endl;
  return 0;
}

Measured memory_bytes: 3628
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int in[10];
bool dfs(int n,vector<int> l,vector<int> r){
  if(n==10)return true;
  if(l.size()==0 or in[n]>l[l.size()-1]) 
  {
    l.push_back(in[n]);
    return dfs(n+1,l,r);
  }
  if(r.size()==0 or in[n]>r[r.size()-1] ){
    r.push_back(in[n]);
    return dfs(n+1,l,r);
  }
  return false;
  }
int main(){
  int d;
  cin>>d;
  for(int dd=0;dd<d;dd++){
    for(int i=0;i<10;i++){
      cin>>in[i];
    }
    vector<int> l,r;
    if(dfs(0,l,r )) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
  
  }
  return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n,m;
    char *t=(char *)calloc(62LL,sizeof(char));
    char *c=(char *)calloc(7LL,sizeof(char));
    while(1){
        for(i64 i=0LL;i<62LL;++i) t[i]='\0';
        scanf("%[^\n]",c);
        scanf("%*c");
        n=atoll(c);
        if(n==0LL) break;
        for(i64 i=0LL;i<n;++i){
            scanf("%[^\n]",c);
            scanf("%*c");
            if(c[0LL]>='0'&&c[0LL]<='9') t[(i64)(c[0LL]-'0')]=c[2LL];
            else if(c[0LL]>='A'&&c[0LL]<='Z') t[(i64)(c[0LL]-'A')+10LL]=c[2LL];
            else if(c[0LL]>='a'&&c[0LL]<='z') t[(i64)(c[0LL]-'a')+36LL]=c[2LL];
        }
        scanf("%[^\n]",c);
        scanf("%*c");
        m=atoll(c);
        for(i64 i=0LL;i<m;++i){
            scanf("%[^\n]",c);
            scanf("%*c");
            if(c[0LL]>='0'&&c[0LL]<='9') printf("%c",t[(i64)(c[0LL]-'0')]!='\0'?t[(i64)(c[0LL]-'0')]:c[0LL]);
            else if(c[0LL]>='A'&&c[0LL]<='Z') printf("%c",t[(i64)(c[0LL]-'A')+10LL]!='\0'?t[(i64)(c[0LL]-'A')+10LL]:c[0LL]);
            else if(c[0LL]>='a'&&c[0LL]<='z') printf("%c",t[(i64)(c[0LL]-'a')+36LL]!='\0'?t[(i64)(c[0LL]-'a')+36LL]:c[0LL]);
            else printf("%c",c[0LL]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2032
#include <iostream>
    using namespace std;
     
    int main() {
	int cards[4][13];
	for(int i=0; i<4; i++){
		for(int j=0; j<13 ;j++){
			cards[i][j]=0;
		}
	}
	int n;
	cin >> n ;
	for(int h=0; h<n ;h++){
		int num ;
		char mar ;
		cin>> mar >> num ;
		if(mar == 'S'){
			cards[0][num-1]=1;
		}
		if(mar == 'H'){
			cards[1][num-1]=1;
		}
		if(mar == 'C'){
			cards[2][num-1]=1;
		}
		if(mar == 'D'){
			cards[3][num-1]=1;
		}
	}
	for (int i=0; i<4 ; i++){
		for (int j=0 ; j<13 ; j++){
			if(cards[i][j] == 0){
				if(i == 0){cout<< "S " <<j+1 <<endl;}
				if(i == 1){cout<< "H " <<j+1 <<endl;}
				if(i == 2){cout<< "C " <<j+1 <<endl;}
				if(i == 3){cout<< "D " <<j+1 <<endl;}
			}
		}
	}
    return 0;
    }



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    int cntA = 0, cntB = 0, cntC = 0;
    int index = a[0];
    cntA++;
        while(true) {
        switch(index) {
            case 'a':
                if (cntA == a.size()){
                    cout << 'A' << endl;
                    return 0;
                }
                cntA++;
                index = a[cntA]; break;
            case 'b':
                if (cntB == b.size()) {
                    cout << 'B' << endl;
                    return 0;
                }
                cntB++;
                index = b[cntB]; break;
            default :
                if (cntC == c.size()) {
                    cout << 'C' << endl;
                    return 0;
                }
                cntC++;
                index = c[cntC]; break;
            }
    }
    return 0;
}

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

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		out(ni() * ni() / 2);

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static void debug() {
		out("---");
	}

	static void debug(long a) {
		out("-------");
		out(a);
		out("-------");
	}

	static void debug(String a) {
		out("-------");
		out(a);
		out("-------");
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static long min(long d, long e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35688
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

gap = []
if C ==0:
    print(0)
for i, c in enumerate(C):
    for j, v in enumerate(V):
        if i == j:
            if v-c>=0:
                gap.append(v - c)
sum = 0
for v in gap:
    sum += v
print(sum)

Measured memory_bytes: 3188
gets
guzais = gets.split(" ").map(&:to_i)
guzais.sort!

in_guzai = nil
guzais.each do |guzai|
 	if !in_guzai
 		in_guzai = guzai 
	else
		in_guzai = Rational(in_guzai + guzai,2)
    end
end

num = in_guzai.numerator.to_f / in_guzai.denominator.to_f

puts num

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////
vector<double> p(7), q(7);

double win(double x) {
	double ret = 0;
	repn(i, 6) ret += max(p[i] * x, q[i] * (1 - x));
	return ret;
}

int main() {
	repn(i, 6) {
		cin >> p[i];
		p[i] /= 100;
	}
	repn(i, 6) {
		cin >> q[i];
		q[i] /= 100;
	}
	
	double l = 0;
	double r = 1;

	rep(i, 200) {
		double u = (l * 2 + r) / 3;
		double v = (r * 2 + l) / 3;
		//cout << u << " " << win(u) << endl;
		if (win(u) < win(v)) { r = v; }
		else { l = u; }
	}

	cout << fixed << setprecision(15);
	cout << win(l) << endl;

}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
    
#define sz(x) (int) (x).size()
#define INF 0x3f3f3f3f
#define pb push_back
    
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
    
const int N = 100005;
const int mod = 1000000007;

vector<int> grafo[N];
int memo[N];
bool vis[N];

int solve(int x) {
    if (sz(grafo[x]) == 0) return 0;
    if (memo[x] != -1) return memo[x];
    int ans = 0;
    for (int v: grafo[x]) {
        ans = max(ans, 1 + solve(v));
    }
    return memo[x] = ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, a, b;
    int ans = 0;
    cin >> n >> m;
    while (m--) {
        cin >> a >> b;
        grafo[a].pb(b);
    }
    memset(memo, -1, sizeof(memo));
    for (int i = 1; i <= n; i++) {
        if (vis[i]) continue;
        vis[i] = true;
        ans = max(ans, solve(i));
    }
    cout << ans << "\n";

    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 11576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100
void push(int);
int pop();

int top,S[1000];
int main(){
  int x,y;
  char s[100];
  top=0;
  while(scanf("%s",s)!= EOF){
    if(s[0]== '+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(s[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
      
    }
    else if(s[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(s));
    }

  }
  printf("%d\n",pop());
}
void push(int i){
  S[++top]=i;
}
int pop(){
  top--;
  return S[top+1];
}
  



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

int main(){
  long long N; cin >> N;
  int d=1;
  long long s=26;
  N--;
  while(N>=s){
    N-=s;
    s*=26;
    d++;
  }
  //d文字でN番目
  vector<char> result(d);
  for(int i=0; i<d; i++){
    int m=N%26;
    result[i]=(char)('a'+m);
    N/=26;
  }
  for(int i=0; i<d; i++){
    cout << result[d-i-1];
  }
  cout << endl;
}

Measured memory_bytes: 3624
from collections import deque

G = dict()
N, M = map(int, input().split())
color = [0]*(N+1)
for n in range(1, N+1):
    G[n] = []
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
Q = int(input())




data = [list(map(int, input().split())) for _ in range(Q)]
data.reverse()
color_d = [-1]*(N+1)

for v, d, c in data:
    if color_d[v] >= d:
        pass
    # BFS
    deq = deque([v])
    if color[v] == 0:
        color[v] = c
    color_d[v] = d
    while len(deq) > 0:
        s = deq.popleft()
        for t in G[s]:
            if color_d[t] >= color_d[s] - 1:
                pass
            else:
                color_d[t] = color_d[s] - 1
                if color[t] == 0:
                    color[t] = c
                if color_d[t] > 0:
                    deq.append(t)
                
for n in range(1, N+1):
    print(color[n])
                



Measured memory_bytes: 56672
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
#define INF 0x3f3f3f3f
using namespace std;
int k;
int S[14];
bool found;
void print(){
	bool nz = false;
	for(int i = 0; i < 11; i++){
		if(S[i] == 0 && !nz) continue;
		nz = true;
		printf("%d", S[i]);
	}
	printf("\n");
}
void rec(int pos, int prev){
	if(pos == 11){
		k--;
		if(k == 0) {
			print();
			found = true;
		}
		return;
	}
	if(prev == -1){
		for(int i = 1; i < 10 && !found; i++){
			S[pos] = i;
			rec(pos + 1, i);
		}
	}else{
		for(int i = -1; i <= 1 && !found; i++){
			S[pos] = prev + i;
			if(prev + i >= 0 && prev + i <= 9) rec(pos + 1, prev + i);
		}
	}
}
int main(){
	scanf("%d", &k);
	found = false;
	for(int i = 10; i >= 0 && !found; i--){
		rec(i, -1);
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
mod=10**9+7
if n==1:
    print(3)
    exit()

s1=list(input())
s2=list(input())
x=[]
i=0
while i<n-1:
    if s1[i]==s1[i+1]:
        x.append(2)
        i+=2
    else:
        x.append(1)
        i+=1
if s1[-1]!=s1[-2]:
    x.append(1)

for i in range(len(x)):
    if i==0 and x[0]==1:
        ans=3
    elif i==0 and x[0]==2:
        ans=6
    else:
        if x[i-1]==1 and x[i]==2:
            ans*=2
        elif x[i-1]==2 and x[i]==2:
            ans*=3
        elif x[i-1]==1 and x[i]==1:
            ans*=2
        ans%=mod
print(ans)

Measured memory_bytes: 61680
#include <iostream>
#include <algorithm>
int main(){
        int a[200001],b[200001],result[200001];
        long long int N,count=0,M=0;
        std::cin>>N;
        for(int i=1; i<=N; i++)
                std::cin>>a[i];
        for(int i=N; i>0; i--) {
                count=0;
                for(int j=i; j<=N; j=j+i) {
                        count+=b[j];
                }
                if(a[i]!=count%2) {
                        b[i]=1;
                        result[M]=i;
                        M++;
                }
                else
                        b[i]=0;
        }
        std::cout<<M<<std::endl;
        for(int i=0; i<M; i++) {
                std::cout<<result[i]<<' ';
        }
        std::cout<<std::endl;
        return 0;
}


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

int main(){
  int count=0;
  int temp=0;
  vector<char> c(3);

  for(int a=0;a<3;a++){
    cin >> c.at(a);
  }

  for(int i=0;i<3;i++){
    if(c.at(i)=='S'){
      if(temp<=count){
        temp=count;
      }
      count=0;
    }else if(c.at(i)=='R'){
      count++;
    }
  }
  if(temp<=count){
    temp=count;
  }
  cout << temp << endl;

  return(0);
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,ans=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<n-1;i++){
		if(a[i]==a[i+1])a[i+1]=1000+i,ans++;
	}
	cout<<ans<<endl;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

main(void){
  char s;
  cin >> s;
  string str = "abcdefghijklmnopqrstuvwxyz";
  char ans = str.at(s-'a'+1);
  cout << ans;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,X,Y;
    int x[110], y[110];
    cin >> N >> M >> X >> Y;
    rep(i,0,N){
        cin >> x[i];
    }
    rep(i,0,M){
        cin >> y[i];
    }
    bool ans = false;
    rep(i,X+1,Y+1){
        bool is_war = false;
        rep(j,0,N){
            if(x[j] >= i){
                is_war = true;
            }
        }
        rep(j,0,M){
            if(y[j] < i){
                is_war = true;
            }
        }
        if(!is_war){
            ans = true;
        }
    }
    if(ans){
        print("No War");
    }else{
        print("War");
    }

}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
Pii P[int(1e5 + 5)];

int main(){
cin >> N;
for (int i = 0; i < N; i++){
  cin >> P[i].fi;
  P[i].se = i + 1;
}
sort(P, P + N);
cout << P[0].se;
for (int i = 1; i < N; i++) cout << " " << P[i].se;
cout << endl; 
  return 0;
}


Measured memory_bytes: 4368
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	cin>>n>>m;
	if(n>=m){
		for(ll i=0;i<n;i++)
			cout<<m;
	}
	else
		for(ll i=0;i<m;i++)
			cout<<n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3002][3002];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s;
    cin >> t;
    for (int i = 0; i < (int)s.size(); ++i) {
        for (int j = 0; j < (int)t.size(); ++j) {
            dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
        }
    }
#ifdef DEBUG
    for (int i = 0; i < (int)s.size()+1; ++i) {
        for (int j = 0; j < (int)t.size()+1; ++j) {
            printf("%d%c", dp[i][j], j == (int)t.size() ? '\n' : ' ');
        }
    }
#endif
    string ans;
    int i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) {
            --i;
        } else if (dp[i][j] == dp[i][j-1]) {
            --j;
        } else if (dp[i][j] == dp[i-1][j-1]+1) {
            ans += s[--i], --j;
        }
    }
    reverse(ans.begin(), ans.end());
    puts(ans.c_str());
    return 0;
}


Measured memory_bytes: 35456