akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int n, Deg[60], par1[60], par2[60], Num1[60], Ed1[60], Ed2[60], Num2[60], cnt, chk[60], res;
int ww[60][60], GD[60], Q[60];
vector<int>E[60], F[60], G[60];
struct Edge {
	int a, b;
}w[60];
void DFS1(int a, int pp) {
	Num1[a] = ++cnt;
	par1[a] = pp;
	for (auto &x : E[a]) {
		if (x != pp)DFS1(x, a);
	}
	Ed1[a] = cnt;
}
void DFS2(int a, int pp) {
	Num2[a] = ++cnt;
	par2[a] = pp;
	for (auto &x : F[a]) {
		if (x != pp)DFS2(x, a);
	}
	Ed2[a] = cnt;
}
bool OK(int a, int b) {
	int i;
	int c = 0;
	if (ww[a][b] % 2 == 0)c++;
	for (i = 1; i <= n; i++) {
		E[i].clear();
		G[i].clear();
		GD[i] = 0;
		chk[i] = 0;
	}
	for (i = 1; i < n; i++) {
		if (w[i].a == a||w[i].b == a)continue;
		E[w[i].a].push_back(w[i].b);
		E[w[i].b].push_back(w[i].a);
	}
	E[a].push_back(b);
	E[b].push_back(a);
	cnt = 0;
	DFS1(a,0);
	cnt = 0;
	DFS2(a,0);
	for (i = 1; i <= n; i++) {
		if (par1[i] != par2[i])chk[i] = 1;
	}
	for (i = 1; i <= n; i++) {
		if (!chk[i] && chk[par1[i]])return false;
		if (chk[i])c++;
		if (chk[i]) {
			if(chk[par1[i]])G[i].push_back(par1[i]), GD[par1[i]]++;
			G[par2[i]].push_back(i), GD[i]++;
		}
	}
	int head = 0, tail = 0;
	for (i = 1; i <= n; i++)if (!GD[i])Q[++tail] = i;
	while (head < tail) {
		int x = Q[++head];
		for (auto &y : G[x]) {
			GD[y]--;
			if (!GD[y])Q[++tail] = y;
		}
	}
	if (tail != n)return false;
	if (res == -1 || res > c)res = c;
	return true;
}
void Solve() {
	int i, j;
	res = -1;
	for (i = 1; i <= n; i++) {
		if (Deg[i] == 1) {
			for (j = 1; j <= n; j++) {
				if (i != j) {
					OK(i, j);
				}
			}
		}
	}
	printf("%d\n", res);
}
int main() {
	int TC, i, a, b, j;
	scanf("%d", &TC);
	while (TC--) {
		scanf("%d", &n);
		for (i = 1; i <= n; i++) {
			E[i].clear(), F[i].clear();
			for (j = 1; j <= n; j++)ww[i][j] = 0;
			Deg[i] = 0;
		}
		for (i = 1; i < n; i++) {
			scanf("%d%d", &a, &b);
			ww[a][b] ++, ww[b][a]++;
			w[i] = { a,b };
			Deg[a]++, Deg[b]++;
		}
		for (i = 1; i < n; i++) {
			scanf("%d%d", &a, &b);
			ww[a][b] +=2, ww[b][a] +=2;
			F[a].push_back(b);
			F[b].push_back(a);
		}
		int ck = 0;
		for (i = 1; i <= n; i++)for (j = 1; j <= n; j++)if (ww[i][j]%3)ck = 1;
		if (!ck) {
			puts("0");
			continue;
		}
		Solve();
	}
}

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

const ll MOD_CONST = 1000000007;



int main(){
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < 10000; i++) {
		if ((i * 8) / 100 == a && (i) / 10 == b) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;


}  



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    
    int x,a=0,b=0,c=0,y=0;
      
    scanf("%d",&x);
  
    a=x/500;  b=x%500;
    c=b/5;    
  
    y=(a*1000)+(c*5);
  
    printf("%d",y);
  
    return 0;
}  

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

using namespace std;

