akhauriyash/Code-Regression huggingface dataset:
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
vector<set<int>>adj;
vector<bool>visited;
int ans,cnt;
void dfs(int v)
{
    visited[v]=true;
    cnt++;
    for(auto it:adj[v])
    {
        if(visited[it]==false)dfs(it);
    }
}
void solve()
{
  int n,m,i,a,b;cin>>n>>m;
  adj=vector<set<int>>(n);
  visited=vector<bool>(n,false);
  fo(i,0,m)
  {
      cin>>a>>b;a--;b--;
      adj[a].insert(b);adj[b].insert(a);
  }
  
  fo(i,0,n)
  {
      if(visited[i]==false)
      {
          cnt=0;
          dfs(i);
          ans=max(ans,cnt);
      }
  }
  cout<<ans<<"\n";
  
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 37420
N=int(input())
x=[]
y=[]
h=[]
for _ in range(N):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
k=0
for i in range(N):
    if h[i]!=0:
        k=i
        break
for cx in range(101):
    for cy in range(101):
        H=h[k]+abs(x[k]-cx)+abs(y[k]-cy)
        for i in range(N):
            if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
                break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break


Measured memory_bytes: 9184
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, m = Is()
li = [[0]*2 for _ in range(n)]
for _ in range(m):
    p_, s = Ss()
    p = int(p_) - 1
    if s == "AC":
        li[p][0] = 1
    elif s == "WA" and li[p][0] == 0:
        li[p][1] += 1

ac = 0
wa = 0
for i in range(n):
    ac += li[i][0]
    wa += li[i][1] if li[i][0] == 1 else 0

print("{} {}".format(ac, wa))


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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  
  int x, y, a;
  int wmin=0, wmax=w, hmin=0, hmax=h;
  for(int i=0; i<n; i++) {
    cin >> x >> y >> a;
    if(a==1 && x>wmin) wmin = x; 
    else if(a==2 && x<wmax) wmax = x;
    else if(a==3 && y>hmin) hmin = y;
    else if(a==4 && y<hmax) hmax = y;
  }
  int ans = (wmax-wmin)*(hmax-hmin);
  if(wmax-wmin>0 && hmax-hmin>0) cout << ans << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3604
s = input()
l = list(s)
l = [int(x) for x in l]
dp = [[0, 0] for i in range(len(s))]
dp[0][0] = l[0]
dp[0][1] = 11 - l[0]
for i in range(1, len(s)):
  dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + l[i]
  dp[i][1] = min(dp[i - 1][0] + 11 - l[i], dp[i - 1][1] + 9 - l[i])
print(min(dp[-1][0], dp[-1][1]))


Measured memory_bytes: 185124
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a>b) { return a; }return b; }
int Min(int a, int b) { if (a<b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	char N[4];
	char ans[4];
	scanf("%s", &N);
	for (int i = 0; i < 4; i++) {
		if (N[i] == '1') {
			printf("%c",'9');
		}
		else if(N[i] == '9'){
			printf("%c", '1');
		}
	}
	printf("\n");

#ifdef DEBUGF
	getch();
#endif
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
std::string s[55],t[55];
bool done[55][22][2];
ll memo[55][22][2],c[55];

ll solve(int x, int p, int rev){
	int i,l,r;
	bool flag;
	if(done[x][p][rev]){
		return memo[x][p][rev];
	}
	done[x][p][rev] = true;
	memo[x][p][rev] = INFLL;
	// 回文判定
	flag = true;
	l = p; r = s[x].l_ength()-1;
	while(l<r){
		if(rev){
			if(t[x][l]!=t[x][r]){
				flag = false;
				break;
			}
		}else{
			if(s[x][l]!=s[x][r]){
				flag = false;
				break;
			}
		}
		++l; --r;
	}
	if(flag){
		return memo[x][p][rev] = 0ll;
	}
	for(i=0; i<n; ++i){
		if(rev){
			l = 0; r = p;
			flag = true;
			while(l<s[i].l_ength() && r<t[x].l_ength()){
				if(s[i][l] != t[x][r]){
					flag = false;
					break;
				}
				++l; ++r;
			}
			if(l == s[i].l_ength()){
				memo[x][p][rev] = std::min(memo[x][p][rev],solve(x,r,1)+c[i]);
			}else if(r == x[t].l_ength()){
				memo[x][p][rev] = std::min(memo[x][p][rev],solve(i,l,0)+c[i]);
			}
		}else{
			l = p; r = 0;
			flag = true;
			while(l<s[x].l_ength() && r<t[i].l_ength()){
				if(s[x][l] != t[i][r]){
					flag = false;
					break;
				}
				++l; ++r;
			}
			if(l == s[x].l_ength()){
				memo[x][p][rev] = std::min(memo[x][p][rev],solve(i,r,1)+c[i]);
			}else if(r == t[i].l_ength()){
				memo[x][p][rev] = std::min(memo[x][p][rev],solve(x,l,0)+c[i]);
			}
		}
	}
	return memo[x][p][rev];
}

int main(void){
	int i;
	ll ans = INFLL;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> s[i] >> c[i];
		t[i] = s[i];
		std::reverse(t[i].begin(),t[i].end());
	}
	for(i=0; i<n; ++i){
		ans = std::min(ans,solve(i,0,0)+c[i]);
	}
	std::cout << ((ans<INFLL)?ans:(-1ll)) << std::endl;
	return 0;
}


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

public class Main {

	public static void main(String[] args) {

		int array[] = null;
		int temp = 0;

		Scanner scanner = new Scanner(System.in);

		//入力値を扱いやすいように配列化
		for(int i = 0; scanner.hasNext(); i++) {

			//最初の入力で配列作成
			if(i == 0) {

				temp = Integer.parseInt(scanner.next());

				array = new int[temp];

			}
			
			array[i] = Integer.parseInt(scanner.next());
			
		}

		//照準ソート
		Arrays.sort(array);

		//間の値の差を求める
		System.out.println((array[(temp / 2)] - array[((temp / 2) -1)]));
		
	}

}

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

int main() {
    int k;
    char s[101];
    scanf("%d %s", &k, s);
    int len = strlen(s);
    if (len <= k) printf("%s\n", s);
    else {
        for (int i = 0; i < k; i++) printf("%c", s[i]);
        printf("...");
    }
    return 0;
}


Measured memory_bytes: 1708
import heapq

n,m,s,t = map(int, input().split())
L = [[int(x) for x in input().split()] for _ in range(m)]

cost = [[] for _ in range(n)]
for i in range(m):
    cost[L[i][0]-1].append((L[i][2], L[i][3], L[i][1]-1))
    cost[L[i][1]-1].append((L[i][2], L[i][3], L[i][0]-1))
    
def dijkstra(s, n, cost, c):
    g = 10**6
    d = [10**15]*n
    used = [0]*n
    d[s] = 0
    used[s] = 1
    edgelist = []
    for e in cost[s]:
        heapq.heappush(edgelist, e[c]*g+e[2])
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if used[minedge%g] == 1:
            continue
        v = minedge%g
        d[v] = minedge//g
        used[v] = 1
        for e in cost[v]:
            if used[e[2]] == 0:
                heapq.heappush(edgelist, (e[c]+d[v])*g + e[2])
    return d

jpy = dijkstra(s-1, n, cost, 0)
snuuk = dijkstra(t-1, n, cost, 1)
ans_list = [0]*n
ans_list[n-1] = jpy[n-1]+snuuk[n-1]
for i in range(n-2, -1, -1):
    ans_list[i] = min(ans_list[i+1], jpy[i]+snuuk[i])
    
for i in range(n):
    print(10**15-ans_list[i])

Measured memory_bytes: 127244
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
	string N;
	cin >> N;
	for(int i=0;i<3;i++){
		if(N[i]=='1'){
			cout <<9;
		}else{
			cout <<1;
		}
	}
	cout<< endl;
}

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

