akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<int>> adj;
int dp[100005];
int k,ans=0;
int parent[1000005];
void dfs(int ver,int pr)
{
    parent[ver]=pr;
    int mx=-1;
    for(auto i:adj[ver])
    {
        dfs(i,ver);
        mx=max(mx,dp[i]);
    }
    dp[ver]=mx+1;
    if(dp[ver]==k-1 &&parent[ver]!=1)
    {
        dp[ver]=-1;        
        ans++;
    }
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n>>k;
    adj.resize(n+1);
    int x;
    cin>>x;
    fill_n(dp,100004,-1);
    if(x!=1)
            ans++;
                
    for(int i=0;i<n-1;i++)
    {
        cin>>x;
        adj[x].push_back(i+2);
    }
    dfs(1,1);
    cout<<ans;

} 


Measured memory_bytes: 13696
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define e 1000000007

typedef  long long ll;

int int_cmp(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 



int max(int a,int b){
	if(a<b)
		a=b;
	return a;	
}

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

int absolu(int n){
	if(n<0)
		n*=-1;
	
	return n;	
}


void solve(){
 char s[4];
 int i,ans=0;
 bool yes=false;
  scanf("%s",s);
  int len=strlen(s);
  
 for(i=0 ; i<len ; i++){
 	if(s[i]=='R' && s[i+1]=='R')
 		ans++;
    if(s[i]=='R')
		yes=true;	
 }
 
  
  if(ans>0)
  printf("%d\n",ans+1);
	else if(ans==0 && yes)
		printf("1\n");
	else
		printf("0\n");	
}





int main(){
 /* int t;
	scanf("%d",&t);
	
	while(t--)*/
		solve();
	
	
	
	return 0;
}	
	


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

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if(a + b == 3){
		    out.println(3);
		}else if(a + b == 4){
		    out.println(2);
		}else{
		    out.println(1);
		}
        out.close();
        
    }
}

Measured memory_bytes: 35604
#include<stdio.h>
  
int main() {
  int height[10], i, j, n, temp;
  
  for (i = 0; i < 10; i += 1) {
    scanf("%d", &height[i]);
  };
  
  for (n = 0; n < i - 1; n += 1) {
    for (j = i - 1; j > n; j -= 1) {
      if (height[j - 1] < height[j]) {
        temp = height[j - 1];
        height[j - 1] = height[j];
        height[j] = temp;
      };
    };
  };
  
  for (i = 0; i < 3; i += 1) {
    printf("%d\n", height[i]);
  };
  
  return 0;
}

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

int compare_int(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int Matsuzaki(N,P) {

	int i,j,count,flag,prime[100],sum[10000];

	count=0;
		for(i=N+1;count<100;i++) {
			flag=1;

			if(i==0||i==1) flag=0;

			else if(i>=4) {
				for(j=2;j<=sqrt(i);j++) {
					if(i%j==0) {
						flag=0;
						break;
					}
				}
			}
				if(flag) {
					prime[count]=i;
					count++;
				}

		}

		count=0;
		for(i=0;i<100;i++) {
			for(j=i;j<100;j++) {
				sum[count]=prime[i]+prime[j];
			count++;
			}
		}

	qsort(sum,5050,sizeof(int),compare_int);

	return sum[P-1];
}

int main() {
	int N,P;

	for(;;) {
		scanf("%d %d",&N,&P);
		if(N==-1&&P==-1) break;
		printf("%d\n",Matsuzaki(N,P));
	}
	return 0;
}

Measured memory_bytes: 680
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int sum = 700;
void top(char c)
{
	if (c == 'o')
		sum += 100;
}

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < 3; ++i) {
		top(s[i]);
	}
	cout << sum;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //System.out.print("入力してください > ");
        //int    x = Integer.parseInt(scanner.nextLine());
        String s = scanner.nextLine();
        
        String[] ss = s.split(" ");
        
        int x = Integer.parseInt(ss[0]);
        int y = Integer.parseInt(ss[1]);
        
        int money = 0;
        
        if(x == 1) money += 300000;
        if(x == 2) money += 200000;
        if(x == 3) money += 100000;
        if(y == 1) money += 300000;
        if(y == 2) money += 200000;
        if(y == 3) money += 100000;
        
        if(x==1 && y==1) money += 400000;
        
        System.out.println(money);
        
        // Scannerクラスのインスタンスをクローズ
        scanner.close();
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
// #include"myfile.h"

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