typedef pair<int, int> P;
typedef pair<long long int, P> Q;

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) {
			break;
		}
		vector<int> d(n, 0);
		d[0] = 1;
		long long int t;
		int s, D;
		vector<Q> dd;
		for (int i = 0; i < m; i++) {
			cin >> t >> s >> D;
			s--;
			D--;
			dd.push_back(Q(t, P(s, D)));
		}
		sort(dd.begin(), dd.end());
		for (int i = 0; i < m; i++) {
			if (d[(dd[i].second).first] == 1) {
				d[(dd[i].second).second] = 1;
			}
		}
		int MM = 0;
		for (int i = 0; i < n; i++) {
			MM += d[i];
		}
		cout << MM << endl;
	}
	return 0;
}

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

int H, W;
int a, b;
int main() {
	cin >> W >> H;
	int N; cin >> N;
	a = 0; b = 0;
	int ans = 0;
	while (N--) {
		int p; cin >> p;
		if (!p) {
			a++;
		}
		else {
			b++;
		}
		if (a == W - 1 || a == W + H - 2) {

		}
		else if (a < W-1) {
			if (a == b)ans++;
		}
		else if (a < W + H-2) {
			if (a == b + 2)ans++;
		}
		else {
			if (a == b + 4)ans++;
		}

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

Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
long long n, t[100000], a[100000], dp[100000];
int main() {
	cin >> n; for (int i = 1; i <= n; i++) { cin >> t[i] >> a[i]; }
	for (int i = 1; i <= n; i++) {
		long long E1 = dp[i - 1] * t[i - 1];
		long long E2 = dp[i - 1] * a[i - 1];
		long long F1 = (E1 + t[i] - 1) / t[i]; if (t[i] >= 1 && F1 == 0)F1 = 1;
		long long F2 = (E2 + a[i] - 1) / a[i]; if (a[i] >= 1 && F2 == 0)F2 = 1;
		dp[i] = max(F1, F2);
	}
	cout << dp[n] * (t[n] + a[n]) << endl;
	return 0;
}

Measured memory_bytes: 384
import collections


n = int(input())

l = []
for i in range(n):
    xa,ya = map(int,input().split())
    l.append([xa,ya])
if n == 1:
    print(1)
else:
    s = []
    for i in range(n):
        for k in range(i+1,n):
            xdis = l[k][0]-l[i][0]
            ydis = l[k][1]-l[i][1]
            if xdis < 0 and ydis < 0:
                xdis = xdis*(-1)
                ydis = ydis*(-1)
            if xdis < 0 and ydis == 0:
                xdis = xdis*(-1)
            if xdis < 0 and ydis >0:
                xdis = xdis*(-1)
                ydis = ydis*(-1)
            if xdis == 0 and ydis < 0:
                ydis = ydis*(-1)
            dist = (xdis,ydis)
            s.append(dist)

    #print(s)

    c = collections.Counter(s)
    #print(c)
    print(n - c.most_common()[0][1])


Measured memory_bytes: 40688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M=1e9+7;
vector<ll> dp;
int main(){
 ll n;
 cin>>n;
 dp.resize(n+1);
 for(ll i=3;i<=n;i++){
 	dp[i]+=1;
 	for(ll j=3;j<=i-3;j++){
 		dp[i]+=dp[j];
		dp[i]%=M; 	
	}
 }
 cout<<dp[n]<<endl;
 return 0;
}



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

int main() {
	int n;
	while(cin>>n, n!=0){
		int count=0;
		int i = n+1;
		if(n!=1){
			if(i%2==0) i++;
			while(i<=(2*n)){
				int t=0;
				for(int j=3 ; j <= sqrt(i) ; j+=2){
					if(i%j==0){
						t=1;
						break;
					}
				}
				if(t==0) count++;
				i+=2;
			}
		}
		else count++;
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
  }
  else if (0 < a) {
    cout << "Positive" << endl;
  }
  else {
    if ((b - a + 1) % 2 == 0) {
      cout << "Positive" << endl;
    }
    else {
      cout << "Negative" << endl;
    }
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


// 2011/10/23

// 0077 Run Length
public class Main {

	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		String s = reader.readLine();
		if (s == null)
			return false;
		
		String d = "";
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == '@') {
				char r = s.charAt(++i);
				c = s.charAt(++i);
				for(int j = 0; j < r - '0'; j++) {
					d += c;
				}
			}
			else {
				d += c;
			}
		}
		
			
		// ðÌ\¦
		System.out.printf("%s\n", d);
		
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "ab@5C1@8050:";

			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
#include <iostream>
  
   int main() {
   char str[4];
     std::cin >> str;
     for (int i = 0; i < 3; i++) {
       if (str[i] == '7') {
         std::cout << "Yes" << std::endl;
         return 0;
      }
    }
   std::cout << "No" << std::endl;
    return 0;
  }

Measured memory_bytes: 3040
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int x = sc.nextInt();
        System.out.println(x >= 30 ? "Yes": "No");

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35732
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
p,q,r= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
#これを消すとなぜかWAになる呪い
print(min(p+q,q+r,r+p))

Measured memory_bytes: 5332
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<pair<int, int>> a(n), b(n);

    REP(i, n) {
        int ta; cin >> ta;
        a[i] = {ta, i};
    }

    REP(i, n) {
        int tb; cin >> tb;
        b[i] = {tb, i};
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    REP(i, n) {
        if (a[i].first > b[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

    REP(i, n-1) {
        if (a[i + 1].first <= b[i].first) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    vector<int> p(n);
    REP(i, n) {
        p[a[i].second] = b[i].second;
    }

    for (int i = 0, t = 0; t < n - 1; t++) {
        i = p[i];
        if (i == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  int n;
  cin >> n;
  double a[n]={},b=1,c;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    c+=1/a[i];
  }
  cout << fixed << setprecision(10) << 1/c << endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s[m];
    vector<int> P(m);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            x--;
            s[i].push_back(x);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> P[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int count = 0;
        int cnt[m]={0};
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                for (int j = 0; j < m; j++)
                {
                    for (int k = 0; k < s[j].size(); k++)
                    {
                        if (i == s[j][k])
                            cnt[j]++;
                    }
                }
            }
        }
        for (int j = 0; j < m; j++)
        {
            if (cnt[j] % 2 == P[j])
                count++;
        }
        if (count == m)
            ans++;
    }
    cout << ans << endl;
}

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

sum = (n // 2) * 2 + 1

ans = []

for i in range(1, n + 1):
	for j in range(i + 1, n + 1):
		if i + j != sum:
			ans.append([i, j])
print(len(ans))

for i in ans:
	print(i[0], i[1])


Measured memory_bytes: 43376
#include <bits/stdc++.h>
using namespace std;
bool compr(int a,int b){
    return a>b;
}
int main(){
    int N;
    cin>>N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end(),compr);
    int finalSum = 0;
    for(int i=0;i<N;i+=2){
        finalSum += v[i];
    }
    for(int i=1;i<N;i+=2){
        finalSum -= v[i];
    }
    cout<<finalSum<<endl;
}

Measured memory_bytes: 3532
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if((a==1&&b==0&&c==0)||(a==0&&b==1&&c==0)||(a==0&&b==0&&c==0)){
        
        cout<<"Close"<<endl;
    }// Your code here!
    else if((a==1&&b==1&&c==0)||(a==0&&b==0&&c==1)){
        cout<<"Open"<<endl;
    }
    
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[200010];
int cnt[30];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < 30; j++)if (a[i] & (1 << j))cnt[j]++;
	}
	for (int i = 0; i < n; i++) {
		int ans = 0;
		for (int j = 0; j < 30; j++) if (((a[i] & (1 << j)) && cnt[j] % 2 == 0) || ((a[i] & (1 << j)) == 0 && cnt[j] % 2))ans += (1 << j);
		cout << ans << " ";
	}
	cout << endl;
}

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

int main() {
    int32_t a, b;
    cin >> a >> b;

    if (a <= 0 && b >= 0) {
        cout << "Zero" << endl;
    } else {
        if (a > 0) {
            cout << "Positive" << endl;
        } else {
            if ((a - b + 1) % 2 == 0) {
                cout << "Positive" << endl;
            } else {
                cout << "Negative" << endl;
            }
        }
    }

    return 0;
}


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

int x,H,W,D,Q,A,L,R;
int px[90001],py[90001];
int d[90001];
int main(){
    cin>>H>>W>>D;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>A;
            px[A]=i,py[A]=j;
        }   
    }   
    for(int i=D+1;i<=H*W;i++){
        d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
    }
    cin>>Q;                                                
    while(Q--){
        cin>>L>>R;
        cout<<d[R]-d[L]<<"\n";
    
    }
    
}            


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  string s;
  cin >> s;
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

double fact[10];
double dist(pair<int, int> x, pair<int,int> y);

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

    fact[0]=1;
    for(int i=1; i<9; i++) 
        fact[i] = fact[i-1] * i;

    vector< pair<int, int> > p;
    p.push_back(make_pair(0,0));
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin>>x>>y;
        p.push_back(make_pair(x,y));
    }

    double prev = dist(p[1], p[2]) * 2;
    double cur = 0;
    for(int i=3; i<=n; i++)
    {
        double dist1 = 0, dist2 = 0;
        for(int j=1; j<i; j++)
        {
            dist1 += (dist(p[j], p[i]) * fact[i-2]);
        }
        dist1 += prev;
        dist1 *=2;
        for(int j=1; j<i; j++)
        {
            for(int k=1; k<i; k++)
            {
                if(k!=j)
                {
                    double new_dist = dist(p[j],p[i]) + dist(p[i],p[k]) - dist(p[j],p[k]);
                    dist2 += (fact[i-3]*new_dist);
                }
            }
        }
        dist2 += prev;
        dist2 *= (i-3+1);
        prev =  dist1 + dist2;
        cur = 0;
    }
    printf("%.8f", prev/fact[n]);
    return 0;
}

