akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;

int f[15][15][1005],s[15][1005],n,m,k;
int ans=2e5,d[15],tot[15];
vector<pii> vec;

void dfs(int x)
{
	if(x==n) {
		vec.clear();
		memset(tot,0,sizeof tot);
		int las=1,cnt=0;
		for(int i=1;i<n;++i) {
			if(d[i]==1) {
				cnt++;
				vec.push_back(mp(las,i));
				las=i+1;
			}
		}
		vec.push_back(mp(las,n));
		int s,t;
		for(int j=1;j<=m;++j) {
			for(int i=0;i<vec.size();++i) {
				s=vec[i].fi,t=vec[i].se;
				if(f[s][t][j]>k) return;
				tot[i]+=f[s][t][j];
			}
			for(int i=0;i<vec.size();++i) {
				if(tot[i]>k) {
					cnt++;
					for(int a=0;a<vec.size();++a) {
						s=vec[a].fi,t=vec[a].se;
						tot[a]=f[s][t][j];
					}
					break;
				}
			}
		}
		ans=min(ans,cnt);
//		printf("%d ",ans);
		return ;
	}
	d[x]=1;
	dfs(x+1);
	d[x]=0;
	dfs(x+1);
}

int main()
{
	scanf("%d %d %d",&n,&m,&k);
	char c;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j) {
			c=getchar();
			while(c!='1'&&c!='0') c=getchar();
			s[i][j]=c;
		}
	for(int i=1;i<=n;++i)
		for(int j=i;j<=n;++j)
			for(int k=i;k<=j;++k)
				for(int a=1;a<=m;++a) f[i][j][a]+=(s[k][a]=='1');
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
a = []
for i in range(3):
    a.extend(list(map(int, input().split())) )
    
count_list =sorted([a.count(i) for i in range(1, 5)])

if count_list.count(1)==2&count_list.count(2)==2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int n,M;
int x[11],y[11];