void solve() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	int ma = 0;
	for (int i = 1; i < n; i++) ma = max(ma, a[i] - a[i - 1]);
	ma = max(ma, a[0] + k - a[n - 1]);

	int ans = k - ma;
	cout << ans << endl;


}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int counter = 0;


void solve(){
	int n,x,y,q;
	cin>>n;
	vl a(n+1);
	ll sum = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum += a[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		cout<<sum - a[x] + y<<endl; 
	}
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  int n; cin>>n; for (counter = 0; counter < n; ++counter)
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int n, k;
vector<int> v;

void init()
{
	cin >> n >> k;
	CINV(v, n);
	sort(all(v));
}

void solve()
{
	int mi = INT_MAX;
	for (int i = 0; i + k - 1 < n; i++) {
		mi = min(mi, v[i+k-1] - v[i]);
	}
	cout << mi << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

    for (long long a = -1000; a <= 1000; a++) {
        for (long long b = -1000; b <= 1000; b++) {
            if (a*a*a*a*a - b*b*b*b*b == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

int main() {
    vector<long long> LnLnList;
    int K;
    cin >> K;
    queue<long long> que;
    for(int i = 1; i < 10; ++i){
        que.push((long long)i);
    }
    while(LnLnList.size() < K) {
        long long p = que.front(); que.pop();
        LnLnList.push_back(p);
        long long x = p%10;
        if(x > 0) que.push(10*p + x-1);
        que.push(10*p + x);
        if(x < 9) que.push(10*p + x+1);
    }
    /*
    for(int i = 0; i < K; ++i) {
        cout << LnLnList[i] << endl;
    }
    cout << endl;
    */
    //sort(LnLnList.begin(), LnLnList.end());
    cout << LnLnList[K-1] << endl;
    return 0;
}

Measured memory_bytes: 2548
a, b, c, d = [i for i in input()]
op = ['+', '-']

for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d) == 7:
                print("{}=7".format(a+i+b+j+c+k+d))
                break

        else:
            continue
        break

    else:
        continue
    break


Measured memory_bytes: 2940
unittest
{
//	assert( [ "5" ].parse.expand.solve == "3 5 7 11 31" );
//	assert( [ "6" ].parse.expand.solve == "2 3 5 7 11 13" );
//	assert( [ "8" ].parse.expand.solve == "2 5 7 13 19 37 67 79" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	// 素数判定用素数列
	auto ps = primes( 1500 ).assumeSorted;
	
	// 5の倍数＋1の素数5つなら和が必ず5の倍数＋5（＝合成数）になる
	auto anss = new long[ n ];
	auto i = 0L;
	foreach( ref ans; anss )
	{
		do
		{
			i++;
		}
		while( ps.find( 5 * i + 1 ).empty );
		ans = 5 * i + 1;
	}
	return anss.to!( string[] ).join( " " );
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,k,n,m,l,a[100][100],b[100][100];
  long int s;
  scanf("%d%d%d",&n,&m,&l);

//行列A
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);

//行列B
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);

//行列C
  for(i=0;i<n;i++)
    for(j=0;j<l;j++){
      s = 0;
      for(k=0;k<m;k++)
        s += a[i][k] * b[k][j] ;
      printf("%ld", s);
      if(j+1 == l)
        printf("\n");
      else
        printf(" ");
    }

  return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

#define rep(i,n) for (int i = 0; i < (n); ++i)

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


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

    if (a > b) cout << a - 1 << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cmath>
 
using namespace std;
 
int main(void) {
    ll k, n;
    cin >> k >> n;
    ll a[n], b[n], d[n];
    rep(i, n){
        ll x;
        cin >> x;
        a[i] = x;
        if(x > k /2){
            x -= k;
        }
        b[i] = x;
    }
    if(n == 2){
        cout << abs(a[1] - a[0]) << endl;
        return 0;
    }
    else{
        rep(i, n-1){
            d[i] = abs(a[i+1] - a[i]);
        }
        d[n-1] = abs(b[n-1] - b[0]);
        ll max = 0;
        rep(i, n){
            if(d[i] > max){
                max = d[i];
            }
        }
        cout << k - max << endl;
        return 0;
    }
}

Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

		while (true) {
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			if(N == 0 || M == 0){
				break;
			}
			
			int max = 0;
			
			int[] array_1 = new int[N];
			for(int i = 0; i < N; i++){
				array_1[i] = sc.nextInt();
				max = Math.max(max, array_1[i] <= M ? array_1[i] : 0);
			}
			
			Arrays.sort(array_1);
			
			int[] array_2 = new int[((N + 1) * N) / 2];
			int count = 0;
			for(int i = 0; i < N; i++){
				for(int j = i; j < N; j++){
					array_2[count] = array_1[i] + array_1[j];
					max = Math.max(max, array_2[count] <= M ? array_2[count] : 0);
					count++;
				}
			}
			
			Arrays.sort(array_2);
			
			//System.out.println(Arrays.toString(array_1));
			//System.out.println(Arrays.toString(array_2));
			
			for(int i = 0; i < array_2.length; i++){
				int rest = M - array_2[i];
				
				int pos1 = Arrays.binarySearch(array_1, rest);
				if(pos1 < 0){
					pos1 = - (pos1 + 2);
				}
				
				if(pos1 >= 0){
					max = Math.max(max, array_2[i] + array_1[pos1]);
				}
				
				int pos2 = Arrays.binarySearch(array_2, rest);
				if(pos2 < 0){
					pos2 = - (pos2 + 2);
				}
				
				if(pos2 >= 0){
					max = Math.max(max, array_2[i] + array_2[pos2]);
				}
			}
			
			System.out.println(max);
		}
	}

}

Measured memory_bytes: 39760
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5; 
using namespace std;

int a[30] = {0};
int b[30] = {0};
int main() 
{ 
	int s, w;
	scanf("%d %d", &s, &w);
	if (s > w)
		printf("safe\n");
	else
		printf("unsafe\n");
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>

int main(void)
{
  int n,n_1000,n_100,n_10,count=0;

  scanf("%d",&n);

  n_1000 = n / 1000;
  n = n - 1000 * n_1000;
  n_100 = n / 100;
  n = n - 100 * n_100;
  n_10 = n / 10;
  n = n - 10 * n_10;

  if(n_1000==2)
    {
      count = 1;
    }

  if(n_100==2)
    {
      count += 1;
    }

    if(n_10==2)
    {
      count += 1;
    }

    if(n==2)
    {
      count += 1;
    }

    printf("%d",count);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int min_cost = 1e9;
int D, G; 
vector<pair<int, int>> pv;

void dfs(string s, int depth){
	if(depth == D){
		int score = 0;
		int cost = 0;
		//cout << s << endl;
		for(int i = 0; i < D; i++){
			if(s[i] == '1'){
				score += (((i+1) * 100 *pv[i].first) + pv[i].second);
				cost += pv[i].first;
				//cout << cost << endl;
			}
		}

		//cout << score << ": " << cost << endl;
		if( score < G ){
			//for(auto i = pv.end(); i != pv.bein(); i--){
			for(int i = s.size()-1; i >= 0; i--){
				//cout << "s" << s[i] << endl;
				if(s[i] == '0'){
					for(int j = 0; j < pv[i].first; j++){
						score += ((i+1) * 100);
						cost++;
						if(score >= G)break;
					}
				}
				if(score >= G)break;
			}
		}
		//cout << score << ": " << cost << endl;
		if( score >= G ) min_cost = min(min_cost, cost);
		return;
	}

	for(int i = 0; i < 2; i++){
		if(i == 0)dfs(s + '0', depth + 1);
		else dfs(s + '1', depth + 1);

	}	
}

int main(){
	cin >> D >> G;
	for(int i = 0; i < D; i++){
		pair<int, int> p; cin >> p.first >> p.second;
		pv.push_back(p);
	}
	dfs("",0);
	cout << min_cost << endl;
}

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

typedef long long ll;
const int mod = 1000000007, iv3 = (mod + 1) / 3;

int n;
int inv[1000054];

ll PowerMod(ll a, int n, ll c = 1) {for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c;}

int main() {
	int i, s = iv3;
	scanf("%d", &n);
	for (inv[1] = 1, i = 2; i <= n; ++i)
		inv[i] = ll(mod - mod / i) * inv[mod % i] % mod, s = ll(s + inv[i]) * iv3 % mod;
	printf("%d\n", (int)PowerMod(n, mod - 2, s));
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using ll = long long;
using namespace std;        
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define ar array


void solve(){
			int n,q; cin>>n;
			map<ll,ll> m;
			ll sum=0;
			for(int i=0;i<n;i++){
				ll x;cin>>x;
				m[x]++;
				sum+=x;
			}
			cin>>q;
			while(q--){
				ll a,b; cin>>a>>b;
				sum-=m[a]*a;
				sum+=m[a]*b;
				m[b]+=m[a];
				m[a]=0;
				cout<<sum<<endl;
			
			}
			

}

int main(){
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
//	freopen("input.txt",r,"stdin");
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}





Measured memory_bytes: 9384
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	bool be[1001] = {};
	for(int i = 2; i<10; i++){
		for(int j = 1; (int)pow(j, i) <= 1000; j++){
			be[(int)pow(j, i) ] = true;
		}
	}
	int x;
	cin >> x;
	for(int i = x; i >= 1; i--){
		if(be[i]){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	/*
	 * default function
	 * */	
	int ni() {
		return cin.nextInt();
	}
	
	long nl() {
		return cin.nextLong();
	}
	
	String line() {
		return cin.nextLine();
	}
	
	void println(String str) {	
		System.out.println(str);
	}
	
	void print(String str) {
		System.out.print(str);
	}
	
	/*
	 * default variable
	 */
	
	static final int MOD = 1000000007;
	
	Scanner cin = new Scanner(System.in);	
	String  output;
	
	public static void main(String[] args) {			
		new Main().run();						
	}
	/* default above */
		
	public void run() {
			
		input();
		/* 
		 * start
		 */	
		
		int res = solve();
		
		/*
		 * finish
		 */
		
		output = res +"";
		println(output);
			
	}
	/* 
	 * define variable
	 */
	
	int H, W;
	
	void input() {
		H = ni();
		W = ni();
		
		if (W > H) {
			W = H + W;
			H = W - H;
			W = W - H;
		}
	}
	
	int solve() {
		
		if (H % 3 == 0 || W % 3 == 0) {
			return 0;
		}
		
		return Math.min(cal(H, W), cal(W, H));		
	}
	
	int cal(long h, long w) {
		
		long res = Long.MAX_VALUE;
		
		res = Math.min(res, W);
		
		for (long i = h/3; i <= h/2; i ++) {
			long a[] = new long[3];
			
			a[0] = (i) * w;
			a[1] = (h - i) * (w / 2);
			a[2] = (h - i) * (w - w/2);
			Arrays.sort(a);
			res = Math.min(res, a[2] - a[0]);		
		}
		return (int)res;
	}
	
	
}


Measured memory_bytes: 23892
n , k = map(int, input().split())
r , s , p = map(int, input().split())
t = input()
g = [['?']*(n//k+2) for i in range(k)]
for i in range(n):
    g[i%k][i//k]=t[i]
score = 0
for i in range(k):
    ch=1
    for j in range(n//k+1):
        if ch%2==0:
            if g[i][j]==g[i][j+1]:
                ch+=1
            else:
                ch=1
            continue
        if g[i][j]==g[i][j+1]:
            ch+=1
        else:
            ch=1
        if g[i][j]=='r':
            score+=p
        if g[i][j]=='s':
            score+=r
        if g[i][j]=='p':
            score+=s
print(score)


Measured memory_bytes: 12020
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << ' ' << a[2] << '\n';
	return 0;
}



Measured memory_bytes: 3204
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] price = new int[n];
		int maxp = 0;
		int sum = 0;
		for( int i = 0; i < n; i++ ) {
			price[i] = in.nextInt();
			maxp = Math.max(price[i], maxp);
			sum += price[i];
		}
		System.out.println(sum-maxp+(maxp/2));
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long i64;

int n;
i64 L;
i64 a[100010];
i64 sum = 0;

vector<int> ans;

int main()
{
	cin >> n >> L;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
	}

	int ans = -1;

	for(int i = 2;i <= n;i++)
	{
		if(a[i - 1] + a[i] >= L)
		{
			ans = i - 1;
			break;
		}
	}

	if(ans == -1)
	{
		cout << "Impossible" << endl;
		return 0;
	}

	cout << "Possible" << endl;

	for(int i = 1;i < ans ;i++)
	{
		cout << i << endl;
	}
	for(int i = n - 1;i >= ans + 1;i--)
	{
		cout << i << endl;
	}
	cout << ans << endl;
	return 0;

}


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

int main()
{
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vector<vector<int>> dp(n + 1, vector<int>(m + 1));
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (j + 1 <= m) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
			if (i + 1 <= n) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (i < n && j < m && s[i] == t[j]) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			}
		}
	}
	int ti = n, tj = m;
	string res;
	while (ti != 0 || tj != 0) {
		if (0 <= ti - 1 && 0 <= tj - 1 && s[ti - 1] == t[tj - 1]) {
			res.push_back(s[ti - 1]);
			ti -= 1;
			tj -= 1;
			continue;
		}
		if (0 <= ti - 1 && dp[ti - 1][tj] == dp[ti][tj]) {
			ti -= 1;
		}
		else {
			tj -= 1;
		}
	}
	reverse(res.begin(), res.end());
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 35584
fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.split("")
            .filter { it.isNotEmpty() }.map(String::toInt)
    val opList = mutableListOf<List<Int>>()
    (0..7).forEach { i ->
        run {
            opList.add(String.format("%03d", Integer.toBinaryString(i).toInt()).split("").filter { it.isNotEmpty() }.map(String::toInt))
        }
    }
    for (op in opList) {
        var result = a
        result += if (op[0] == 0) b else -b
        result += if (op[1] == 0) c else -c
        result += if (op[2] == 0) d else -d
        if (result == 7) {
            val builder = StringBuilder()
            builder.append(a)
            builder.append(if (op[0] == 0) "+" else "-")
            builder.append(b)
            builder.append(if (op[1] == 0) "+" else "-")
            builder.append(c)
            builder.append(if (op[2] == 0) "+" else "-")
            builder.append(d)
            builder.append("=7")
            println(builder.toString())
            return
        }
    }
}

Measured memory_bytes: 36012
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

n=5;
fr(i,0,n){
	cin >> k;
	if(k == 0){
		cout << i+1;
		return 0 ; 
	}
}

 eNd();
  return 0;
 
}


Measured memory_bytes: 3588
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int X, Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n; ld ar[N]; ld dp[N][N];
ld findans(ll i,ll cnt_h){
	ll cnt_t=(i-1-cnt_h);
	if(i==n+1){
		if(cnt_h>cnt_t) return 1.0;
		else return 0.0;
	}
	if(dp[i][cnt_h]!=-1.0){
		return dp[i][cnt_h];
	}

	ld a,b;
	a=findans(i+1,cnt_h+1)*ar[i];
	b=findans(i+1,cnt_h)*(1.0-ar[i]);
	return dp[i][cnt_h]=a+b;
}
int main(){

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

	ll i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			dp[i][j]=-1.0;
		}
	}
	ld an=findans(1,0);
	cout<<fixed<<setprecision(10)<<an;
	return 0;
}