double dist(pair<int, int> x, pair<int,int> y)
{
    double x1 = x.first, x2 = y.first;
    double y1 = x.second, y2 = y.second;
    double tmp = ((x1-x2) * (x1-x2)) + ((y1-y2) * (y1-y2));
    return sqrt(tmp);
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int n,m,limit;
char s[11][1010];
int c[11],b[11];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>m>>limit;
	rep(i,1,n) cin>>s[i]+1;
	rep(i,1,n) rep(j,1,m) s[i][j]-='0';
	int S=(1<<(n-1))-1;
	int ans=inf;
	rep(i,0,S){
		int sta=i^(1<<n);
		int ret=__builtin_popcount(sta)-1;
		rep(j,0,n-1) b[j+1]=sta>>j&1;
		int flag=1,cnt=0;
		rep(j,1,m){
			cnt=0;
			memset(c,0,sizeof(c));
			rep(k,1,n){
				c[k]+=s[k][j];
				cnt+=c[k];
				if(cnt>limit) flag=0;
				if(b[k]) cnt=0;
			}
		}
		if(!flag) continue;
		memset(c,0,sizeof(c));
		rep(j,1,m){
			cnt=0;
			rep(k,1,n){
				c[k]+=s[k][j];
				cnt+=c[k];
				if(cnt>limit){
					ret++;
					--j;
					memset(c,0,sizeof(c));
					break;
				}
				if(b[k]) cnt=0;
			}
		}
		ans=min(ans,ret);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main() {
int n;
cin>>n;
int a[n];

for(int i=0;i<n;i++)
{
  cin>>a[i];
}
int f=0,s=0,fi=0,si=0;
for(int i=0;i<n;i++)
{
  if(f<a[i])
  {
    f=a[i];
    fi=i;
  }
  else if(s<a[i])
  {
    s=a[i];
    si=i;
  }
}
for(int i=0;i<n;i++)
{
  if(i!=fi)
  {
    cout<<f<<endl;
  }
  else
  {
    cout<<s<<endl;
  }
}

}


Measured memory_bytes: 3200
#include <iostream>
 
using namespace std;
 
int main() {
  string s;
  bool seven = false;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '7') {
      seven = true;
      break;
    }
  }
  
  if (seven) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  return 0;
}

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

