akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const ll MAXN=1e6+5;
ll n,m,t;
ll v[MAXN];
char s[MAXN];
int main(){
    cin>>n>>m;
    if(n==1||m==1){cout<<1;return 0;}
    ll b=m/2,a=m-b;
    ll d=n/2,c=n-d;
    cout<<a*c+b*d;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
using namespace std;
#define EPS 1e-10

struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        x=_x; y=_y;
    }
    Point operator +(const Point p)const{
        return Point(x+p.x,y+p.y);
    }
    Point operator -(const Point p)const{
        return Point(x-p.x,y-p.y);
    }
	Point operator *(const double d)const{
		return Point(x*d,y*d);
	}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point _a,Point _b){
        a=_a; b=_b;
    }
};

double dot(Point p,Point q){
    return p.x*q.x+p.y*q.y;
}

double cross(Point p,Point q){
    return p.x*q.y-q.x*p.y;
}

int ccw(Point a,Point b,Point c){
    if(cross(b-a,c-b)>0) return +1;
    if(cross(b-a,c-b)<0) return -1;
    return 0;
}

bool intersect_ss(Line l,Line m) {
    return ccw(l.a,m.a,l.b)*ccw(l.a,m.b,l.b)<=0 && ccw(m.a,l.a,m.b)*ccw(m.a,l.b,m.b)<=0;
}

bool crosspoint_ll(Line l,Line m,Point &p){
    Point a1,a2,b1,b2;
	a1 = l.b-l.a; a2 = m.b-m.a;
	b1 = m.a-l.a; b2 = m.b-l.a;
	double s1,s2;
	s1 = abs(cross(a1,b1)/2); s2 = abs(cross(a1,b2)/2);
	if(s1<EPS && s2<EPS) return false;
	p = Point(m.a.x+a2.x*s1/(s1+s2),m.a.y+a2.y*s1/(s1+s2));
	return true;
}

bool crosspoint_ss(Line l,Line m,Point &p){
    if(intersect_ss(l,m)==false) return false;
	return crosspoint_ll(l,m,p);
}