using namespace std;

int main(void) {
    int N;
    string S;
    cin >> N >> S;
    if(S.substr(0, N/2) == S.substr(N/2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 300005
#define INF 1000000005LL
#define MOD 1000000007

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

int N;
ll A[SIZE];
P m1[SIZE],m2[SIZE];

void update(int S,P v){
  if(v == m1[S] || v == m2[S])return;
  if(v.first > m1[S].first){
    m2[S] = m1[S];
    m1[S] = v;
  }else if(m2[S].first < v.first && v.first <= m1[S].first){
    m2[S] = v;
  }
}

ll f(int S){
  return m1[S].first + m2[S].first;
}

int main(){
  cin >> N;
  rep(i,0,1<<N){
    cin >> A[i];
  }

  m1[0] = P(A[0],0);

  rep(S,0,1<<N){
    rep(i,0,N) if(S>>i & 1){
      int T = S & ~(1<<i);
      update(S,m1[T]);
      update(S,m2[T]);
      update(S,P(A[S],S));
    }
  }

  rep(K,1,1<<N){
    ll ans = f(K);
    rep(i,0,N) if(K>>i & 1){
      int T = (K & ~(1<<i)) | ((1<<i)-1);
      ans = max(ans,f(T));
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 14464
// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
const int MAX = 100 * 1000 + 47;

int X[MAX];

VI mult(VI &A, VI &B)
{
    VI res(SZ(A));
    FOR(i, 0, SZ(A))
        res[i] = B[A[i]];
    return res;
};


VI BP(VI& P, LL n)
{
    VI res;
    FOR(i, 0, SZ(P))res.PB(i);
    while(n)
    {
        if (n & 1)res = mult(res, P);
        P = mult(P, P);
        n >>= 1;
    }
    return res;
}

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)scanf("%d", X + i);
    int m;
    LL k;
    scanf("%d%lld", &m, &k);
    VI P;
    FOR(i, 0, n-1)
        P.PB(i);
    FOR(i, 0, m)
    {
        int x;
        scanf("%d", &x);
        --x;
        swap(P[x], P[x-1]);
    }
    //cout << m << endl << endl;
    P = BP(P, k);
    LL cur = X[0];
    FOR(i, 0, n)
    {
        printf("%lld\n", cur);
        if (i < SZ(P))cur += X[P[i] + 1] - X[P[i]];
    }
}



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

int main(){
  string S;
  cin>>S;
  char x;
  bool flag=0;
  for (x='a';x<='z';x++){
    for(int i=0;i<S.length();i++){
      if(x==S.at(i)){
        flag=1;
      }
    }
    //cout<<x<<"#"<<endl;
    if(flag){
      flag=0;
      continue;
    }
    cout<<x<<endl;
    return 0;
  }
  cout<<"None"<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
int main()
{
	int a,b,c,n,s,num;
	cin>>a>>b>>c>>n;
//	num=s=min(a,n);
//	if(n!=num)
//	{
//		
//	}
	if(n<=a)cout<<n;
	else if(n<=a+b)cout<<a;
	else cout<<a-(n-a-b);
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	int s=0;
	rep(i,0,n){
		cin>>a[i];
		s+=a[i];
	}	
	sort(a,a+n);
	int k=ceil((s*1.0)/(4*m));
	int pos=lbnd(a,a+n,k)-a;
	if(n-pos>=m)
		cout<<"Yes";
	else
		cout<<"No";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
using namespace std;
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    int ans = (b / k) - (a - 1) / k;
    if(ans > 0)
       cout << "OK";
    else
     cout << "NG";
    
    
}

Measured memory_bytes: 3644
n = int(input())
b = list(map(int,input().split()))

ans = [0 for i in range(n)]

ans[0] = b[0]
ans[n-1] = b[n-2]
for i in range(1,n-1):
    ans[i] = min(b[i-1],b[i])
    
print(sum(ans))

Measured memory_bytes: 3064
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 

struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
int tests(){    
    int D,T,S;
    cin >> D >> T >> S;
    if(S*T >= D)
        return cout << "Yes\n",0;
    cout << "No\n";
    return 0;
}
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            (int H, int W) = Slice2<int>();
            WriteLine(new string('#', W + 2));
            for (var i = 0; i < H; ++i)
                WriteLine('#' + ReadLine() + '#');
            WriteLine(new string('#', W + 2));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27400
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
typedef long long ll;

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

    int n;
    cin >> n;
    ll a[n+1], b[n];
    rep (i, n + 1) {
        cin >> a[i];
    }
    rep (i, n) {
        cin >> b[i];
    }
    ll res = 0;
    rep (i, n) {
        if (a[i] < b[i]) {
            res += a[i];
            b[i] -= a[i];
            if (a[i + 1] < b[i]) {
                res += a[i+1];
                a[i+1] = 0;
            } else {
                res += b[i];
                a[i + 1] -= b[i];
            }
        } else {
            res += b[i];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 5204
#include<stdio.h>

int main(void){
 	
  char line[4];
  
  scanf("%s",line);
  
  if(line[0] == line[1] && line[1] == line[2]){
   	printf("No"); 
  }else{
   	printf("Yes"); 
  }
  
  return 0;
}

Measured memory_bytes: 128
n=input()
op_cnt=len(n)-1
for i in range(2**op_cnt):
  op=["-"]*op_cnt
  for j in range(op_cnt):
    if ((i>>j)&1):
      op[j]="+"
  formula=""
  for p_n, p_o in zip(n, op + [""]): 
      formula += (p_n + p_o)
  if eval(formula) == 7:
      print(formula + "=7")
      break


Measured memory_bytes: 61924
nstr = gets
n = nstr.to_i

out = 0
base = 0b00
point = 0
inning = 0

while inning < n do
	event = gets

	case event
	when /OUT.*/
		out += 1
	when /HOMERUN.*/
		point += 1
		point += 1 if base[0] == 1
		point += 1 if base[1] == 1
		point += 1 if base[2] == 1
		base = 0b00
	when /HIT.*/
		base = base << 1
		if base[3] == 1 then
			point += 1
			base -= 0b1000
		end
		base += 0b01
	else
		print("undefined event: ", event, "\n")
	end

	if out == 3 then
		print(point, "\n")
		out = 0
		point = 0
		base = 0
		inning += 1
	end
end

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

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


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

  ll sum = 0;
  for(auto n : N) {
    sum += n - '0';
  }

  cerr << sum%9 << endl;
  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3744
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll k;
    cin >> k;
    cout << 50 << endl;
    ll v,w;
    if(k%50==0){
        v=k/50;
        w=0;
    }
    else{
        v=(k-1)/50+1;
        w=50-k%50;
    }
    vector<ll> a(50);
    rep(i,50){
        a[i]=49+v;
    }
    rep(i,w){
        sort(a.rbegin(),a.rend());
        rep(j,50){
            if(j==0) a[j]-=50;
            else a[j]++;
        }
    }
    rep(i,50){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
} 


Measured memory_bytes: 3588
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

t = 0
ans = 0
if sum(a) == x:
    print(n)
else:
    for i in range(n):
        if t + a[i] <= x:
            t += a[i]
            ans += 1
        else:
            break

    if ans == n:
        print(n-1)
    else:
        print(ans)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.awt.Point;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int h = sc.nextInt();
			int w = sc.nextInt();
			int d = sc.nextInt();
			Point[] map = new Point[h * w + 1];
			for (int y = 0; y < h; y++) {
				for (int x = 0; x < w; x++) {
					int a = sc.nextInt();
					map[a] = new Point(x, y);
				}
			}

			long[] mps = new long[h * w + 1];
			for (int i = 0; i < d; i++) {
				long tmp = 0;
				for (int j = h * w - d - i; j > 0; j -= d) {
					tmp += mp(map[j], map[j + d]);
					mps[j] = tmp;
				}
			}

			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int l = sc.nextInt();
				int r = sc.nextInt();
				out.println(mps[l] - mps[r]);
			}

		}

		long mp(Point p1, Point p2) {
			return Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);
		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

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

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

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

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

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

	}
}



Measured memory_bytes: 35700
#include <iostream>

using namespace std;

int main() {
	int a, b, c,r,i;
	cin >> a >> b >> c;
	r = a%b;
	for (i = 0; i < 100; i++) {
		if (r*i%b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    nvertices, nedges, s = map(int, input().split())
    E = []
    for i in range(nedges):
        u, v, w = map(int, input().split())
        E.append((u, v, w))

    INF = 1000000000
    d = [INF] * nvertices
    d[s] = 0
    for i in range(nvertices - 1):
        for u, v, w in E:
            if d[u] == INF:
                continue
            if d[u] + w < d[v]:
                d[v] = d[u] + w

    for i in range(nvertices - 1):
        for u, v, w in E:
            if d[v] == INF:
                continue
            if d[v] > d[u] + w:
                print("NEGATIVE CYCLE")
                return

    for val in d:
        if val >= INF:
            print("INF")
        else:
            print(val)


main()

Measured memory_bytes: 8136
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

constexpr int MOD = 1000000007;

int main(){
    Stream io;

    ll N;
    io.read(N);
    ll ans = 1;
    for(int i = 1; i <= N; i++){
        ans *= i;
        ans %= MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readIntegerList()
    val isAcArray = Array(n + 1) { false }
    val waCountArray = Array(n + 1) { 0 }
    for (i in 0 until m) {
        val (p, s) = readStringList()
        val pNum = p.toInt()

        if (isAcArray[pNum]) {
            continue
        }

        if (s == "AC") {
            isAcArray[pNum] = true
        } else {
            waCountArray[pNum]++
        }
    }

    var acCount = 0
    var waCount = 0
    for (i in isAcArray.indices) {
        if (isAcArray[i]) {
            acCount++
            waCount += waCountArray[i]
        }
    }

    println("$acCount $waCount")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 58004
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

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

/* TEMPLATE ENDS HERE */

#define MAXN (1 << 10)

int n;
int a[MAXN], b[MAXN], c[MAXN];

int main() {
	cout << fixed << setprecision(12);	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i]; 
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
	}
	int ret = 0;
	for (int i = 1; i <= n; i++) {
		ret += b[a[i]];
		if ((a[i + 1] == a[i] + 1) && i < n) {
			ret += c[a[i]];
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    bool vis[200000];
    vector<ll> v[200000];
    ll p[200000 + 1], w[200000 + 1];
    
    
    int main() {
      ios::sync_with_stdio(0);
      ll a1, b, c, ans, n, m, t1, t2, t3, t, i, j, k, temp = 0, t4;
      //cin >> t;
      t=1;
      while (t--) {
        cin>>n;
        ans=INT_MAX;
        //map<ll,ll>m;
        //priority_queue<pair<ll,ll>>pq;
        ll a[n+1],b[n+1];
        string s;cin>>s;
        t1=0;t2=0;
        for (i = 0; i < n; i++)
        {
            if(s[i]=='#'){t1++;}
            a[i] = t1;
            
        }
        for (i = n-1; i >=0; i--)
        {
            if(s[i]=='.'){t2++;}
            b[i] = t2;
            //cout<<b[i];
        }b[n]=0;
        for (i = 0; i < n; i++)
        {
            ans = min(ans, a[i]+b[i+1]);
        }
        //ans = min(ans,)
        if(a[n-1]==n)ans=0;
        ans = min(ans, b[0]);
        cout<<ans;
    }
    
        
    return 0;
    }


Measured memory_bytes: 9492
/*
ID: lit20182
TASK: beads
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define int ll


ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*_____________________________________________________________________________________________________*/




        vector<ll> arr[11], ans;
        set<ll> v;
signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
    next :
	while(t--){
        int n, m;
        cin >> n;
        rep(i, 0, 10)arr[0].pb(i);
        rep(i, 0, 9){

            for(auto j : arr[i]){
                v.insert(j);
                // cout << j << endl;
                int x = j/(power(10, i));
                int z = x+1;
                if(z == 10)z--;
                while(z >= 0 and abs(x-z) <= 1){
                    arr[i+1].pb(j+z*power(10, i+1));
                    z--;
                }
            }
        }
        for(auto i : arr[9]){
            v.insert(i);
        }
        for(auto i : v)ans.pb(i);
        cout << ans[n];
    }
} 









Measured memory_bytes: 14448
import java.util.Scanner;
import java.lang.Math;
import java.lang.StringBuilder;
import java.util.regex.Pattern;

    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 j=0; j<A.length-1; j++){
                 for(int k=n-1; k>j; k--){
                     if(A[k] < A[k-1]){
                         int temp = A[k];
                         A[k] = A[k-1];
                         A[k-1] = temp;
                     }
                 }
             }
             
             A[n-1] /= 2;
             
             int sum=0;
             for(int p=0; p<n; p++){
                 sum += A[p];
             }
             
             System.out.println(sum);
    
        }
    }




Measured memory_bytes: 21588
#include <ctime>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define R register
#define ll long long
using namespace std;
const int N = 110000;
const double eps = 1e-15;

struct point {
	double x, y;
	point(double x = 0, double y = 0) : x(x), y(y) {}
	inline point operator - (const point &b) const {
		return point(x - b.x, y - b.y);
	}
	inline point operator + (const point &b) const {
		return point(x + b.x, y + b.y);
	}
	inline point operator * (double w) const {
		return point(x * w, y * w);
	}
}p[N];
inline double dist(const point &a, const point &b);
struct circle {
	point o;
	double r;
	circle() {}
	circle(const point &o, double r) : o(o), r(r) {}
	circle(const point &p1, const point &p2) {
		o = (p1 + p2) * 0.5, r = dist(p1, p2) * 0.5;
		return;
	}
}ans;
struct line {
	point p, v;
	line(const point &p, const point &v) : p(p), v(v) {}
};
int n;

inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}

inline double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

inline double cross(const point &a, const point &b) {
	return a.x * b.y - a.y * b.x;
}

inline double sqr(double x) {
	return x * x;
}

inline double dist(const point &a, const point &b) {
	return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}

inline bool poiInCir(const point &p, const circle &c) {
	return sgn(c.r - dist(p, c.o)) != -1;
}

inline point getInter(const line &a, const line &b) {
	return a.p + a.v * (cross(a.p - b.p, b.v) / cross(b.v, a.v));
}

inline line getBis(const point &p1, const point &p2) {
	return line((p1 + p2) * 0.5, point(p1.y - p2.y, p2.x - p1.x));
}

inline circle makeCir(const point &p1, const point &p2, const point &p3) {
	if (sgn(dot(p1 - p3, p2 - p3)) == -1)
		return circle(p1, p2);
	if (sgn(dot(p2 - p1, p3 - p1)) == -1)
		return circle(p2, p3);
	if (sgn(dot(p1 - p2, p3 - p2)) == -1)
		return circle(p1, p3);
	point o = getInter(getBis(p1, p2), getBis(p1, p3));
	return circle(o, dist(p1, o));
}

int main() {
	srand(time(0));
	scanf("%d", &n);
	for (R int i = 1; i <= n; ++i)
		scanf("%lf %lf", &p[i].x, &p[i].y);
    if (n == 1) return printf("0\n"), 0;
    if (n == 2) return printf("%.10lf\n", dist(p[1], p[2]) / 2), 0;
	for (R int i = 1; i <= n; ++i)
		swap(p[rand() % n + 1], p[rand() % n + 1]);
	ans = makeCir(p[1], p[2], p[3]);
	for (R int i = 4; i <= n; ++i) {
		if (poiInCir(p[i], ans))
			continue;
		ans = circle(p[1], p[i]);
		for (R int j = 2; j < i; ++j) {
			if (poiInCir(p[j], ans))
				continue;
			ans = circle(p[j], p[i]);
			for (R int k = 1; k < j; ++k)
				if (!poiInCir(p[k], ans))
					ans = makeCir(p[i], p[j], p[k]);
		}
	}
	printf("%.10lf\n", ans.r);
	return 0;
}

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

//22:14~

int main() {
  int n; ll k; cin>>n>>k;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  int v=1;
  while (ord[v]==-1) {
    ord[v]=s.size();
    s.push_back(v);
    v=a[v-1];
  }
  int cycle=s.size()-ord[v];
  int start=ord[v];
  int res;
  if (k<start) res=s[k];
  else res=s[(k-start)%cycle+start];
  cout<<res<<endl;
}


Measured memory_bytes: 5884
import java.util.Scanner;

public class Main {
    public static void main(String[] var0) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int AC = 0;
        int WA = 0;
        int TLE = 0;
        int RE = 0;

        for (int i = 0; i < N; i++) {
            String C = scanner.next();
            if (C.equals("AC")) {
                AC += 1;
            } else if(C.equals("WA")) {
                WA += 1;
            } else if(C.equals("TLE")) {
                TLE += 1;
            } else {
                RE += 1;
            }
        }

        System.out.println("AC x " + AC);
        System.out.println("WA x " + WA);
        System.out.println("TLE x " + TLE);
        System.out.println("RE x " + RE);
    }
}

Measured memory_bytes: 48472
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

#define long long ll

char X, Y;

int main()
{
    std::cin >> X >> Y;
    if (X > Y) {
        std::cout << ">";
    } else if (X < Y){
        std::cout << "<";
    } else {
        std::cout << "=";
    }
    return 0;
}

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

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int M = sc.nextInt();
		Pair[] pairs = new Pair[N];


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

			Pair pair = new Pair();
			pair.from = sc.nextInt();;
			pair.end = sc.nextInt();;
			pairs[i] = pair;
		}
		Arrays.sort(pairs);
		long ans = 0l;
		int count = 0;
		
		for(int i = 0;i < N;i++){
			for(int j = 0;j < pairs[i].end;j++){
				ans += pairs[i].from;
				count++;
				if(count == M){
					System.out.print(ans);
					return;
				}
			}
		}


	}


}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