typedef long long int ll;

ll dp[5001][5001];

int a[5001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,A,B;
	cin>>n>>A>>B;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			dp[i][j]=1e18;
	dp[0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(a[i]>j){
				dp[i][j]=min(dp[i][j],dp[i-1][j]+A);
				dp[i][a[i]]=min(dp[i][a[i]],dp[i-1][j]);
			}
			else
				dp[i][j]=min(dp[i][j],dp[i-1][j]+B);
	cout<<*min_element(dp[n]+1,dp[n]+n+1)<<endl;
}


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

using namespace std;

int main(){
    string s,t;
    int plus=0;
    cin>>s>>t;
    for (int i=0; i<=2; i++) {
        if (s.at(i)==t.at(i)) {
            plus++;
        }
    }
    cout<<plus<<endl;
    return 0;
}

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

int main() {
    int N, one = 0, two = 0, four = 0;
    cin >> N;
    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
    }
    REP(i, N) {
        if(a[i] % 4 == 0){
            four++;
        } else if(a[i] % 2 == 0){
            two++;
        }
    }
    one = N - two - four;
    if(one <= four){
        cout << "Yes" << endl;
    } else if(one -1 == four && two == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
N,M,Q=map(int,input().split())

A=[]
for _ in range(Q):
    a,b,c,d=map(int,input().split())
    A.append((a-1,b-1,c,d))

import itertools

ans=0
for x in itertools.combinations_with_replacement(range(1,M+1),N):
    ans_temp=0
    for a,b,c,d in A:
        if x[b]-x[a]==c:
            ans_temp+=d
    ans=max(ans,ans_temp)

print(ans)

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

int main(){
  int n;
  cin >> n;
  bool ans = false;
  for(int i = 0; i < 30; ++i){
    for(int j = 0; j < 20; ++j){
      int total = 4 * i + 7 * j;
      if( total == n ) ans = true;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();

        int cnt = 0;
        int time = 0;
        while (true) {
            time += A;
            if (time > T+0.5) {
                break;
            }
            cnt += B;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 2010
#define MAXM 50000
#define INF 1ll<<60
#define LL long long
struct Edge{
    LL w,c;
    int v,Next;
}E[MAXM+5];
int Adj[MAXN+5],ecnt;
void AddEdge(int u,int v,LL Cap,LL Cost){
    E[ecnt].v=v,E[ecnt].w=Cap,E[ecnt].c= Cost,E[ecnt].Next=Adj[u],Adj[u]=ecnt++;
    E[ecnt].v=u,E[ecnt].w=0,  E[ecnt].c=-Cost,E[ecnt].Next=Adj[v],Adj[v]=ecnt++;
}

int pre[MAXN+5];
LL Dist[MAXN+5];
bool vis[MAXN+5];
int cnt[MAXN+5];
bool SPFA(int S,int T,int N,LL &Flow,LL &Cost){
    for(int i=0;i<=N;i++)
        Dist[i]=INF,pre[i]=-1,vis[i]=0,cnt[i]=0;
    queue<int> Q;
    Q.push(S);
    Dist[S]=0,vis[S]=1;
    while(!Q.empty()){
        int u=Q.front();Q.pop();vis[u]=0;
        for(int i=Adj[u];i!=-1;i=E[i].Next){
            int v=E[i].v,c=E[i].c;
            if(E[i].w&&Dist[v]>Dist[u]+c){
                Dist[v]=Dist[u]+c;
                pre[v]=i;
                if(!vis[v]){
                    ++cnt[v];
                    vis[v]=1,Q.push(v);
                }
            }
        }
    }
    if(Dist[T]==INF)
        return 0;
    LL Min=INF;
    for(int i=pre[T];i!=-1;i=pre[E[i^1].v])
        Min=min(Min,(LL)E[i].w);
    for(int i=pre[T];i!=-1;i=pre[E[i^1].v])
        E[i].w-=Min,E[i^1].w+=Min,Cost+=Min*E[i].c;
    Flow+=Min;
    return 1;
}
pair<LL,LL> Dinic(int S,int T,int N){
    LL Flow=0,Cost=0;
    while(1)
        if(!SPFA(S,T,N,Flow,Cost))
            break;
    return make_pair(Flow,Cost);
}

#undef MAXN
#undef MAXM

#define MAXM 1000
int N,M,K;
int A[MAXM+5];

int main(){
    N=read();
    ecnt=0;
    memset(Adj,-1,sizeof Adj);
    for(int i=1;i<=N;i++){
        int x=read(),y=read(),c=read();
        AddEdge(1,i+1,c,0);
        AddEdge(i+1,N+2,INF,x+y);
        AddEdge(i+1,N+3,INF,-x+y);
        AddEdge(i+1,N+4,INF,x-y);
        AddEdge(i+1,N+5,INF,-x-y);
    }
    for(int i=1;i<=N;i++){
        int x=read(),y=read(),c=read();
        AddEdge(i+5+N,2*N+6,c,0);
        AddEdge(N+2,i+5+N,INF,-x-y);
        AddEdge(N+3,i+5+N,INF,x-y);
        AddEdge(N+4,i+5+N,INF,-x+y);
        AddEdge(N+5,i+5+N,INF,x+y);
    }
    printf("%lld",-Dinic(1,2*N+6,2*N+6).second);
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

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

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=2e5+2;





int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);

string s,z;cin>>s>>z;
ll ans=1e10;
forl(i,0,s.S){
    ll cnt=0;
    forl(t,0,z.S){
        ll x=i+t;
        if(x>=s.S){
            cnt=1e11;break;
        }
        if(s[x]!=z[t])cnt++;
    }
    ans=min(ans,cnt);
}
p1(ans);
  







return 0;
}





  







Measured memory_bytes: 3656
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    a,b,k=parseMap(split(readline()))
    a,b=max(0,a-k),ifelse(a<=k,max(0,b-(k-a)),b)
    println("$a $b")
end
main()

Measured memory_bytes: 111480
use std::io;
use std::str::FromStr;

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

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let _: i32 = input();
    let a_vec = input_i32_vec();
    let mut sum = 0;
    for a in a_vec {
        sum += a - 1;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

ll p[200001] = {};
map<ll, ll> mp = {};
bool v[200001] = {};

int main() {
	ll N; cin >> N;
	mp[0] = 0;
	repe(i, 1, N) {
		ll tmp; cin >> tmp;
		p[i] = tmp;
		mp[tmp] = i;
	}

	ll asc_cnt_max = 0;

	repe(k, 1, N) {
		if (v[k])continue;

		ll asc_cnt = 1;
		ll cur = k;
		v[cur] = true;

		while (1) {
			if (cur == N) {
				break;
			}

			if (mp[cur + 1] > mp[cur]) {
				v[cur + 1] = true;

				asc_cnt++;
				cur++;
			}
			else {
				break;
			}
		}
		asc_cnt_max = max(asc_cnt_max, asc_cnt);
	}

	cout << N - asc_cnt_max << endl;

	return 0;
}

Measured memory_bytes: 14464
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL H; cin >> H;
  LL num = 1;
  LL cnt = 0;
  while (H > 0) {
    cnt += num;
    H = H/2;
    num *= 2;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    vector<ll> num(3);
    rep(i,3) cin>>num[i];

    sort(num.begin(),num.end(),greater<ll>());
    cout<<num[0]*10+num[1]+num[2]<<endl;
    return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()){
    if(s.at(i) != t.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		// get a integer
		int num = sc.nextInt();
		
		int result = getResult(num);
		System.out.println(result);
	}
	
	public static boolean isMaxNum(int num) {
		return num > 100 ? true : false;
	}
	
	public static boolean isOddNumber(int num) {
		return (num % 2) != 0 ? true : false;
	}
	
	public static int getInteger(int num) {
		if(isOddNumber(num)) {
			return (3 * num) + 1;
		}
		
		return num / 2;
	}
	
	public static int getResult(int num) {
		if(isMaxNum(num)) {
			return 0;
		}
		
		String[] temp = new String[1000000];
		
		//boolean notFound = true;
		int index = 1;
		while(true) {
			if(temp[num] != null) {
				break;	
			}
			temp[num] = "inserted";
			num = getInteger(num);
			
			index++;
		}
		return index;
	}
	
}


Measured memory_bytes: 25940
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,l,ans_i=-1;
  cin >> n >> l;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]>=l){
      ans_i=i;
      break;
    }
  }
  if(ans_i==-1){
    cout <<"Impossible"<<endl;
  }else{
    cout <<"Possible"<<endl;
    for(int i=0;i<ans_i;i++){
      cout << i+1<<endl;
    }
    for(int i=n-2;i>ans_i;i--){
      cout << i+1<<endl;
    }
    cout << ans_i+1<<endl;
  }
}


Measured memory_bytes: 1664
//Sort
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int a, b, c, d, stoptimes, i;
    int x, y;
    
    while(1){
        cin >> a >> b;
        if(a+b==0){break;}
        cin >> stoptimes;
        int maze[a+1][b+1];
        int det[a+1][b+1];
        for(x=0;x<a+1;x++){
            for(y=0;y<b+1;y++){
                det[x][y]=0;
            }
        }
                for(i=0;i<stoptimes;i++){
            cin >> c >> d;
            det[c][d]=1;
        }
        
     
        for(x=0;x<a+1;x++){
            for(y=0;y<b+1;y++){
            maze[x][y]=0;
            }
        }
        maze[1][1]=1;
        for(x=0;x<a;x++){
            for(y=0;y<b;y++){
                if(x+y==0)continue;
                maze[x+1][y+1]=maze[x][y+1]+maze[x+1][y];
                if(det[x+1][y+1]==1){maze[x+1][y+1]=0;}
            }
        }
        
        cout << maze[a][b] << endl;
        
    
    
    }
    return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}


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


	int N = getint();

	ll kotae = (ll(N) * (N + 1) * (2 * N + 1) / 6 + ll(N) * (N + 1) / 2) / 2;

	rep(i, N - 1) {
		int u = getint(), v = getint();
		if (u > v) swap(u, v);

		kotae -= ll(u) * (N - v + 1);
	}

	printf("%lld\n", kotae);



	Would you please return 0;
}