int main(){
    int N;
    Line l[100];
    while(cin>>N,N){
        int ans=1;
        for(int i=0;i<N;i++){
            cin>>l[i].a.x>>l[i].a.y>>l[i].b.x>>l[i].b.y;
			vector<Point> cp;
			int cnt=1;
			for(int j=0;j<i;j++){
				Point p;
                if(crosspoint_ss(l[i],l[j],p)==true &&
				   abs(p.x-100)>=EPS && abs(p.x+100)>=EPS &&
				   abs(p.y-100)>=EPS && abs(p.y+100)>=EPS){
					cnt++;
					for(int k=0;k<cp.size();k++){
						if(abs(p.x-cp[k].x)<EPS && abs(p.y-cp[k].y)<EPS){
							cnt--; break;
						}
					}
					cp.push_back(p);
				}
            }
			ans += cnt;
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1224
N,M = map(int, raw_input().split())
hist = [0 for i in range(N)]
for i in range(M):
  a,b = map(int, raw_input().split())
  hist[a-1] += 1
  hist[b-1] += 1
for v in hist:
  if v%2 == 1:
    print 'NO'
    break
else : print 'YES'

Measured memory_bytes: 6668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a=sc.next(),b=sc.next();
		boolean flag = true;
		for(int i=0;i<a.length();i++) {
			if(a.charAt(i)!=b.charAt(i)) {
				flag = false;
			}
		}
		if(a.length()+1!=b.length()) {
			flag = false;
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 35708
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	int x,y;
	while(cin>>x>>y){
		int sum=x+y;
		cout<<(int)log10(sum)+1<<endl;
	}
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 10;

set<ii> points;
set<ii> sqrs;
ll h,w,n;
ll ans[T];

bool isIn(int i, int j) {
    return (i >= 1 and j >= 1 and i+2 <= h and j+2 <= w);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> h >> w >> n;
    ans[0] = (h-2) * (w-2);

    while(n--) {
        int x,y; cin >> x >> y;
        points.emplace(x,y);

        for(int i = x-2; i <= x; i++)
            for(int j = y-2; j <= y; j++)
                if(isIn(i,j)) sqrs.emplace(i,j);

    }

    for(ii x : sqrs) {
        int qtd = 0;

        for(int i = x.fi; i <= x.fi+2; i++)
            for(int j = x.se; j <= x.se+2; j++)
                if(points.count(mk(i,j))) qtd++;

        if(qtd) ans[0]--, ans[qtd]++;
    }

    for(int i = 0; i < T; i++) cout << ans[i] << endl;

    return 0;
}



Measured memory_bytes: 47104
N=int(input())
A=[int(i) for i in input().split()]
B=[]
A=sorted(A)
M=0

amin=A[0]
amax=A[-1]
for a in A[1:N-1]:
	if a<0:
		M-=a
	else:
		M+=a
print(M-amin+amax)
for a in A[1:N-1]:
	if a<0:
		print(amax,a)
		amax=amax-a
	else:
		print(amin,a)
		amin=amin-a
print(amax,amin)

Measured memory_bytes: 14076
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for (string s; cin >> s;) {
		int IOI = 0, JOI = 0;
		string tmp; tmp = s;
		for (size_t a = tmp.find("IOI"); a != string::npos; a = tmp.find("IOI")) {
			tmp[a] = 'A';
			IOI++;
		}
		for (size_t a = s.find("JOI"); a != string::npos; a = s.find("JOI")) {
			s[a] = 'A';
			JOI++;
		}
		cout << JOI << endl;
		cout << IOI << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    string pre = s.substr(0,2);
    string ato = s.substr(2);

    int a = stoi(pre);
    int b = stoi(ato);

    if(a==0 and b==0){
        cout << "NA" << endl;
        return 0;
    }
    if(a==0){
        if(b <= 12){
            cout << "YYMM" << endl;
            return 0;
        }
        if(b > 12){
            cout << "NA" << endl;
            return 0;
        }
    }
    if(b==0){
        if(a <= 12){
            cout << "MMYY" << endl;
            return 0;
        }
        if(a > 12){
            cout << "NA" << endl;
            return 0;
        }
    }

    if(a > 12 and b > 12){
        cout << "NA" << endl;
        return 0;
    }

    if(a <= 12 and b <= 12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if(a <= 12 and  b > 12){
        cout << "MMYY" << endl;
        return 0;
    }

    if(b <= 12 and a > 12){
        cout << "YYMM" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1<<30;
map<pair<int,int>,int> MA;
int pre[MAX][MAX],dis[MAX][MAX];
vector<int> G[MAX];
vector<int> ans(1010,0);

void BFS(int s){
    dis[s][s]=1;
    queue<int> Q;
    Q.push(s);
    int t=-1;
    bool flag=false;
    while(!Q.empty()&&!flag){
        int a=Q.front();Q.pop();
        for(int u:G[a]){
            if(dis[u][s]!=INF) continue;
            pre[u][s]=a;
            dis[u][s]=dis[a][s]+1;
            Q.push(u);
            if(MA[{u,s}]){
                t=u;
                flag=true;
                break;
            }
        }
    }
    if(dis[t][s]>=ans.size()||t==-1) return;
    vector<int> S;
    while(pre[t][s]!=-1){
        S.push_back(t);
        t=pre[t][s];
    }
    S.push_back(s);
    ans=S;
}

int main(){
    
    int N,M;cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;a--;b--;
        G[a].push_back(b);
        MA[{a,b}]=1;
    }
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            pre[i][j]=-1;
            dis[i][j]=INF;
        }
    }
    
    for(int i=0;i<N;i++){
        BFS(i);
    }
    
    if(ans.size()==1010) cout<<-1<<endl;
    else{
        cout<<ans.size()<<endl;
        for(int u:ans) cout<<u+1<<endl;
    }
}


Measured memory_bytes: 70784
import sys

if __name__ == "__main__":
    a = int(sys.stdin.readline())
    b = int(sys.stdin.readline())
    c = int(sys.stdin.readline())
    d = int(sys.stdin.readline())
    e = int(sys.stdin.readline())
    k = int(sys.stdin.readline())

    if e - a > k:
        print(":(")
    else:
        print("Yay!")

Measured memory_bytes: 3060
H,W = map(int, input().split())
A = [[int(i) for i in input().split()] for _ in range(H)]

cnt = 0
ans = []
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            if i == H - 1 and j == W - 1:
                continue
            if j == W - 1:
                if A[i][j] % 2 == 1:
                    A[i][j] -= 1
                    A[i+1][j] += 1
                    ans.append((i+1, j+1, i+2, j+1))
            else:
                if A[i][j] % 2 == 1:
                    A[i][j] -= 1
                    A[i][j+1] += 1
                    ans.append((i+1, j+1, i+1, j+2))
    else:
        for j in range(W - 1, -1, -1):
            if i == H - 1 and j == 0:
                continue
            if j == 0:
                if A[i][j] % 2 == 1:
                    A[i][j] -= 1
                    A[i+1][j] += 1
                    ans.append((i+1, j+1, i+2, j+1))
            else:
                if A[i][j] % 2 == 1:
                    A[i][j] -= 1
                    A[i][j-1] += 1
                    ans.append((i+1, j+1, i+1, j))

print(len(ans))
for a in ans:
    print(*a, sep = " ")

Measured memory_bytes: 26604
#include <iostream>
# include <algorithm>

using namespace std;

typedef long long ll;
ll f(ll a, ll b)
{
  ll r, x, tmp;
 
  x = a * b;
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  //cout << "x: " << x << endl;
  //cout << "b: " << b << endl;
  return x/b;
}


int main()
{
  ll A, B;
  ll C, D;
  cin >> A >> B >> C >> D;
  ll lcm = f(C, D); 
  //cout << "lcm: " << lcm << endl;

  
  ll ans = 0;
  ll temp = B+2;
  /*
    for (ll i=A; i<(B+1); i++){
    if(i%lcm == 0){
      temp = i*2;
      ans++;
    }
  }
  for (ll i=temp; i<(B+1); i=i+lcm){
    ans++;
    }*/
  
  ll b = (A-1)/lcm;
  ll a = B/lcm;
  ll b1 = (A-1)/C;
  ll a1 = B/C;
  ll b2 = (A-1)/D;
  ll a2 = B/D;
  ans = (B-A+1) - ((a1-b1) + (a2-b2) - (a-b));
  //cout << a << ", " << b << endl;
  cout << ans << endl;
   

  return 0;
}


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

long long a,b,x,y,k
;


int main(){
  cin>>a>>b;
  for(long long i=a;i<=b;i++){
   if(i%10==i/10000){
        x=i/10;
        y=i/1000;
    if((x%10)==(y%10))k++;
   }
  }
  cout<<k;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

int digitSum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int main(void){
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for (int i = 1; i <= N; i++){
    if (digitSum(i) >= A && digitSum(i) <= B) ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,k,t,ans,cnt;
	for(;;){
		scanf("%d%d",&n,&k);
		if(n==0 && k==0)break;
		vector<int> v,u;
		ans=0;
		rep(i,k){
			scanf("%d",&t);
			v.push_back(t);
		}
		sort(v.begin(),v.end());
		cnt=1;
		if(v[0]==0){
			int f=0;
			rep(i,k-2){
				if(v[i+2]-v[i+1]==1)cnt++;
				else{
					u.push_back(cnt);
					if(v[i+2]-v[i+1]==2)u.push_back(0);
					cnt=1;
				}
			}
			u.push_back(cnt);
			rep(i,u.size()){
				ans=max(ans,u[i]+1);
				if(u[i]==0 && i>0 && i< u.size()-1)ans=max(ans,u[i-1]+u[i+1]+1);
			}
		}else{
			rep(i,k-1){
				if(v[i+1]-v[i]==1)cnt++;
				else {
					ans=max(ans,cnt);
					cnt=1;
				}
			}
			ans=max(ans,cnt);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1712
#!/usr/bin/env python
# -*- coding: utf-8 -*-

w, a, b = map(int, input().split())

if (a + w >= b and b >= a) or (b + w >= a and b <= a):
    print(0)
elif a + w < b:
    print(b - (a + w))
else:
    print(a - (b + w))


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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt(); // arrays
		int m = nextInt(); // numbers in each array
		int q = nextInt();
		int[] a = new int[q];
		for (int i = q - 1; i >= 0; i--) {
			a[i] = nextInt() - 1;
		}
		
		TreeSet<Integer>[] sets = new TreeSet[m];
		for (int i = 0; i < m; i++) {
			sets[i] = new TreeSet<>();
		}
		
		for (int i = 0; i < q; i++) {
			sets[a[i]].add(i);
		}
		
		boolean[] used = new boolean[m];
		
		int[] ptrs = new int[n];
		Arrays.fill(ptrs, -1);
		
		int curPos = 0;
		
		int lastProper = -1;
		
		outer: while (true) { // ?
			while (curPos < q && used[a[curPos]]) {
				curPos++;
			}
			
			if (curPos == q) { // huh?
				out.println("Yes");
				return;
			}
			
			int num = a[curPos];
			used[num] = true;
			
			int prev = -1;
			
			for (int i = 0; i < n; i++) {
				Integer newPtr = sets[num].higher(Math.max(prev, ptrs[i]));
				if (newPtr == null) {
					lastProper = num;
					break outer;
				}
				sets[num].remove(newPtr);
				ptrs[i] = newPtr;
				prev = newPtr;
			}
		}
		
		List<Integer> rest = new ArrayList<>();
		rest.add(lastProper);
		for (int i = curPos; i < q; i++) {
			if (!used[a[i]]) {
				rest.add(a[i]);
				used[a[i]] = true;
			}
		}
		
		for (int i = 0; i < m; i++) {
			if (!used[i]) {
				rest.add(i);
			}
		}
		
		for (int i = 0; i < rest.size() - 1; i++) {
			if (rest.get(i) > rest.get(i + 1)) {
				out.println("No");
				return;
			}
		}
		
		out.println("Yes");
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

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

int main(){
  string S,T,U;
  int A,B;
  cin>>S>>T>>A>>B>>U;
  if(S==U)
    cout<<A-1<<' '<<B<<endl;
  else
    cout<<A<<' '<<B-1<<endl;
}

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

const int maxn = 100005;
int n, a[maxn][3], dp[maxn][3];

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
    dp[1][0] = a[1][0], dp[1][1] = a[1][1], dp[1][2] = a[1][2];
    for(int i = 2; i <= n; i++) for(int j = 0; j < 3; j++){
        for(int k = 0; k < 3; k++){
            if(k == j) continue;
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
        }
    }
    printf("%d", max({dp[n][0], dp[n][1], dp[n][2]}));
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define forup(i,a,b) for(int i=(a); i<(b); ++i)
#define fordn(i,a,b) for(int i=(a); i>(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)

#define gi(x) scanf("%d",&x)
#define gl(x) cin>>x
#define gd(x) scanf("%lf",&x)
#define gs(x) scanf(" %s",x)

#define D(x) cout << #x << " : " << x << endl

#define fs first
#define sc second

#define pb push_back
#define mp make_pair

const int inf=numeric_limits<int>::max();
const LL linf=numeric_limits<LL>::max();

const int max_n=3010;

LL n, dp[max_n][max_n][2], a[max_n];
bool s[max_n][max_n][2];

LL mx(LL aa, LL a, LL bb, LL b, LL c){
    return (c==0)?max(aa+a,bb+b):min(a-aa,b-bb);
}

LL f(int l, int r, int c){
    // D(l<<r<<c);
    if(r<0 || l >= n || l>r) return 0;
    if(s[l][r][c])
        return dp[l][r][c];

    s[l][r][c] = true;
    return dp[l][r][c] = mx(a[l],f(l+1,r,!c), a[r],f(l,r-1,!c), c);
}

int main() {
    gl(n);
    rep(i,n) gl(a[i]);

    cout << f(0,n-1,0) << endl;
    return 0;
}

Measured memory_bytes: 158208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		
		int t = 0;
		
		if(n > k)
		{
			t+= n/k;
			n = n%k;
			if(n<0)n+=k;
		}
		
		if(n==0)
		{
			System.out.println(n);
			return;
		}
		
		//n<k
		if(k - n < n)
		{
			n = k-n;
			t++;
		}
		System.out.println(n);
		
	}

}


Measured memory_bytes: 23124
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0
abc=[]
for i in range(3):
    l=list(input())
    abc.append(l[i])
print(*abc,sep="")


Measured memory_bytes: 38256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <tuple>
#include <set>

int main() {
  char buf[8];
  scanf("%s", buf);
  std::string S = buf;
  std::sort(S.begin(), S.end());
  if (S[0] == S[1] && S[1] != S[2] && S[2] == S[3])
    puts("Yes");
  else
    puts("No");
}


Measured memory_bytes: 256
#include <iostream>
 #include <string>
 using namespace std;
 int main(){
 string s;
 cin>>s;
 if(s=="Sunny"s) cout<<"Cloudy"<<endl;
 if(s=="Cloudy"s) cout<<"Rainy"<<endl;
 if(s=="Rainy"s) cout<<"Sunny"<<endl;
 return 0;
 }

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

int main() {
    vector<int> a;
    for(int i=0; i<9; i++){
        int x;
        cin >> x;
        a.push_back(x);
    }
    int n;
    cin >> n;
    vector<bool> b (9,false);
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        for(int j=0; j<9; j++){
            if(a.at(j) == x){
                b.at(j) = true;
            }
        }
    }
    string ans = "No";
    if((b.at(0)==true && b.at(1)==true && b.at(2)) || (b.at(3)==true && b.at(4)==true && b.at(5)) || (b.at(6)==true && b.at(7)==true && b.at(8)) || (b.at(0)==true && b.at(3)==true && b.at(6)) || (b.at(1)==true && b.at(4)==true && b.at(7)) || (b.at(2)==true && b.at(5)==true && b.at(8)) || (b.at(0)==true && b.at(4)==true && b.at(8)) || (b.at(2)==true && b.at(4)==true && b.at(6))){
        ans = "Yes";
    }
    cout << ans << endl;
}

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

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

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

  vector<int> check(m+5,0);
  vector<ll> suma(m+5,0);
  vector<ll> a(m+5);
  a.at(1) = x;
  suma.at(1) = x;
  check.at(x) = 1;

  int loop = 0;
  int first = 0;
  ll loopsum = 0;
  ll firstsum = 0;
  
  for(int i=2; i<=m+5; i++){
    a.at(i) = a.at(i-1)*a.at(i-1);
    if(a.at(i)>=m) a.at(i)%=m;
    //cout << a.at(i) << endl;
    if(check.at(a.at(i))==0) {
      check.at(a.at(i)) = i;
      suma.at(i)=suma.at(i-1)+a.at(i); 
    }else{
      loop = i-check.at(a.at(i));
      first = max(0, check.at(a.at(i))-1);
      loopsum = suma.at(i-1)-suma.at(first);
      firstsum = suma.at(first);
      break;
    }
  }

  int k = first;
  if(n<first) k=n;
  ll p = (n-k)/loop;
  ll r = n-k-loop*p;
  if(r<0) r=0;
  ll ans = suma.at(k) + loopsum*p + suma.at(first+r) - suma.at(first);
  cout << ans;
  
}

Measured memory_bytes: 5092
#include <stdio.h>
 
int main() {
  int height, width;

  while(1){
    scanf("%d %d",&height,&width);
    if(height == 0 && width == 0) break;

    for(int i=1; i<=height; i++) {
      for(int j=1; j<=width; j++) {
        if (i==1 || i==height) printf("#");
        else {
          if (j==1 || j==width) printf("#");
          else printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


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

using pii = pair<int, int>;

int main() {
    int n, k; cin >> n >> k;
    string s, t; cin >> s >> t;

    vector<int> sum(n + 1);
    for(int i = 0; i < n; ++i) {
        sum[i + 1] = sum[i] + (i == 0 || t[i - 1] != t[i]);
    }

    vector<int> dp(n + 1);
    deque<pii> deq;
    deq.emplace_back(0, -1);
    for(int i = 1; i <= n; ++i) {
        if(deq.front().first < i - k) deq.pop_front();
        if(s[i - 1] == t[i - 1]) {
            dp[i] = dp[i - 1];
        } else {
            dp[i] = (deq.front().second + sum[i] + 1) / 2 + 1;
        }
        if(i != n) {
            const int added = 2 * dp[i] - sum[i + 1];
            while(!deq.empty() && deq.back().second >= added) deq.pop_back();
            deq.emplace_back(i, added);
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 7892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b,c;
    cin>>a>>b>>c;
    int d;
    d=max(a,max(b,c));
    int e;
    e=min(a,min(b,c));
    int f;
    f=a+b+c-d-e;
    if((f-e)%2==0){
    cout<<d-f+(f-e)/2;
    }else{
        cout<<1+d-f+(f+1-e)/2;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101
void Search(int);
 
int number,G[MAX][MAX],d[MAX],count=0;
int F[MAX] = {0};
 
  
int main(void){
  int i,j,k=0,u,a;
   
  for(i = 0;i < number;i++){
    d[i] = 0;
  }
    
  scanf("%d",&number);
   
  for(i = 0;i < number + 1;i++){
    for(j = 0;j < number + 1;j++){
      G[i][j] = 0;
    }
  }
   
  for(i = 0;i < number;i++){
   
    scanf("%d %d ",&k,&u);
   
    for(j = 0;j < u;j++){
      scanf("%d",&a);
      G[k - 1][a - 1] = 1;
    }
  }
  
  for(i = 0;i < number;i++){
    if(d[i] == 0)
    Search (i);
  }
       
  for(i = 0;i < number;i++){
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
  
  return 0;
 }
 
 
void Search(int u){
  int v;
  count++;
  d[u] = count;
   
  for(v = 0;v < number;v++){
    if(G[u][v] == 1 && d[v] == 0 ){
      Search(v);
    }
  }
  count++;
  F[u] = count;
}



Measured memory_bytes: 2128
#include<iostream>
    #include <string>
   #include <algorithm>
    using namespace std; 
     
    int main(){
    unsigned long N,x,i,temp,zero;
    unsigned long array1[100000],array2[100000];
    unsigned long long sum =0;
    cin >>N>>x ;
    for(i = 0 ; i< N; i++){
       cin >> array1[i];
array2[i] = array1[i];
    }
if(array1[0]>x){
array1[0]=x;
}
    for(i = 0 ; i< N-1; i++){
             if((array1[i]+array1[i+1])>x){
               array1[i+1] = max(zero, x-array1[i]);
               if(array1[i]>x){
               array1[i] = x;
               }
         }

    }
for(i=0;i<N;i++){
sum += array2[i]-array1[i];
}
    cout << sum;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    for(int i = n-1; i >= 0; i--) {
        if((a[i] + ans) % b[i] == 0) continue;
        ans += b[i] - (a[i] + ans) % b[i];
    }

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



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
class UnionFind {
private:
    vector<int> par, rank;
    
    int find(int x) {
        if(par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }
public:
    UnionFind(int Max_Node) {
        par.resize(Max_Node);
        rank.resize(Max_Node);
    }
    
    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        
        if (rank[x] < rank[y])
            par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};


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

    int n, m;
    cin >> n >> m;
    vector<int> in(n);
    
    for (int i = 0; i < n; i++) {
        cin >> in[i];
    }
    
    UnionFind uf(n + 10);
    uf.init(n+1);
    
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
        //uf.unite(b, a);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(in[i], i+1))
            ans++;
    }
    cout << ans << endl;
    
    
    
    
    
    
    return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll S, W;

    cin >> S >> W;
    if( W >= S ){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
  int n;
  while(cin >> n) {
    vector<string> ans;
    for (int i = 0; i < n; ++i) {
      int x, y, z;
      cin >> x >> y >> z;
        if (x * x == y * y + z * z || y * y == z * z + x * x || z * z == x * x + y * y) {
          ans.push_back("YES");
      } else {
        ans.push_back("NO");
      }
    }
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define SZ(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define MP make_pair
#define PB push_back
const int INF=1<<28;
	/*int n;
	int dp[50][50][50];
	int ta[]={380,550,850},wa[]={5,4,3};
	
	int dfs(int a,int b,int c){
		//cout<<a<<" "<<b<<" "<<c<<endl;
		if(a*200+b*300+c*500>n)return dp[a][b][c]=INF;
		
		if(dp[a][b][c]!=INF)return dp[a][b][c];	
		if(a*200+b*300+c*500==n){
			int ret=0;
			
			while(a>=5)a-=5,ret+=(380*5)*0.8;
			ret+=a*380;
			
			while(b>=4)b-=4,ret+=(550*4)*0.85;
			ret+=b*550;
			
			while(c>=3)c-=3,ret+=(850*3)*0.88;
			ret+=c*850;
			
			return dp[a][b][c]=ret;
		}
		
		int ret=INF;
	ret=min( ret,dfs(a+1,b,c) );
	ret=min( ret,dfs(a,b+1,c) );
	ret=min( ret,dfs(a,b,c+1) );
	
	return dp[a][b][c]=ret;
	}*/


	int main(){
	int n;
	while(cin>>n,n){
	int ans=1<<20;
		for(int i=0;i<=50;i++){
			for(int j=0;j<=50;j++){
				for(int k=0;k<=50;k++){
					int a=i,b=j,c=k,ret=0;
					if(a*200+b*300+c*500==n){
			
				while(a>=5)a-=5,ret+=(380*5)*0.8;
				ret+=a*380;
				
				while(b>=4)b-=4,ret+=(550*4)*0.85;
				ret+=b*550;
			
				while(c>=3)c-=3,ret+=(850*3)*0.88;
				ret+=c*850;
								ans=min(ans,ret);
				}

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

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef pair<double, vector<int> > P;

const int MAX_N = 15;
const double INF = 999999999.0;

int n;
int no[MAX_N], x[MAX_N], w[MAX_N];
P dp[MAX_N][1 << MAX_N];

P solve(int v, int S, int weight)
{
    P res(0.0, vector<int>());
    res.second.push_back(no[v]);
    
    if(S == (1 << n) - 1) 
        return res;
    if(dp[v][S].first != INF)
        return dp[v][S];

    res.first = INF;
    for(int u = 0; u < n; u++) {
        if(!(S >> u & 1)) {
            P tmp = solve(u, S | 1 << u, weight + w[u]);
            tmp.first += fabs((double)(x[v] - x[u])) / (2000.0 / (70 + weight));
            if(res.first > tmp.first) {
                res = tmp;
            }
        }
    }

    res.second.insert(res.second.begin(), no[v]);

    return dp[v][S] = res;
}

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> no[i] >> x[i] >> w[i];
        w[i] *= 20;
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < (1 << n); j++) {
            dp[i][j] = P(INF, vector<int>());
        }
    }

    P ans(INF, vector<int>());
    for(int v = 0; v < n; v++) {
        P tmp = solve(v, 1 << v, w[v]);
        if(ans.first > tmp.first) ans = tmp;
    }

    for(int i = 0; i < n - 1; i++) 
        cout << ans.second[i] << " ";
    cout << ans.second[n-1] << endl;

}

Measured memory_bytes: 19000
import java.util.*;
class Main 
{ 

	
	 
	public static void main(String args[]) 
	{ 
		Scanner s = new Scanner(System.in);
		double n = s.nextDouble();
		double x = s.nextDouble();
		System.out.printf("%.10f\n",n/x);
		 
	} 
} 


Measured memory_bytes: 24532
str = [input() for i in range(1)]

if str[0] == "SUN":
    print(7)
if str[0] == "MON":
    print(6)
if str[0] == "TUE":
    print(5)
if str[0] == "WED":
    print(4)
if str[0] == "THU":
    print(3)
if str[0] == "FRI":
    print(2)
if str[0] == "SAT":
    print(1)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int h,m,s,t;
  for(;cin>>h>>m>>s;)
    {
      if(h==-1)
	break;
      int a,b,x;
      for(int i=0;i<2;i++)
	{
	  t=7200-(h*3600+m*60+s);
	  if(i==1)
	    t*=3;
	  a=t/3600;
	  t%=3600;
	  b=t/60;
	  t%=60;
	  printf("%02d:%02d:%02d\n",a,b,t);
	}

    }
}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.io.*;


class Main {
	public static void main(String args[]) {
	    Scanner sc = new Scanner(System.in);
	    while( true ){
	    	String s1 = sc.next();
	    	int x = Integer.parseInt(s1);
	    	String s2 = sc.next();
	    	int y = Integer.parseInt(s2);
	    	if( x == 0 && y == 0){
	    		break;
	    	}
	    	if( x < y ){
	    	    System.out.println( x + " " + y );
	    	}
	    	else{
	    		System.out.println( y + " " + x );
	    	}
	    }
	}
}

Measured memory_bytes: 25164
A,B,C,X,Y=map(int,input().split())
if A+B<C*2:
    print(A*X+B*Y)
else:
    if X>=Y:
        kazu=Y*C*2
        if A>=C*2:
            number=(X-Y)*C*2
            print(kazu+number)
        else:
            number=(X-Y)*A
            print(kazu + number)
    else:
        kazu=X*C*2
        if B>=C*2:
            number = (Y-X) * C*2
            print(kazu + number)
        else:
            number = (Y-X) * B
            print(kazu + number)
            

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;
const int inf=1001001001;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
int main()
{
    ll a,b,c,n,sum=0,k;
    string s;
    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)sum+=gcd(i,gcd(j,l));
    			else if(i!=j&&j!=l)sum+=6*gcd(i,gcd(j,l));
    			else sum+=gcd(i,gcd(j,l))*3;
    		}
    	}
    }
    cout<<sum;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;


int main(){
    int n;
    int ans = 0;
    
    cin >> n;

    for (int i = 1; i <= n; i += 2) {
        int count = 0;
        for (int yakusuu = 1; yakusuu <= i; yakusuu++) {
            if (i % yakusuu == 0) {
                count++;

            }
        }
        if (count == 8) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <deque>

using namespace std;

int main() {
    deque<int> dq;
    
    int n;
    cin>>n;
    
    while(n){
        int q,d;
        cin>>q;
        
        switch(q){
            case 0:
                cin>>d;
                int x;
                cin>>x;
                if(d==0){
                dq.push_front(x);
                }else if(d==1){
                    dq.push_back(x);
                }
                break;
            case 1:
                int p;
                cin>>p;
                cout<<dq.at(p)<<endl;
                
                break;
            case 2:
                cin>>d;
                if(d==0){
                    dq.pop_front();
                }else if(d==1){
                    dq.pop_back();
                }
                break;
        }
        --n;
    }
    
}
    


Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n, k; cin >> n >> k;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int digit;
  for (digit = 0; (1LL << digit) <= k; digit++) ;
  digit--;
  vector<int> look; look.push_back(k);
  for (int i = digit; i >= 0; i--) {
    int u = k;
    if (u & (1 << i)) {
      u ^= (1 << i);
      for (int j = 0; j < i; j++) {
        u |= (1 << j);
      }
      look.push_back(u);
    }
  }
  long long ans = 0;
  for (int i = 0; i < (int) look.size(); i++) {
    int p = ~look[i]; long long tmp = 0;
    for (int j = 0; j < n; j++) {
      if ((p & a[j]) == 0) tmp += (long long) b[j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

int main() {
	string c1, c2, c3;
	cin >> c1 >> c2 >> c3;
	
	char c11 = c1[0];
	char c22 = c2[1];
	char c33 = c3[2];
	string ans  = {c11, c22, c33};
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func nextInt64(s *bufio.Scanner) int64 {
	n, err := strconv.ParseInt(nextStr(s), 0, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	r := bufio.NewReader(os.Stdin)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	str := nextLine(r)
	sum := 0
	for _, c := range str {
		sum += int(c - '0')
	}

	if sum % 9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3080
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

X_l = sorted([Ai for Ai, Bi in AB])
X_r = sorted([Bi for Ai, Bi in AB])

if N % 2 == 0:
    ans_min = X_l[N // 2 - 1] + X_l[N // 2]
    ans_max = X_r[N // 2 - 1] + X_r[N // 2]
else:
    ans_min = X_l[N // 2]
    ans_max = X_r[N // 2]

ans = ans_max - ans_min + 1
print(ans)

Measured memory_bytes: 50948
#include<bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define vv(dt) vector<vector<dt>>
#define vec vector<int>
#define un unsigned
#define mp(x,y) make_pair(x,y)
#define dbl double
#define wking(t) cout<<"Working "<<t<<endl;
#define loop(i,s,n) for(auto i=s;i!=n;i++)
#define min2(a,b) (a)<(b)?(a):(b)
#define eps 0.000000001
#define inf 100000000000000001
using namespace std;

int f(int n,vec &dp,vv(int) &E)
{
    if(dp[n]!=-1) return dp[n];
    int maxm=-1;
    loop(i,0,E[n].size())
    {
        int temp = f(E[n][i],dp,E);
        if(maxm<temp) maxm=temp;
    }
    return dp[n] = max(dp[n],1+maxm);
}

int calc(int N,vv(int) &E)
{
    vec dp(N+1,-1);
    int max=-1;
    loop(i,1,N+1)
    {
        int temp = f(i,dp,E);
        if(max<temp) max=temp;
    }
    return max;
}

int main()
{
    int N,M;
    cin>>N>>M;
    vv(int) E(N+1);
    loop(i,0,M)
    {
        int x,y;
        cin>>x>>y;
        E[x].pb(y);
    }
    cout<<calc(N,E)<<endl;
    return 0;
}


Measured memory_bytes: 8832
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int h = Integer.parseInt(scanner.next());
        int a = Integer.parseInt(scanner.next());
        int i = 0;
        while (h > 0) {
            h = h - a;
            i++;
        }
        pw.println(i);
        pw.flush();
    }
}

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

const double PI=3.14159265358979323846;

int main()
{
    double a, b, C;
    cin >> a >> b >> C;
    C = C/180*PI;
    double S, L, h, R;
    S = a*b*sin(C)/2;
    R = sqrt(a*a + b*b - 2*a*b*cos(C))/(2*sin(C));   
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(C));
    h = b*sin(C);
    cout << fixed << setprecision(15) << S << endl;
    cout << fixed << setprecision(15) << L << endl;
    cout << fixed << setprecision(15) << h << endl;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    map<string, int> mp;
    for(int i = 0;i < n;i++){
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}


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

s=input()
t=input()
sl=len(s)
tl=len(t)
ans=10**18
for i in range(sl-tl+1):
    tmp=s[i:i+tl]
    cnt=0
    for j in range(tl):
        if tmp[j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
 

int n;

void dfs(string &s, char c) {
	if (s.size() == n) {
		cout << s << endl;
		return;
	}
	for (char add = 'a'; add <= c; add++) {
		s += add;
		if (add == c) {
			dfs(s, c + 1);
		}
		else {
			dfs(s, c);
		}
		s.pop_back();
	}
}
 
signed main() {
	cin >> n;
	string s;
	dfs(s, 'a');
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;

  int ans = 0;
  int target = 1;
  for (int& x : a) {
    ans += (x != target);
    if (x == target) target++;
  }
  if (ans == n) ans = -1;
  cout << ans << endl;
}


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

int main(){
  int N;
  string s;

  cin >> N;
  cin >> s;

  int ans=0;

  for(int i=0;i+1<N;){
    if(s[i]=='O' && s[i+1]=='X'){
      ans++;
      i+=2;
    }
    else if(s[i]=='X' && s[i+1]=='O'){
      ans++;
      i+=2;
    }
    else {
      i++;
    }
  }

  cout << ans << endl;
}



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

int main(){
  int n;
  cin >> n;
  cout << n/3 << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <cmath>

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

int main() {
	int N, M, X;
	cin >> N >> M >> X;

	vector<int> C(N);
	vector<vector<int>> A(N, vector<int>(M));

	for (int i = 0; i < N; ++i) {
		cin >> C[i];
		for (int j = 0; j < M; ++j) {
			cin >> A[i][j];
		}
	}

	int ans = 100000000;
	for (int i = 1; i < (1 << (N+1)); ++i) {
		int money = 0;
		vector<int> total(M, 0);
		for (int j = 0; j < N; ++j) {
			if (i & (1 << j)) {
				for (int k = 0; k < M; ++k) {
					total[k] += A[j][k];
				}
				money += C[j];
			}
		}

		bool ok = true;
		for (int k = 0; k < M; ++k) {
			if (total[k] < X) {
				ok = false;
				break;
			}
		}

		if (ok) {
			ans = min(ans, money);
		}
	}
	cout << (ans == 100000000 ? -1 : ans)<< endl;

	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    int x,t;cin >> x >> t;
    cout << (n+x-1)/x * t << endl;
}

Measured memory_bytes: 3644
n = int(input())
a = input()
b = input()
c = input()
res = 0
for i in range(n):
  if a[i] == b[i]:
    if c[i] == b[i]:
      res += 0
    else:
      res += 1
  else:
    if c[i] == b[i]:
  	  res += 1
    else:
      if a[i] == c[i]:
        res += 1
      else:
        res += 2
print(res)

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

using namespace std;
using ll = long long;
using ld = long double;
const int MOD=1e9+7;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    ll ans=0;
    for(ll i = k; i <= n+1; i++) {
        ll tmp;
        tmp=((n%MOD)*(i%MOD))%MOD;
        ans+=tmp;
        tmp=MOD-(((i-1)%MOD)*(i%MOD))%MOD;
        ans+=tmp;
        ans=(ans+1)%MOD;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	string s;
	int i;
	int cnt;
	cin>>n;
	cin>>s;
	cnt=1;
	for(i=1;i<n;i++){
		if(s[i-1]!=s[i])	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 512