int main(void)
{
	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;

	return 0;
}

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

int main(){
	string s; cin >> s;
	int n=s.size();
	int ans=0;
	rep(i,n) {
		int a=s[i]-'0';
		ans+=a;
		ans%=9;
	}
	if(ans%9==0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdio.h>
#include <cmath>
#include <limits.h>
using namespace std;

typedef long long ll;

#define min(a, b) (((a) < (b))? (a):(b))
#define max(a, b) (((a) > (b))? (a):(b))
#define REP(i, a, n) for(int i=(a); i<(n); ++i)
#define rep(i, n) REP(i, 0, (n))
#define square(a) (a)*(a)
#define pb push_back

int n,a[110];
int main(void) {
    cin >> n;
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
def f(s):
    return eval(s)
    
def g(s):
    ret = ord(s[0])-48
    i = 1
    while i < len(s):
        if s[i] == '+':
            ret += ord(s[i+1])-48
        else:
            ret *= ord(s[i+1])-48
        i += 2
    return ret

s = input()
n = int(input())
f1, f2 = (n == f(s)), (n == g(s))
if f1 and f2:
    print("U")
elif f1:
    print("M")
elif f2:
    print("L")
else:
    print("I")


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> P;
#define MOD 1000000007
#define INF 1000000000
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;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
bool a[334],b[334];
int main(){
	int n,m;
	char c[334][334];	
	cin>>n>>m;
	rep(i,n){
		rep(j,m){
			cin>>c[i][j];
			if(c[i][j]=='#')a[i]=true,b[j]=true;
		}
	}
	rep(i,n){
		rep(j,m){
			if(a[i]&&b[j])cout<<c[i][j];
		}
		if(a[i]==true)cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using Num = long;
 
Num gcd(Num m,Num n){
	Num temp;
	while(m % n != 0){
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}
Num lcm(Num m,Num n){
	return m / gcd(m,n) * n;
}
int main(){
	int n;
	Num ans = 1;
	cin >> n;
	for(int i=0;i<n;i++){
		Num t;
		cin >> t;
		ans = lcm(ans,t);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.text.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String msg = "No";
		char ch[] = sc.next().toCharArray();
		
		int first = 0;
		int second = 0;
		int count = 0;
		
		boolean isOdd = (ch.length % 2 == 0);
		if (ch.length == 0) {
			System.out.println(0);
			return;
		}
		// 0が先頭ケース
		for (int i = 0; i < ch.length; i += 2) {
			if (ch[i] == '0') {
				first++;
			}
		}
		for (int i = 1; i < ch.length; i += 2) {
			if (ch[i] == '1') {
				first++;
			}
		}
		
		// 0が先頭ケース
		for (int i = 0; i < ch.length; i += 2) {
			if (ch[i] == '1') {
				second++;
			}
		}
		for (int i = 1; i < ch.length; i += 2) {
			if (ch[i] == '0') {
				second++;
			}
		}
		count = first > second ? first : second;
		
		if (isOdd) {
			count = ch.length - count;
		}else{
			count = ch.length - count;
		}
		
		System.out.println(count);
	}
}

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int k=0;k<4;k++){
		vector<int> pat(n,-1);//0:wolf,1:sheep
		pat[0]=k%2;
		pat[1]=(k/2)%2;
		for(int i=1;i<n-1;i++){
			if(pat[i]==0){
				if(s[i]=='o'){
					pat[i+1]=(!pat[i-1]);
				}
				else{
					pat[i+1]=pat[i-1];
				}
			}
			else{
				if(s[i]=='o'){
					pat[i+1]=pat[i-1];
				}
				else{
					pat[i+1]=(!pat[i-1]);
				}
			}
		}
		bool isok=true;
		if(pat[0]==0){
			if(s[0]=='o'){
				isok=isok&& (pat[1]!=pat[n-1]);
			}
			else{
				isok=isok&&(pat[1]==pat[n-1]);
			}

		}
		else{
			if(s[0]=='o'){
				isok=isok&&(pat[1]==pat[n-1]);
			}
			else{
				isok=isok&&(pat[1]!=pat[n-1]);
			}
		}

		if(pat[n-1]==0){
			if(s[n-1]=='o'){
				isok=isok&& (pat[n-2]!=pat[0]);
			}
			else{
				isok=isok&&(pat[n-2]==pat[0]);
			}

		}
		else{
			if(s[n-1]=='o'){
				isok=isok&&(pat[n-2]==pat[0]);
			}
			else{
				isok=isok&&(pat[n-2]!=pat[0]);
			}
		}
		if(isok){
			for(int i=0;i<n;i++) cout<<(pat[i] ? 'S' : 'W');
			cout<<endl;
			return 0;
		}

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


Measured memory_bytes: 1016
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;
int cnt;

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

	int N;
	cin >> N;

	vector<int> a(N);
    vector<bool> rate(9);

	rep(i,N){
		cin >> a[i];
        if(a[i]>=1 && a[i]<=399) rate[0] = true;
        if(a[i]>=400 && a[i]<=799) rate[1] = true;
        if(a[i]>=800 && a[i]<=1199) rate[2] = true;
        if(a[i]>=1200 && a[i]<=1599) rate[3] = true;
        if(a[i]>=1600 && a[i]<=1999) rate[4] = true;
        if(a[i]>=2000 && a[i]<=2399) rate[5] = true;
        if(a[i]>=2400 && a[i]<=2799) rate[6] = true;
        if(a[i]>=2800 && a[i]<=3199) rate[7] = true;
        if(a[i]>=3200){
            rate[8] = true;
            cnt++;
        }

	}

	rep(i,8){
        if(rate[i]) ans++;
    }


    int min=0;
    if(rate[8]){
        if(ans==0){
            min = 1;
        }
        else{
            min = ans;
        }

        
        cout << min << " " << ans+cnt << endl;
        
    }
    else cout << ans << " " << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from scipy.sparse import*
def main():
  f=csgraph.floyd_warshall
  n,m,l,*t=map(int,open(0).read().split())
  d=[[0]*(n+1)for _ in range(n+1)]
  for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c
  d=f(f(d,0)<=l)-1
  d[d>n]=-1
  print('\n'.join(map(str,map(int,[d[i]for i in zip(*[iter(t[m*3+1:])]*2)]))))
main()

Measured memory_bytes: 40864