Measured memory_bytes: 1692
n,a,b = map(int,input().split())
ans = pow(2,n,10**9+7)-1

inf = 10**9+7
def comb2(n,k): #素数でわるかつ数字が大きいとき 0(klogN) 10**9まで
    x,y = 1,1
    if n-k < k:
        k = n-k
    for i in range(k):
        x *= n-i
        x = x%inf
        y *= i+1
        y = y%inf
    ans = x* pow(y,inf-2,inf) %inf
    return ans

ans -= comb2(n,a) + comb2(n,b)
ans = ans%inf
print(ans)

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    int ans = 0;
    for(int i=100;i>=0;i--){
        if(cnt == k){
            ans = i+1;
            break;
        }
        if(a%i==0 && b%i==0){
            cnt++;
        }
    }
    cout << ans << endl;
}


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

bool checkTriangle(long long i, long long j, long long k) {
    return ( (i + j > k) && (i + k > j) && (j + k > i) );
}

int main() {
    int n; cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
                if(checkTriangle(a[i], a[j], a[k])) ans ++;
            }
        }
    }

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


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

int main(){
	int N,D;
	cin >> N >> D;
	if(N%(2*D+1) == 0){
		cout << N/(2*D+1) << endl;
	}else{
		cout << N/(2*D+1)+1 << endl;
	}
	return 0;
}

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