bool solve(){
	int m;cin >> m;
	vector<pair<int,int>> v(m);
	for(int i=0;i<m;i++){
		cin >> v[i].first >> v[i].second;
	}
	if(m!=M)return 0;
	bool ok=true;
	for(int i=1;i<m;i++){
		ok&=(abs(v[i].first-v[i-1].first)+abs(v[i].second-v[i-1].second)==abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
	}
	for(int i=1;i<m-1;i++){
		ok&=((v[i-1].first-v[i].first)*(v[i+1].second-v[i].second)-(v[i-1].second-v[i].second)*(v[i+1].first-v[i].first)>0)==((x[i-1]-x[i])*(y[i+1]-y[i])-(y[i-1]-y[i])*(x[i+1]-x[i])>0);
	}
	if(ok)return 1;
	ok=1;
	reverse(v.begin(), v.end());
	for(int i=1;i<m;i++){
		ok&=(abs(v[i].first-v[i-1].first)+abs(v[i].second-v[i-1].second)==abs(x[i]-x[i-1])+abs(y[i]-y[i-1]));
	}
	for(int i=1;i<m-1;i++){
		ok&=((v[i-1].first-v[i].first)*(v[i+1].second-v[i].second)-(v[i-1].second-v[i].second)*(v[i+1].first-v[i].first)>0)==((x[i-1]-x[i])*(y[i+1]-y[i])-(y[i-1]-y[i])*(x[i+1]-x[i])>0);
	}
	if(ok)return 1;
	return 0;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(cin >> n,n){
		cin >> M;
		for(int i=0;i<M;i++){
			cin >> x[i] >> y[i];
		}
		for(int i=0;i<n;i++){
			if(solve())printf("%d\n",i+1);
		}
		printf("+++++\n");
	}
}



Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<string> s;
    for(int i=0;i<n;i++)
    {
        string x;
        cin>>x;
        s.push_back(x);

    }
    sort(s.begin(),s.end());
    for(int i=0;i<s.size();i++)
    {
        cout<<s[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())
li = list(map(int,input().split()))
ans = [1]
nex = 1
f = [1]+[0]*(n-1)

for i in range(n):
    now = nex #今の場所
    nex = li[now-1] #テレポート先の場所
    #print(now,nex)
    if f[nex-1] == 1: #循環判定
        a = ans.index(nex) #開始点
        b = ans.index(now)-a+1 #循環周期
        break
    f[now-1] = 1
    ans.append(li[now-1])

#print(ans)
#print(f)
if k <= a:
    print(ans[k])
else:
    x = (k-a)%b
    print(ans[a+x])

Measured memory_bytes: 32252
#include<bits/stdc++.h>
#define N 50009
using namespace std;

const int INF = 0x3f3f3f3f;

char s[N];
bool judge()
{
    int len = strlen(s);
    if(len > 26) return false;
    int a[33];
    memset(a, 0, sizeof(a));
    for(int i = 0; i < len; i++)
    {
        int k = s[i] - 'a';
        if(a[k]) return false;
        a[k]++;
    }
    return true;
}

int main()
{
    scanf(" %s", s);
    if(judge()) puts("yes");
    else puts("no");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		int c=scn.nextInt();
		System.out.println(Math.min(b/a, c));
	}

}


Measured memory_bytes: 22608
for t in range(1):
	n=input()
	s=input()
	freq=[0]*(26)
	ct=0
	for i in range(len(s)):
		freq[ord(s[i])-ord('a')]+=1
		if freq[ord(s[i])-ord('a')]==1:
			ct+=1
	ans=1
	for i in range(26):
		if freq[i]>0:
			ans=(ans*(freq[i]+1))
	print((ans-1)%1000000007)



Measured memory_bytes: 3188
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 C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		
		if(A > D || B < C)
			System.out.println("0");
		else {
			int x = B > D ? D : B;
			if(A < C)
				System.out.println((x - C));
			else
				System.out.println((x - A));
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main() {long N; string s;
cin >> N >> s;
long x = 0; long ans = 0;
rep(i, N){
    if(s.at(i) == 'I'){
        x++;
        ans = max(ans, x);
    }
    else x--;
}


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



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int n, x, localm, max_num= 64;
  cin >> n;
  for (int k = 0; k<n; k++) {
    cin >> x;
    localm = 0;
    while (x % 2 == 0 && x != 0) {
      localm += 1;
      x = x / 2;
    }
    if (localm < max_num) {
      max_num = localm;
    }
  }
  cout << max_num;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 1000000
int main() {
	int i, j, cnt, *p, n;
	p = (int*)calloc(N, sizeof(int));
	for (i = 2; i <= (int)sqrt((double)N); ++i) if (!*(p+i)) for (j = 2; j*i < N; j++) *(p+i*j) = 1;
	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		cnt = 0;
		for (i = 2; i <= n / 2; i++) if (!*(p+i) && !*(p+n-i)) cnt++;
		printf("%d\n", cnt);
	}
	free(p);
	return 0;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	int n,l;
	cin >> n >> l;
	string s[n];
	REP(i,n) cin >> s[i];
	SORT(s,n);
	REP(i,n) cout << s[i];
	cout << endl;

//////////////////////////////////////////////
}


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

using namespace std;

const int MOD = 1e9 + 7;

void add(int &x, int y) {
   x += y;
   if (x >= MOD) x -= MOD;
}

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   string S;
   cin >> S;
   array<array<int, 3>, 3> dp = {};
   dp[0][0] = 1;
   int ans = 0;
   for (char c : S) {
      array<array<int, 3>, 3> ndp = {};
      if (c == '?') add(ans, ans);
      if (c != '0') {
         for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
               if (j) add(ndp[i][j - 1], dp[i][j]);
               else if (i == 2) add(ans, dp[i][j]);
               else add(ndp[i + 1][j], dp[i][j]);
            }
         }
      }
      if (c != '1') {
         for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
               int nj = j + 1;
               if (nj == 3) nj = 1;
               add(ndp[i][nj], dp[i][j]);
            }
         }
      }
      dp = ndp;
   }
   add(ans, dp[2][1]);
   add(ans, dp[1][0]);
   cout << ans << "\n";
   return 0;
}


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

int n,ans=0;
std::string shop_name,sign[101]; 

int main(){
	std::cin>>n>>shop_name;
	for(int i=0;i<n;i++){
		std::cin>>sign[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<sign[i].size();j++){
			if(sign[i][j]==shop_name[0]){
				for(int k=j+1;k<sign[i].size();k++){
					if(sign[i][k]==shop_name[1]){
						for(int l=2,m=k+(k-j);l<shop_name.size() && m<sign[i].size();l++,m+=(k-j)){
							if(sign[i][m]!=shop_name[l])break;
							if(l==shop_name.size()-1){
								ans++;
								goto end;
							}
						}
					}
				}
			}
		}
		end:;
	}
	std::cout<<ans<<std::endl;
	return 0;
}

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