Measured memory_bytes: 142592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define pr pair<int, int>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define pls +
#define le <=
#define ge <=
//int mx=9999999;
/**  '' "\n" x ^ **/
void YES()
{
    cout<<"YES\n";
}

void NO()
{
    cout<<"NO\n";
}
void yes()
{
    cout<<"Yes\n";
}

void no()
{
    cout<<"No\n";
}
int main() {
    /**  '' "\n" x ^ **/
    /** printf("\n") */
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>k>>n;
    int a[n];
    in(i,n)
    {
        sf(a[i]);
    }
    ll sum1 E 0,sum2 E 0;
    for(int i=1;i<n;i++)
    {
        sum1 E sum1 pls (a[i] mn a[i mn 1]);
    }
    ll test=k+a[0];
    test=test mn a[n mn 1];
    //cout<<sum1;ps();cout<<sum<<endl;
    ll l=9999999;
    if(sum1<l)
        l=sum1;
    if((sum1 mn (a[1] mn a[0])+test)<l)
        l=(sum1 mn (a[1] mn a[0])+test);
    for(int i=1;i<n mn 1;i++)
    {
        ll b=sum1;
        b = b mn (a[i] mn a[ i mn 1]);
        b+=test;
        if(b<l)
            l=b;
        b=sum1;
        b=b mn (a[i+1] mn a[i]);
        b+=test;
        if(b<l)
            l=b;
    }
    ll p=sum1;
    p=p mn (a[n mn 1] mn a[n mn 2]);
    p+=test;
    if(p<l)
        l=p;
    pf(l);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	int x,y;
	cin>>n>>x>>y;
	x--, y--;
	
	vvi dp(n,vi(n,INF));
	dp[x][y]=dp[y][x]=1;
	for(int i=x;i<=y;++i){
		for(int j=i;j<=y;++j){
			dp[i][j]=dp[j][i]=min(j-i,(i-x)+1+(y-j));
		}
	}
	
	REP(i,x)for(int j=i;j<x;++j){
		dp[i][j]=dp[j][i]=j-i;
	}
	for(int i=y+1;i<n;++i)for(int j=i;j<n;++j){
		dp[i][j]=dp[j][i]=j-i;
	}
	
	REP(i,x)for(int j=x;j<=y;++j){
		dp[i][j]=dp[j][i]=dp[i][x-1]+dp[x][j]+1;
	}
	for(int i=x;i<=y;++i)for(int j=y+1;j<n;++j){
		dp[i][j]=dp[j][i]=dp[i][y]+dp[y+1][j]+1;
	}
	REP(i,x)for(int j=y+1;j<n;++j){
		dp[i][j]=dp[j][i]=dp[i][x]+dp[x][j];
	}
	
	/*REP(i,n)for(int j=i;j<n;++j){
		cout<<i<<j<<' '<<dp[i][j]<<endl;
	}*/
	
	vi ans(n,0);
	REP(i,n-1)for(int j=i;j<n;++j){
		ans[dp[i][j]]++;
	}
	
	for(int i=1;i<n;++i) cout<<ans[i]<<endl;
}