int main()
{
    int n,k,low,high,i;
    cin>>n>>k;
    low=k-(n-1);
    high=k+(n-1);
    for(i=low;i<=high;i++)
        cout<<i<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

queue = deque()

left = [[0 for j in range(w)] for i in range(h)]
right = [[0 for j in range(w)] for i in range(h)]
up = [[0 for j in range(w)] for i in range(h)]
down = [[0 for j in range(w)] for i in range(h)]

cnt = 0

for i in range(h):
    cnt = 0
    for j in range(w):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            left[i][j] = cnt

    cnt = 0
    for j in reversed(range(w)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            right[i][j] = cnt


for j in range(w):
    cnt = 0
    for i in range(h):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            up[i][j] = cnt

    cnt = 0
    for i in reversed(range(h)):
        if maze[i][j] == '#': cnt = 0
        else:
            cnt += 1
            down[i][j] = cnt

ans = 0
for i in range(h):
    for j in range(w):
        tmp = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
        ans = max(tmp, ans)

print(ans)


Measured memory_bytes: 183688
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

string a, s, c;

int main() {
    fast_io; cout_precision;
    cin >> a >> s >> c;
    cout << a[0] << s[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,k,l;
vector<int> a;
int main(){
  cin >> n >> k;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << ROUNDUP((n-1),(k-1)) << endl;
}


Measured memory_bytes: 640
import math
import sys
import collections
import bisect


def main():
    a, b, n = map(int, input().split())
    i = max(b - 1 if n >= b else n, 1)
    print(math.floor(a * i / b) - a * math.floor(i / b))


if __name__ == '__main__':
    main()


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

/*int Luca(int x) {
  if (x == 0) {
    return 2;
  }
  else if (x == 1) {
    return 1;
  }
  else return Luca(x - 1) + Luca(x - 2); 
}*/

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> Luca(87);
  Luca.at(0) = 2;
  Luca.at(1) = 1;
  
  for (int i = 2; i < N + 1; i++) {
    Luca.at(i) = Luca.at(i - 1) + Luca.at(i - 2);
  }
  
  cout << Luca.at(N) << endl;
}
  

Measured memory_bytes: 256
// 171

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    for(int i=0; i<=x; i++){
        if(y == (i*2 + (x-i)*4)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }


int main() {
  string S, ans;
  int K;
  cin >>K>>S;
  if(S.length() <= K) ans = S;
  else ans = S.substr(0,K) + "...";
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
	int n, cnt = 0; cin >> n;
	priority_queue<int> l, r;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) {
		l.push(a[i]); r.push(a[n - i - 1]);
		while (!l.empty() && (l.top() == r.top()))
			l.pop(), r.pop();
		if(l.empty()){
			if (cnt++) cout << " ";
			cout << i + 1;
		}
	}
	cout << endl;

	return 0;
}


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

int judge(int now_x, int now_y, int t, int x, int y){
    int i, j;
    i = now_x;
    
    if(now_x < x){
    do{
        i++;
        t--;
        if(t < 0){
       
            return 2;
        
        }
    }while(i != x);
    }else if(now_x > x){
    do{
        i--;
        t--;
        if(t < 0){
      
            return 2;
       
        }
    }while(i != x);
    }
    
    j = now_y;
    
    if(now_y < y){
    do{
        j++;
        t--;
        if(t < 0){
      
            return 2;
        
        }     
    }while(j != y);
    }else if(now_y > y){
    do{
        j--;
        t--;
        if(t < 0){
       
            return 2;
        
        }     
    }while(j != y);
    }
   
    if(t == 0){
        return 1;
    }else if(t % 2 == 0){
        return 1;
    }else{
      
        return 2;
        
    }
}


int main(void){
    int N = 100000;
    int t[N], x[N], y[N];
    int i, j, n, k, x_num, y_num, time;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d%d%d", &t[i], &x[i], &y[i]);
    }
    x_num = 0;
    y_num = 0;
    time = t[0];
    for(i = 0; i < n; i++){
        if(i > 0){
        time = t[i] - t[i-1];
        }
       
        j = judge(x_num, y_num, time, x[i], y[i]);
      
        if(j == 1){
            x_num = x[i];
            y_num = y[i];
        }else{
            printf("No");
            exit(0);
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#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 sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};





signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0) cout<<(b-a)/2<<endl;
    else{
        ll s=min(a-1,n-b);
        cout<<(b-a+s*2+1)/2<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(str(input()))
T1 = []
T2 = []

if N%2 == 0:
  for i in range(int(N/2)):
    T1.append(S.pop(0))
    T2.insert(0,S.pop(-1))
  if T1==T2:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>


int main(){
  int k;
  int count_even=0;
  int count_odd=0;
  scanf("%d",&k);

  for(int i=1;i<=k;i++){
    if(i%2==0) count_even++;
    else count_odd++;
  }

  printf("%d\n",count_odd*count_even);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{   
	ll n;cin>>n;
	ll h[n],dp[n];
	for(int i=0;i<n;++i)
	{
		cin>>h[i];
	}
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<"\n";

	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

template <typename T, class F = function<T(const T&, const T&)>>
class SegmentTree {
public:
  SegmentTree(size_t n, T i, F f) : identity(i), operation(f) {
    for (size = 1; size < n; size <<= 1) {}
    data.assign(size * 2, identity);
  }

  void update(size_t i, T value) {
    for (data[i += size] = value; i > 1; i >>= 1)
      data[i >> 1] = operation(data[i], data[i ^ 1]);
  }
  // [a,b)
  T query(size_t l, size_t r) {
    T res = identity;
    for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = operation(res, data[l++]);
      if (r & 1) res = operation(res, data[--r]);
    }
    return res;
  }

private:
  size_t size;    // num of leaves
  vector<T> data; // root index is 1
  T identity;
  F operation;
};

int main() {
  int n, q;
  cin >> n >> q;
  SegmentTree<int> st(n, 2147483647, [](int a, int b) { return min(a, b); });

  rep(i, 0, q) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 0)
      st.update(x, y);
    else
      cout << st.query(x, y + 1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3816