int main(){

    int deck[4][14] = { };

    int n;
    std::cin >> n;

    char a;
    int  b;

    for ( int i = 0; i < n; i++ ) {

        std::cin >> a >> b;
   
        if ( a == 'S' ) deck[0][b]++;
        if ( a == 'H' ) deck[1][b]++;
        if ( a == 'C' ) deck[2][b]++;
        if ( a == 'D' ) deck[3][b]++;
    }

    for ( int i = 0; i < 4; i++ ) {
        for ( int j = 1; j <= 13; j++) {
            if ( deck[i][j] == 0 ) {
                std::cout << "SHCD"[i] << " " << j << std::endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    
    for(int i=0; i<n; i++){
      a[i]=sc.nextInt();
    }
    
    for(int i=n-1; i>=0; i-=2){
      System.out.print(a[i]+" ");
    }
    for(int i=n%2; i<n; i+=2){
      System.out.print(a[i]+" ");
    }
  }
}
    
    
    
    

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

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

    cout << (N - 1 + K - 2) / (K - 1) << endl;

    return 0;
}

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

using ll = long long;

constexpr ll INF = 1e18;

struct edge {
    int from, to, cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

int main() {
    int N, M;
    cin >> N >> M;
    edges es(M);
    for(int i = 0; i < M; ++i) {
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].from--;
        es[i].to--;
        es[i].cost = -es[i].cost;
    }

    ll res = INF;
    vector<ll> d(N, INF);
    d[0] = 0;
    for(int i = 0; i < 3 * N; ++i) {
        for(auto& e : es) {
            if(d[e.to] > d[e.from] + e.cost) {
                if(e.to == N - 1 && i >= N) {
                    cout << "inf" << endl;
                    return 0;
                }
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    cout << -d[N - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int NMAX = 100;
const int MMAX = 1000;
const int INF = 100000;

int main() {
  int n, m;
  cin >> n >> m;
  int a[MMAX], b[MMAX], c[MMAX];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  int d[NMAX][NMAX];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  for (int i = 0; i < m; i++) {
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	private static Scanner scan;

	public static void main(String[] args) {
		scan = new Scanner(System.in);
		while(scan.hasNext()){
			String s = scan.next();
			int n = Integer.parseInt(s);
			int m = 0;
			for(int i = 0;i <=9;i++){
				for(int j = 0;j <=9;j++){
					for(int k = 0;k <=9;k++){
						for(int l = 0;l <=9;l++){
							if(i + j + k + l == n){
								m++;
							}
						}
					}
				}
			}
			System.out.println(m);
		}
		System.exit(0);
	}
}

Measured memory_bytes: 12000
n = int(input())
a = list(map(int,input().split()))
k = sum(a)
c = 0
ans = [0]*n
for i in range(n//2):
  c += a[i*2+1]
one = k - 2*c
ans[0] = one
for j in range(1,n):
  ans[j] = (a[j-1] - ans[j-1]//2)*2
for ji in ans:
  print(ji,end=' ')

Measured memory_bytes: 14028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

	
int main()
{
	int n;cin>>n;
	cout<<(n/2)*(n-n/2)<<"\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long[] a = new long[5];
        long[] remain = new long[6];
		long num = sc.nextLong();
        remain[0] = num;
        for(int i=0; i<5; i++){
          a[i] = sc.nextLong();
        }
        long min = a[0];
        long count = 0;
        int plus = 0;
        for(int i=1; i<5; i++){
          if(a[i] < min) {
            min = a[i];
            plus = i;
          }
          //if(a[i] < a[i+1]) a[i+1] = a[i];
          //if(a[i] > a[i+1]) plus += (a[i]-a[i+1]);
        }
        count = num / min;
          if(num > min && (num % min) == 0) count--;
          //count++;
          //if(remain[5] == num) break; 
        //}
		System.out.println(count+5);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    ll n, d; cin >> n >> d;
    ll x, y;
    int c = 0;
     rep(i, n) {
        cin >> x >> y;
        if (x*x + y*y <= d*d) ++c;
     }
     cout << c << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int n,m;
int dp[100010];
string nengo;
string nen;
string tuki;
string niti;

const long long INF = 1LL << 62;

int main(){
    cin >> nengo;
    stringstream ss{nengo};
    getline(ss, nen, '/');
    getline(ss, tuki, '/');
    getline(ss, niti, '/');
    if(stoi(tuki)<5){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t,u;
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(s==u) a--;
	else b--;
	cout<<a<<' '<<b;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	static int count = 0;
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		int n = scan.nextInt();
		int[] data = new int[n];
		
		for (int i = 0; i < n; i++) {
			data[i] = scan.nextInt();
		}
		scan.close();
		
		Main obj = new Main();
		obj.MergeSort (data, 0, n);
		printArray (data);
		System.out.println(count);
	}
	
	void MergeSort (int[] data, int left, int right) {
		
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			
			MergeSort(data, left, mid);
			MergeSort(data, mid, right);
			
			Merge(data, left, mid, right);
			
		}
	}
	
	void Merge (int[] data, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		final int INFTY = 1000000000;
		
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		
		for (int i = 0; i < n1; i++) {
			L[i] = data[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = data[mid + i];
		}
		
		L[n1] = INFTY;
		R[n2] = INFTY;
		
		int i = 0, j = 0;
		int k = left;
		
		while (true) {
			
			if (i == n1 && j == n2) break;
			
			if (L[i] <= R[j]) {
				data[k] = L[i];
				i++;
			} else {
				data[k] = R[j];
				j++;
			}
			k++;
			count++;
		}
		
	}

	static void printArray (int[] data) {
		int n = data.length;
		for (int i = 0; i < n; i++) {
			if ( i != n - 1) System.out.print(data[i] + " "); 
			else System.out.println(data[i]);
		}
	}
}



Measured memory_bytes: 169668
def d_katana_thrower(N, H, Swords):
    import math
    # 振ったとき最もダメージが大きい刀以上に投げたときのダメージが大きな刀
    # について、ダメージが大きなものから投げていく。そのダメージの総和が
    # 敵の体力より大きければ投げて倒せばいいし、足りなければ刀を降って倒せばいい。
    # ただし、振る刀の投げダメージが振るより高ければ、投げる前に振らなければならないが、
    # 計算時には「投げてから振る」とみなしても問題ない。
    swing_damage_max = max([s[0] for s in Swords])
    throw_higher_than_swing = [s[1] for s in Swords if s[1] >= swing_damage_max]
    throw_higher_than_swing.sort(reverse=True)

    minimum_moving = 0
    for damage in throw_higher_than_swing:
        if H <= 0:  # 刀を投げている途中で敵を倒したら終わり
            H = 0
            break
        H -= damage
        minimum_moving += 1
    minimum_moving += math.ceil(H / swing_damage_max)
    return minimum_moving

N, H = [int(i) for i in input().split()]
Swords = [[int(i) for i in input().split()] for j in range(N)]
print(d_katana_thrower(N, H, Swords))

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    queue<string> q;
    vector<string> numV;
    numV.push_back("3");
    numV.push_back("5");
    numV.push_back("7");
    q.push("357");
    q.push("375");
    q.push("537");
    q.push("573");
    q.push("735");
    q.push("753");
    ll ans = 0;
    map<string, bool> countMap;
    while(!q.empty())
    {
        string s = q.front();
        ll p = stoll(s);
        q.pop();
        if (p <= N) 
        {
            ans++;
            REPV(it, numV)
            {
                REP(i, s.size() + 1)
                {
                    string pushS;
                    if (i == 0)
                    {
                        pushS = *it + s;
                    }
                    else if (i == s.size())
                    {
                        pushS = s + *it;
                    }
                    else
                    {
                        pushS = s.substr(0, i) + *it + s.substr(i, s.size() - 1);
                    }
                    if (countMap.find(pushS) == countMap.end())
                    {
                        countMap[pushS] = true;
                        q.push(pushS);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


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

int	main()
{
  int A, B, C, D;
  
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  
  int L = (A + B);
  int R = (C + D);
  
  if (L > R)
    cout << "Left" << endl;
  
  if (L == R)
    cout << "Balanced" << endl;
  
  if (L < R)
    cout << "Right" << endl;
  
  return (0);
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;

	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

int main() {
	int N;
	cin >> N;
	for (int i = 1; i < 10; ++i) {
		for (int j = 1; j < 10; ++j) {
			if (i * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

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

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26216
import sys
input = sys.stdin.readline

n = int(input())
s = input()

count = 0

ls_si = []
for i in range(n-2):
    # print("i={}".format(i))
    if s[i] in ls_si:
        pass
    else:
        ls_si.append(s[i])
        ls_sj = []
        for j in range(i+1,n-1):
            if s[j] in ls_sj:
                pass
            else:
                ls_sj.append(s[j])
                # ls = s[j+1:-1]
                # st = set(ls)
                # l = len(st)
                # print(ls)
                # print(st)
                # print(l)
                count += len(set(list(s[j+1:-1])))

# print(ls_si)
# print(ls_sj)
print(count)

Measured memory_bytes: 73080
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int ans = S.Length;
        for (int i = 0; i < 26; i++)
        {
            char c = (char)('a' + i);

            int tmp = 0;
            int cnt = 0;
            for (int j = 0; j < S.Length; j++)
            {
                if (S[j] == c)
                {
                    tmp = Math.Max(tmp, cnt);
                    cnt = 0;
                }
                else cnt++;
            }
            tmp = Math.Max(tmp, cnt);
            ans = Math.Min(tmp, ans);
        }
        Console.WriteLine(ans);
    }
    


}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>

int main(void){
    int a, b, c;

    scanf("%d",&a);

    if(a%2 == 0){

        a = a/2;
    }
    else{
        a = a/2 +1;
    }
    
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 1005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,m,ans;
bool vis[M];
int main()
{
	int x,y;
	RI(n,m);
	ans = n+1;
	REP(i,1,m)
	{
		RI(x,y);
		REP(j,x,y-1) if(!vis[j])
		{
			vis[j] = true;
			ans += 2;
		}
	}
	printf("%d\n", ans);

	return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(3*n);
	rep(i, 3*n) cin >>a[i];
	
	priority_queue<ll, vector<ll>, greater<ll> > pl;
	priority_queue<ll> pr;
	
	ll sml=0, smr=0;
	VL lf(3*n), rg(3*n);
	rep(i, 3*n){
		sml += a[i];
		pl.push(a[i]);
		if(sz(pl) >n){ sml -=pl.top(); pl.pop();}
		lf[i] = sml;
	}
	repr(i, 3*n-1, 0){
		smr += a[i];
		pr.push(a[i]);
		if(sz(pr) >n){ smr -=pr.top(); pr.pop();}
		rg[i] = smr;
	}

	ll ans = -1LL<<60;
	rep2(i, n-1, 2*n) ans = max(ans, lf[i] - rg[i+1]);
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


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

  int h, w, k;
  cin >> h >> w >> k;

  vector<string> c(h);
  rep(i, h) cin >> c[i];

  int ans = 0;
  for(int bit = 0; bit < (1<<(h+w)); bit++){

    int cnt = 0;
    rep(i, h){
      rep(j, w){
        if(c[i][j] == '#' && (bit & (1<<i)) && (bit & (1 <<(h+j)))){
          cnt++;
        }
      }
    }
    if(cnt == k) ans++;

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	int N, K;
	string S;
	cin >> N >> S >> K;
	for (int i = 0; i < N; i++) {
		if (S[i] != S[K - 1])S[i] = '*';
	}
	cout << S << endl;
}


Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
    ll n,m;cin>>n>>m;cout<<(n==m ? "Yes" : "No");
return 0;
}


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

int gcd(int a, int b){
  int res = 0;
  for (int i = 1; i <= b; i++){
    if(a%i == 0 && b%i == 0){
      res = i;
    }
  }
  return res;
}

int gcd_2(int a, int b, int c){
  int res = 0;
  for (int i = 1; i<= c; i++){
    if(a%i == 0 && b%i == 0 && c%i == 0){
      res = i;
    }
  }
  return res;
}

int main() {
  int k;
  long long s = 0;
  cin >> k;
  for (int i = 1; i <= k; i++){
    for (int j = i; j <= k; j++){
      for (int l = j; l <= k; l++){
	if (i == j && j == l){
	  s += i;
	}else if (i == j){
	  s += gcd(i,l) * 3;
	}else if (i == l){
	  s += gcd(i,j) * 3;
	}else if (j == l){
	  s += gcd(i,j) * 3;
	}else {
	  s += gcd_2(i,j,l)*6;
	}
      }
    }
  }
  cout << s << endl;
  return 0;

}


Measured memory_bytes: 3624
s = input()
n = len(s)

ans = 0
for bit in range(2**(n-1)):
    tmp_total = 0
    tmp = s[0] #文字列
    for i in range(n-1):
        if (1<<i) & bit: #プラスがある時
            tmp_total += int(tmp)
            tmp = s[i+1]
        else:
            tmp += s[i+1] #tmpは文字列
    tmp_total += int(tmp)
    ans += tmp_total
print(ans)


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

using namespace std;

int main()
{
	string str1,str2[10];
	int n,a,i,j;
	
	str2[0]="0111111";
	str2[1]="0000110";
	str2[2]="1011011";
	str2[3]="1001111";
	str2[4]="1100110";
	str2[5]="1101101";
	str2[6]="1111101";
	str2[7]="0100111";
	str2[8]="1111111";
	str2[9]="1101111";
	
	for(;;)
	{
		cin >> n;
		if(n==-1)
			break;
		
		str1="0000000";
		for(i=0;i<n;i++)
		{
			cin >> a;
			for(j=0;j<7;j++)
			{
				if(str1[j]==str2[a][j])
					str1[j]='0';
				else
					str1[j]='1';
			}
			cout << str1 << endl;
			str1=str2[a];
		}
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	boolean flag;
	char[] a;
	int pos;
	
	void cat(){
		if(pos<a.length && a[pos]=='m') pos++;
		else flag = false;
		if(flag==false) return;
		
		if(pos<a.length && a[pos]=='m') cat();
		if(pos<a.length && a[pos]=='e') pos++;
		else flag = false;
		if(flag==false) return;
		
		if(pos<a.length && a[pos]=='m') cat();
		if(pos<a.length && a[pos]=='w') pos++;
		else flag = false;
		if(flag==false) return;
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			a = sc.next().toCharArray();
			if(a.length%3!=0){
				System.out.println("Rabbit");
			}else{
				flag = true;
				pos = 0;
				cat();
				if(flag==true && pos==a.length) System.out.println("Cat");
				else System.out.println("Rabbit");
			}
		}		
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 17316
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

const ll mn = 1000003;
ll h, w, v, t, x, y, p, q;
ll md;
ll dist(ll a, ll b) {
	ll dx = a - x;
	ll dy = b - y;
	ll ret = dx * dx + dy * dy;
	return ret;
}
ll calc(ll i, ll cp, ll cq) {
	ll ret = 0;
	ll le = 0, ri = mn;
	while (ri - le > 1) {
		ll mid = (le + ri) / 2;
		ll np = cp + mid * (2*h);
		ll nq = cq + i * (2*w);
		ll d = dist(np, nq);
		if (d <= md&&abs(np)<2*mn&&abs(nq)<2 * mn) {
			le = mid;
		}
		else {
			ri = mid;
		}
	}
	ret += le;
	le = -mn, ri = 0;
	while (ri - le > 1) {
		ll mid = (le + ri) / 2;
		ll np = cp + mid * (2 * h);
		ll nq = cq + i * (2 * w);
		ll d = dist(np, nq);
		if (d <= md&&abs(np)<2*mn&&abs(nq)<2*mn) {
			ri = mid;
		}
		else {
			le = mid;
		}
	}
	ret += -ri;
	ll d = dist(cp, cq + i * (2 * w));
	if (d <= md && abs(cp)<2 * mn&&abs(cq+i*(2*w))<2 * mn)ret++;
	/*if (ret > 0) {
		cout << ret << " " << i << " " << cp << " " << cq << endl;
	}*/
	return ret;
}
void solve() {
	cin >> h >> w >> v >> t >> x >> y >> p >> q;
	md = v * v*t*t;
	ll ans = 0;
	for (ll i = -mn; i <= mn; i++) {
		ans += calc(i, p, q);
		if(p>0)ans += calc(i, 2*h-p, q);
		if(q>0)ans += calc(i, p, 2 * w - q);
		if(p>0&&q>0)ans += calc(i, 2 * h - p, w * 2 - q);
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//while (cin >> n>>h>>m>>s,n)solve();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3156
package main

import (
	"io"
	"os"
	"strconv"
)

const mod = 1e9 + 7

func main() {
	b := [26 + 'a']int{}
	buf := make([]byte, 1)
	var err error
	for err != io.EOF {
		_, err = os.Stdin.Read(buf)
		if buf[0] < 'a' || buf[0] > 'z' {
			continue
		}
		b[buf[0]]++
	}

	r := 1
	for i := 'a'; i < 26+'a'; i++ {
		r = r * (b[i] + 1) % mod
	}
	os.Stdout.Write([]byte(strconv.Itoa(r-1) + "\n"))
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  int ans = 0;
  cin >> S;
  auto check = [](char c) {
    return (c == 'A') || (c == 'T') || (c == 'G') || (c == 'C');
  };
  for (int i = 0; i < (int)S.length(); i++) {
    int j = i;
    while (check(S[j])) j++;
    ans = max(ans, j - i);
    i = j;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int N;
int pT, pX, pY, T, X, Y;
bool ans = true;
int main(void) {
	cin >> N;
	for (int n = 0; n < N; ++n) {
		cin >> T >> X >> Y;
		int dt = T - pT;
		int dx = abs(X - pX);
		int dy = abs(Y - pY);
		bool no = (dt < (dx + dy)) || ((dt % 2) != ((dx + dy) % 2));
		if (no) {
			ans = false;
			break;
		}
		pT = T;
		pX = X;
		pY = Y;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int(),stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
n=int(I())
a=LI()
sum=0
for i in range(len(a)):
    sum+=a[i]
norm=0
for i in range(len(a)):
    norm+=a[i]**2
print(((sum**2-norm)//2)%(10**9+7))

Measured memory_bytes: 31368
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	string s;
	cin>>s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 764
//abc162B
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int k, i, j, m, a, b, c, r, tmp;
  long long sum=0;
  scanf(" %d", &k);

  for(i=1; i <= k; i++){
    for(j=1; j <= k; j++){
      for(m=1; m <= k; m++){

        a=i, b=j, c=m;
        //printf("  %d %d %d    %d\n",a,b,c,b);
        if(a < b) tmp=a, a=b, b=tmp;

        r=a % b;/* ユークリッドの互除法 */
        while(r != 0)
          a=b, b=r, r=a % b;


        if(c < b) tmp=c, c=b, b=tmp;

        r=c % b;/* ユークリッドの互除法 */
        while(r != 0)
          c=b, b=r, r=c % b;

        sum+=b;
        //printf("%d %d %d    %d\n",a,b,c,b);
      }
    }
  }
printf("%lld\n",sum);
}

Measured memory_bytes: 1732
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
	int N,R;
	cin >> N >> R;
	if(N >= 10){
		cout << R << "\n";
	}else{
		int K = R + (10 - N)*100;
		cout << K << "\n";
	}
	return 0;
}

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

int main(){

	int a=0;
	int b=0;

	for(int count=0;count<81;count++)
	{
		a++;
		if(0==a%10){a=1;}

		if(a==1)
		{
			b++;
			if(0==b%10){b=1;}
		}
	cout<<b<<"x"<<a<<"="<<a*b<<endl;
	}
    return 0;
}

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

using namespace std;
typedef long long ll;

ll md = 1e9+7;
vector < vector < ll > > mul(vector < vector < ll > > v1, vector <vector < ll > > v2)
{
    vector < vector < ll >> v(v1.size() , vector < ll> (v1[0].size()));
    for (int i = 0; i < v1.size() ; ++i)
        for (int j = 0 ; j < v1[0].size() ; ++j)
        {
            v[i][j] = 0;
            for (int k = 0 ; k < v1[0].size() ; ++k)
                v[i][j] += (v1[i][k] * v2[k][j])%md,
                v[i][j] %= md;
        }
    return v;
}
vector < vector < ll > > po(vector < vector < ll > > b, ll p)
{
    if (p == 1) return b;
    if (p & 1) return mul(b, po(mul(b, b), p/2));
    return po(mul(b, b), p/2);
}

int main()
{
    int n;
    ll k;
    scanf("%d%lld", &n, &k);
    vector < vector < ll > > v (n, vector < ll>(n));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            scanf("%lld", &v[i][j]);
    auto it = po(v, k);
    ll ans = 0;
    for (auto u : it)
        for (auto v : u)
        {
            ans += v;
            if (ans >= md)
                ans -= md;
        }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4096
import math                                                       
A, B, N = map(int, input().split())

# A, B, N = 11, 10, 9
T = N//B
maxR = -1
maxT = 0
# for x in range(1, T+2):
    # t = min(x*B-1,N)
    # R = math.floor(A*t/B) - A * math.floor(t/B)
    # if R >= maxR:
    #     maxR = R
    #     maxT = t
t = min(B-1,N)
maxR = math.floor(A*t/B) - A * math.floor(t/B)
print (maxR)

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

int main(){
    int x;
    cin>>x;
    ll ans=0;
    ans+=x/500*1000;
    x%=500;
    ans+=x/5*5;
    cout<<ans<<endl;
}

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

int main () {
  int N ;
  cin >> N ;
  int t[110000] , x[110000] , y[110000] ;
  t[0] = x[0] = y[0] = 0 ;
  
  bool can = true ;
  
  for(int i = 0 ; i < N ; i++ ){
    cin >> t[i+1] >> x[i+1] >> y[i+1] ;
  }
  for(int i = 0 ; i < N ; i++ ){
    int dt = t[i+1] - t[i] ;
    int dl = abs( x[i+1] - x[i] ) +  abs( y[i+1] - y[i] ) ;
    if( dl > dt ) can = false ;
    if( dt % 2 != dl % 2 ) can = false ;
  }
  if(can) cout << "Yes" << endl ;
  else cout << "No" << endl ;
  
  
}

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

int main() {
    int N, K;
	string S;
    cin >> N >> K;
  	cin >> S;
    for (int i = 0; i < N; i++) {
        if (i == K - 1) S[i] = S[i] + 0x20;
    }
    cout << S << endl;
}

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

int main() {
	int N,diff;
	cin >> N;
	diff = 0;
	vector<int> v(N);
	//cin.ignore();
	for (int i = 0; i < N; i++) {
		cin >> v.at(i);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i < N; i+=2) {
		if (i + 1 < N) {
			diff += v.at(i) - v.at(i + 1);
		}
		else {
			diff += v.at(i);
		}
	}
	cout << diff << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main()
{
	char S[100001];
	int ans = 0;
	std::cin >> S;
	
	int len = strlen(S);
	
	for(int i = 1; i < len; i++)
	{
		if(S[i-1] != S[i])
		{
			++ans;
		}
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}


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

int main() {
  lint x, y;
  cin >> x >> y;
  lint cnt = 1ll;
  while (true) {
    x *= 2;
    cnt++;
    if (x > y) break;
  }
  cout << cnt - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>

int main() {
	int n, t; std::cin >> n >> t;
	std::vector<int> health(n); for (auto& h : health) std::cin >> h;
	std::vector<int> first_end_time(n, 0), last_end_time(n, 0), last_check(n, 0), step_time{ health };
	last_check[0] = t / health[0] + 1; first_end_time[0] = t >= health[0] ? health[0] : 0; last_end_time[0] = t / health[0] * health[0];
	for (auto i = 1; i < n; ++i) {
		step_time[i] = std::max(step_time[i], step_time[i - 1]);
		if (step_time[i] > step_time[i - 1]) {
			last_check[i] = (t - first_end_time[i - 1]) / step_time[i] + 1;
			last_end_time[i] = (t - first_end_time[i - 1]) / step_time[i] * step_time[i] + first_end_time[i - 1];
		}
		else {
			last_check[i] = t >= last_end_time[i - 1] + health[i] ? last_check[i - 1] : std::max(1, last_check[i - 1] - 1);
			last_end_time[i] = t >= last_end_time[i - 1] + health[i] ? last_end_time[i - 1] + health[i] : last_end_time[i - 1] + health[i] - step_time[i];
		}
		first_end_time[i] = std::min(t, first_end_time[i - 1] + health[i]);
	}
	for (const auto c : last_check) {
		std::cout << c << '\n';
	}
}


Measured memory_bytes: 4704
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


void preorder(int i, vector<vector<int>> chi) {
	if (i == -1) return;
	cout << " " << i;
	preorder(chi[i][0], chi);
	preorder(chi[i][1], chi);
}

void inorder(int i, vector<vector<int>> chi) {
	if (i == -1) return;
	inorder(chi[i][0], chi);
	cout << " " << i;
	inorder(chi[i][1], chi);
}

void postorder(int i, vector<vector<int>> chi) {
	if (i == -1) return;
	postorder(chi[i][0], chi);
	postorder(chi[i][1], chi);
	cout << " " << i;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<vector<int>> chi(n, vector<int>(2)); // 子
	vector<int> par(n, -1); // 親
	
	

	REP(i, n) {
		int node;
		cin >> node;
		REP(k, 2) {
			cin >> chi[node][k];
		}
		if (chi[node][0] != -1) {
			par[chi[node][0]] = node;
		}
		if (chi[node][1] != -1) {
			par[chi[node][1]] = node;
		}
	}
	
	int x = 0;
	while (par[x] != -1) {
		x = par[x];
	}
	
	cout << "Preorder\n";
	preorder(x, chi);
	cout << "\nInorder\n";
	inorder(x, chi);
	cout << "\nPostorder\n";
	postorder(x, chi);
	cout << "\n";

	return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            string s;
            cin >> s;
            cout << s << "\n";
            cout << s << "\n";
        }
    }
}

Measured memory_bytes: 256
int main(){
  int n;
  scanf("%d", &n);
  int a=n/27, b=n%27;
  if(b==13||b==26){
    puts(":(");
  }else if(b<=12){
    printf("%d\n", a*25+b);
  }else{
    printf("%d\n", a*25+b-1);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  long long N, M, K;
  cin >> N >> M >> K;
  vector<long long> A(N + 1), B(M);
  rep(i, N)
  {
    cin >> A[i + 1];
  }
  rep(i, M)
  {
    cin >> B[i];
  }
  rep(i, N)
  {
    A[i + 1] += A[i];
  }
  rep(i, M - 1)
  {
    B[i + 1] += B[i];
  }
  long long ans = 0;
  rep(i, N + 1)
  {
    long long restK = K - A[i];
    if (restK >= 0)
    {
      long long B_num;
      auto it = upper_bound(B.begin(), B.end(), restK);
      if (it == B.end())
        B_num = M;
      else if (B[0] > restK)
        B_num = 0;
      else
        B_num = it - B.begin();
      long long score = B_num + i;
      ans = max(ans, score);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6400
N = int(input())

A = [int(n) for n in input().rstrip().split(' ')]
B = [int(n) for n in input().rstrip().split(' ')]
C = [int(n) for n in input().rstrip().split(' ')]

next_a = 0

sum_cnt = 0

for i in range(len(A)):
  now = A[i] -1
  sum_cnt += B[now]
  
  if i < len(A)-1:
    next = A[i+1] -1
    if now + 1 == next:
      sum_cnt += C[now]

print(sum_cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;  cin>>N;
    int A[N];  for(int i=0; i<N; i++)cin>>A[i];
    int B[N];  for(int i=0; i<N; i++)cin>>B[i];
    int C[N];  for(int i=0; i<N; i++)cin>>C[i];
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);

    long long ans=0;
    for(int i=0; i<N; i++){
        ans += ( lower_bound(A,A+N, B[i]) - A ) * ( C+N - upper_bound(C,C+N, B[i]) );
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
	int a,s,d,t;

	scanf("%d %d %d", &a, &s, &d);
	
	if(a > s)
	{
		t = s;
		s = a;
		a = t;
	}
	if(s > d)
	{
		t = d;
		d = s;
		s = t;
	}
	if(a > s)
	{
		t = s;
		s = a;
		a = t;
	}

	printf("%d %d %d\n", a, s, d);

	return 0;
}

Measured memory_bytes: 596