Measured memory_bytes: 16000
a = []

n = int(input())

for i in ['S', 'H', 'C', 'D']:
    for j in range(1, 14):
        a.append([i, j])

for i in range(1, n + 1):
    ca, integer = input().split()
    a.remove([ca, int(integer)])

for i in range(len(a)):
    print(a[i][0]+' %d' % (a[i][1]))



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef struct{
  string s;
  int k;
}sstr;
main(){
  sstr red[101];
  string t[101];
  int n,m;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>red[i].s;
    red[i].k=1;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>t[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(red[i].s==red[j].s){
        red[i].k++;
      }
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(red[i].s==t[j]) --red[i].k;
    }
    if(ans<red[i].k) ans=red[i].k;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
'''
nCk mod pを求める。

nCk= n!/k!(n-k)!を考えるが、単純計算だと途中の桁が膨大になり計算が間に合わない。
そこで計算中にmodをとるが、割り算にmodを適用するためには逆元を求める必要がある。


'''

from collections import defaultdict,deque
import sys, bisect, math, itertools
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


class combination():
    def __init__(self, mod):
        '''
        modを指定して初期化
        '''
        self.mod=mod
        self.fac = [1, 1]  # 階乗テーブル
        self.ifac = [1, 1]  # 階乗の逆元テーブル
        self.inv = [0, 1]  # 逆元計算用

    def calc(self,n,k):
        '''
        nCk%modを計算する
        '''
        if k < 0 or n < k:
            return 0
        self.make_tables(n) #テーブル作成
        k = min(k, n - k)
        return self.fac[n] * (self.ifac[k] * self.ifac[n - k] % self.mod) % self.mod

    def make_tables(self, n):
        '''
        階乗テーブル・階乗の逆元テーブルを作成
        '''
        for i in range(len(self.fac), n + 1):
            self.fac.append((self.fac[-1] * i) % self.mod)
            self.inv.append((-self.inv[self.mod % i] * (self.mod // i)) % self.mod)
            self.ifac.append((self.ifac[-1] * self.inv[-1]) % self.mod)

comb = combination(mod)

x, y = inpl()
if x > y:
    x, y = y, x
dist = x + y
if dist % 3:
    print(0)
    exit()
total = int((x + y) // 3)
n = x - total
if y > 2 * x:
    print(0)
    exit()

print(comb.calc(total, n))

Measured memory_bytes: 118764
// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

int n, k;

void work() {
	n = read(), k = read();
	if (k == 1) cout << 0 << endl;
	else cout << n -  k << endl;
}

int main(){
	#ifdef LZT
		freopen("in","r",stdin);
	#endif

	work();

	#ifdef LZT
		Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
	#endif
}


Measured memory_bytes: 256
def merge( tS, left, mid, right )
	n1 = mid - left;
	n2 = right - mid;
	tL = tS[ left ... mid ];
	tR = tS[ mid ... right ];	
	tL.push( 1000000001 )
	tR.push( 1000000001 )
	i = j = 0
	for k in ( left ... right )
		$cnt += 1
		if tL[i] <= tR[j]
			tS[k] = tL[i]
			i += 1
		else
			tS[k] = tR[j]
			j += 1
		end
	end
end

def mergeSort( tS, left, right )
	if left+1 < right
		mid = ( left+right )/2
		mergeSort( tS, left, mid )
		mergeSort( tS, mid, right )
		merge( tS, left, mid, right )
	end
end

n = gets.to_i
arrS = gets.split( " " ).map { |val| val.to_i }
$cnt = 0
mergeSort( arrS, 0, n )
puts( arrS.join( " " ) )
puts( $cnt )

Measured memory_bytes: 208536
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0 };
int dy[] = { 0,1,-1 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}
long long convert_to_num(string x) {
	long long  num = 0;
	for (int i = 0; i < x.size(); i++) {
		num *= 2;
		num += x[i] - '0';
	}
	return num;
}

long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	
	string s;
  cin>>s;
  if(s.size()>=6&&s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes";
  else
    cout<<"No";
	
	return 0;

}

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

int main() {
	ll n; cin >> n;
	
	ll ans = n;
	rep(i, 0, n + 1) {
		ll c = 0, t = i;
		while (t > 0) {
			c += t % 6;
			t /= 6;
		}
		t = n - i;
		while (t > 0) {
			c += t % 9;
			t /= 9;
		}
		ans = min(ans, c);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll a[100];
int main(){
    a[0] = 2;
    a[1] = 1;
    int n;
    cin >> n;
    for(int i=2;i<=n;i++) a[i] = a[i-1]+a[i-2];
    cout << a[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  int ret = 0;
  for (ll i=2; i*i <= N; i++) {
    if (N % i == 0) {
      int c = 0;
      while (N % i == 0) {
        N = N / i;
        c++;
      }
      for (int j=1; ; j++) {
        if (c < j) break;
        c -= j;
        ret++;
      }
    }
  }
  if (N > 1) ret++;
  cout << ret << endl;
}

Measured memory_bytes: 3652
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum MM = [0,2,5,5,4,5,6,3,7,6];

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    auto ms = new bool[](11);
    foreach (a; readln.split.to!(int[])) ms[a] = true;

    int[] max_rs(int[] aa, int[] bb) {
        int ac, bc;
        foreach (a; aa) ac += a;
        foreach (b; bb) bc += b;
        if (ac > bc) {
            return aa;
        } else if (ac < bc) {
            return bb;
        }
        foreach_reverse (i; 1..10) {
            if (aa[i] > bb[i]) {
                return aa;
            } else if (aa[i] < bb[i]) {
                return bb;
            }
        }
        return aa;
    }

    auto DP = new int[][][](10, N+1, 0);
    auto ng = new int[](11);
    ng[0] = -1;
    int[] solve(int i, int n) {
        if (i == 10) return n == 0 ? new int[](11) : ng;
        if (DP[i][n].empty) {
            if (ms[i] && n >= MM[i]) {
                auto r1 = solve(i+1, n);
                auto r2 = solve(i, n-MM[i]).dup;
                r2[i] += 1;
                DP[i][n] = max_rs(r1, r2);
            } else {
                DP[i][n] = solve(i+1, n);
            }
        }
        return DP[i][n];
    }

    int[] res;
    foreach_reverse (i, n; solve(1, N)) if (n) {
        foreach (_; 0..n) res ~= i.to!int;
    }
    writeln(res.to!(string[]).join(""));
}

Measured memory_bytes: 13656
#!/usr/bin/env python3

import networkx as nx


n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(n)]


match_list = [[] for i in range(n)]
for i in range(n):
    for j in range(n):
        a, b = ab[i]
        c, d = cd[j]

        if a < c and b < d:
            match_list[i].append(j)
# print(match_list)


group1 = range(n)
group2 = range(n, 2*n)

g = nx.Graph()
g.add_nodes_from(group1, bipartite=1)
g.add_nodes_from(group2, bipartite=0)

for i, list_ in enumerate(match_list):
    for j in list_:
        g.add_edge(i, j+n, weight=1)

# A, B = bipartite.sets(g)
# print(A, B)
# pos = dict()
# pos.update((n, (1, i)) for i, n in enumerate(A))
# pos.update((n, (2, i)) for i, n in enumerate(B))
# nx.draw_networkx(g, pos)
# nx.draw_networkx_edges(g, pos)
# plt.axis("off")
# plt.show()


d = nx.max_weight_matching(g)

print(len(d))


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

int main() {
    int n;
    string str, ans = "";
    cin >> n >> str;
    rep(i, str.length()) {
        if(str.at(i) + n <= 'Z') ans += str.at(i) + n;
        else ans += str.at(i) + n - 26;
    }
    cout << ans << endl;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n,m;
	cin >> n >> m;
	int l[m],r[m];
	int imos[n+1] = {};
	REP(i,m) cin >> l[i] >> r[i];
	REP(i,m){
		imos[l[i]]++;
		imos[r[i]+1]--;
	}
	REP(i,n+1) imos[i+1]+=imos[i];
	size_t ans = count(imos,imos+n+1,m);
	cout << ans << endl;

}


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

int f(int x){
    int ans = 0;
    while(x > 0){
        ans += x % 10;
        x /= 10;
    }

    return ans;
}

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

    if(n % f(n) == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,mt;
    scanf("%d %d %d",&n,&a,&b);
    mt=n*a;
    if(mt<b)
    {
        printf("%d\n",mt);
    }
    else
    {
        printf("%d\n",b);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int a,b,c,d,x,m=100000000,ans;
	cin>>a>>b>>c;
	x=(b-c)*1000;
	f(i,a){
		cin>>d;
		if(m>abs(x-d*6)){
			m=abs(x-d*6);
			ans=i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s,t; cin >> s >> t;
  ll n = s.size(); ll m = t.size();
  
  ll cnt = n;
  
  for(ll i=0; m-1+i <= n-1; i++){
    ll sum = 0;
    rep(j,m){
      if(t[j] != s[i+j]) sum++;
    }
    
    cnt = min(sum,cnt);
    
  }
  
  
  cout << cnt << endl;
  
  
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
	public static long solve(long n){
		long div = 5;
		long sum = 0;
		while( div <= n ){
			sum += n/div;
			div *= 5;
		}
		return sum;
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<Long> result = new ArrayList<Long>();
		
		long n;
		while( (n = stdIn.nextLong()) != 0 ){
			result.add(solve(n));
		}
		for(Long num : result){
			System.out.println(num);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int MAX_N = 4005;
int dp[MAX_N + 1][MAX_N + 1];
string s, t;

int solve(){
    int n = s.size(), m = t.size(); //????????°?????±?????¨?????????????????????
    rep(i,MAX_N) rep(j,MAX_N) dp[i][j] = 0;

    rep(i,n){
        rep(j,m){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            //jelse{
            //j    dp[i + 1][j + 1] = min(dp[i][j + 1], dp[i + 1][j]);
            //j}
        }
    }

    int sum = 0;
    rep(i,n + 1){
        rep(j,m + 1){
            sum = max(sum,dp[i][j]);
        }
    }
    return sum;
}

int main(){
    while(cin >> s >> t){
        cout << solve() << endl;
    }
}

Measured memory_bytes: 65868
#include<iostream>
#include<string>
using namespace std;
int main(){
  int X,A,B;
  cin>>X>>A>>B;
  if(A>=B){
    cout<<"delicious"<<endl;
  }else if((B-A)<=X){
    cout<<"safe"<<endl;
  }else
    cout<<"dangerous"<<endl;
  return 0;
}


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

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)cin >> a[i];
    int pos = 1;
    ll cnt = 0;
    do {
        --pos;
        if(a[pos]==-1){
            cout << -1 << "\n";
            return 0;
        }
        if(a[pos]==2){
            cout << ++cnt << "\n";
            return 0;
        }
        int b = pos;
        pos = a[pos];
        a[b] = -1;
        ++cnt;
    } while(pos!=2);
    return 0;
}

Measured memory_bytes: 640
import sys
readline = sys.stdin.readline
def dfs(root):
    visited = [False] * n
    queue = [(0, root)]
    longest = (-1, -1)
    while queue:
        total_weight, node = queue.pop()
        if visited[node]: continue
        visited[node] = True
        longest = max(longest, (total_weight, node))
        queue.extend((total_weight + w, t) for w, t in edges[node] if not visited[t])
    return longest
n = int(readline())
edges = [set() for _ in range(n)]
for _ in range(n - 1):
    s, t, w = map(int, readline().split())
    edges[s].add((w, t))
    edges[t].add((w, s))
_, ln = dfs(0)
ld, _ = dfs(ln)
print(ld)

Measured memory_bytes: 52912
program sample1
implicit none

integer a,b
read(*,*) a
b=0
If(a/100.0>=1.0) then
   b=b+1
   a=a-100
end if   
If(a/10.0>=1.0) then
   b=b+1
   a=a-10
end if
If(a>=1) then
    b=b+1
end if
write(*,*) b

stop
end program sample1




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] cost = new int[n+1][n+1];
        int[] rc = new int[n+1];

        for (int i = 0; i < n; i++) {
            rc[i]   = sc.nextInt();
            rc[i+1] = sc.nextInt();
        }
        
        for (int l = 2; l <= n; l++) {
            for (int i = 1; i <= n - l + 1; i++) {
                int j = i + l - 1;
                cost[i][j] = (1 << 21);
                for (int k = i; k <= j - 1; k++) {
                    cost[i][j] = Math.min(cost[i][j], cost[i][k] + cost[k + 1][j] + rc[i-1] * rc[k] * rc[j]);
                }
            }
        }
        System.out.println(cost[1][n]);
    }
}


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

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

  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  int ans=1;
  int td=0;
  for(int i=0; i<n; i++){
    td+=l[i];
    if(td<=x) ans++;
    else break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256