akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n,tt;
    cin>>n>>tt;
    vv c(n, vi (2));
    rep(i,n){
        cin>>c[i][0]>>c[i][1];
    }
    
    sort(c.begin(), c.end());
    
    rep(i,n){
        if(c[i][1]<=tt){
            cout<<c[i][0]<<endl;
            return 0;
        }
    }
    
    cout<<"TLE"<<endl;
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner sc = new Scanner();

    internal static void Main(string[] args) {
        var N = sc.nextInt();
        var M = sc.nextInt();
        var a = sc.ArrayInt(N);

        var sum = new int[N + 1];
        for (int i = 0; i < N; i++) {
            sum[i + 1] = (sum[i] + a[i]) % M;
        }

        long ans = 0;
        var dic = new Dictionary<int, int>();
        for (int i = 0; i < sum.Length; i++) {
            if (!dic.ContainsKey(sum[i])) {
                dic.Add(sum[i], 0);
            }

            ans += dic[sum[i]];
            dic[sum[i]]++;
        }

        WriteLine(ans);
    }
}



class Scanner {
    string[] s;
    int i;

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

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

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

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

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

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

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

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

Measured memory_bytes: 25312
def main():
    n = int(input())
    A = []
    for _ in range(n):
        x, l = map(int, input().split())
        A.append([x - l, x + l])
    A.sort(key = lambda x: x[1])
    ans, lmax = 0, -10 ** 11
    for a in A:
        if lmax <= a[0]:
            ans += 1
            lmax = a[1]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25456
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  h,w,i,j,count,x,y,sw,m,n,a,b,c:Integer;
  //a,b:array of string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(b);
    Readln(c);

    if  (b-a)=(c-b) then
      Writeln('YES')
    else
      Writeln('NO');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


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


int main() 
{
    int A[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;

    int B[100];
    for (int k = 0; k < N; k++)
    {
        cin >> B[k];
    }

    bool answer = false;

    for (int a = 0; a < 3; a++)
    {
        for (int b = 0; b < 3; b++)
        {
            for (int c = 0; c < N; c++)
            {
                if (A[a][b] == B[c])
                    A[a][b] = 0;
            }
        }
    }

    if (A[0][0] + A[0][1] + A[0][2] == 0 || A[1][0] + A[1][1] + A[1][2] == 0 || A[2][0] + A[2][1] + A[2][2] == 0)
        answer = true;
    if (A[0][0] + A[1][0] + A[2][0] == 0 || A[0][1] + A[1][1] + A[2][1] == 0 || A[0][2] + A[1][2] + A[2][2] == 0)
        answer = true;
    if (A[0][0] + A[1][1] + A[2][2] == 0 || A[0][2] + A[1][1] + A[2][0] == 0)
        answer = true;

    if (answer)
    {
        cout << "Yes";
    }
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	int a;
	String op;
	int b;
	public Main(){
	    Scanner scan = new Scanner(System.in);
		for(;;){
			a=scan.nextInt();
			op=scan.next();
			b=scan.nextInt();
		    if(op.equals("+")){
			     System.out.println(a+b);
		    }else if(op.equals("-")){
			     System.out.println(a-b);
		    }else if(op.equals("*")){
			     System.out.println(a*b);
		    }else if(op.equals("/")){
		 	     System.out.println(a/b);
		    }else if(op.equals("?")){
			     break;
		    }
		}
	}
	public static void main(String[]args){
		new Main();
	}
}

Measured memory_bytes: 26036
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int A, B, T, c;
    c = 0;
    cin >> A >> B >> T;
    for(int i = A; i <= T + 0.5; i += A){
        c += B;
    }
    cout << c;
    return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
long long n;cin>>n;
vector<int> v(n);
long long ans=0;
for(int i=0;i<n;i++)cin>>v[i];
long long a=1;
for(int i=0;i<n;i++){
    if(v[i]==1)break;
    else if(i==n-1){cout<<-1;return 0;}
}
for(int i=0;i<n;i++){
    if(v[i]==a){
        a++;ans++;
    }
}
    cout<<n-ans;



}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
ll d[200005];
ll t[200005];
int main() {
	int n,m;
	cin >> n;
	map<int, int>mpa, mpb;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		mpa[d[i]]++;
	}
	for (int j = 0; j < m; j++) {
		mpb[t[j]]++;
    }
	for (int i = 0; i < m; i++) {
		int x = t[i];
		if (mpb[x] > mpa[x]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 22144
#include <stdio.h>
   
#define MAX 100000
#define N -1
   
struct Node{
  int y; 
  int l; 
  int r; 
};
 
void preorder(int);
void inorder(int);
void postorder(int);
 
  
struct Node T[MAX];
   
int main(){
  int i,j,a,b,n;
   
  scanf("%d",&n); 
   
  for(i=0;i<n;i++){
    T[i].y=N;
    T[i].l=N;
    T[i].r=N;
  }
   
  for(i=0;i<n;i++){
    scanf("%d",&a); 
   
    for(j=0;j<2;j++){
      scanf("%d",&b); 
   
      if(j==0){
    T[a].l=b;  
      } else {
    T[a].r=b;
      }
    T[b].y=a;       
    }
  }
   
  for(i=0;i<n;i++){
    if(T[i].y==N){
      a=i;
      break;
    }
  }
   
  printf("Preorder\n");
  preorder(a);
  printf("\nInorder\n");
  inorder(a);
  printf("\nPostorder\n");
  postorder(a);
  printf("\n");
    
  return 0;
}
 
void preorder(int x){
   
  printf(" %d",x);
  if(T[x].l!=N) preorder(T[x].l);
  if(T[x].r!=N) preorder(T[x].r);
   
}
   
void inorder(int y){
   
  if(T[y].l!=N) inorder(T[y].l);
  printf(" %d",y);
  if(T[y].r!=N) inorder(T[y].r);
}
   
void postorder(int z){ 
    
  if(T[z].l!=N) postorder(T[z].l);
  if(T[z].r!=N) postorder(T[z].r);
  printf(" %d",z);
   
}

Measured memory_bytes: 616
#include <iostream>
#include <cstdio>
using namespace std;
int a[200];
int b[200];
int c[200];
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        for(int i=0; i<N; i++)
            scanf("%d",&a[i]);
        for(int i=0; i<N; i++)
            scanf("%d",&b[i]);
        int min1=0;
        int a1,b1;
        a1=a[0];
        b1=0;
        for(int i=0; i<N; i++)
            b1=b1+b[i];
        for(int i=0; i<N; i++)
        {
            int K=a1+b1;
            if(K>min1)
                min1=K;
            a1=a1+a[i+1];
            b1=b1-b[i];
        }
        printf("%d\n",min1);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])cout << "Yes";
	else cout << "No";
}

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

int snk[110];
int N, K;

int main(){
    cin >> N >> K;
    memset(snk, 0, sizeof(snk));

    for(int i = 0; i < K; i++){
        int D;
        cin >> D;
        for(int d = 0; d < D; d++){
            int A;
            cin >> A;
            snk[A - 1]++;
        }
    }
    int res = 0;
    for(int i = 0; i < N; i++){
        if(!snk[i]) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b;
	char c;
	cin >> a >> c >> b;
	if(c == '+')cout << a + b;
	else cout << a - b;
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	int h, w, m;
	cin >> h >> w >> m;
	int row[h + 1] = {};
	int col[w + 1] = {};
	map <pair<int, int>, bool> mp;
	while (m--) {
		int r, c;
		scanf("%d %d", &r, &c);
		++row[r];
		++col[c];
		mp[{r, c}] = true;
	}

	vector <int> roww, coll;
	int mx = 0;
	for (int i = 1; i <= h; ++i)
		mx = max(mx, row[i]);
	for (int i = 1; i <= h; ++i)
		if (row[i] == mx)
			roww.pb(i);
	int ans = mx;

	mx = 0;
	for (int i = 1; i <= w; ++i)
		mx = max(mx, col[i]);
	for (int i = 1; i <= w; ++i)
		if (col[i] == mx)
			coll.pb(i);
	ans += mx;

	int temp = 1;

	for (int a : roww)
		for (int b : coll)
			if (!mp.count({a, b})){
				temp = 0;
				break;
			}
	cout << ans - temp << endl;

}

Measured memory_bytes: 28624
INF = 10**10
N = int(input())
S = [list(input()) for _ in range(N)]
seti = set()
for i in S:
  if not seti:
    seti = set(i)
  else:
    seti &= set(i)
ans = {}
for i in seti:
  ans.setdefault(i, INF)
  for j in S:
    ans[i] = min(ans[i], j.count(i))

ans_sorted = sorted(ans.items(), key=lambda x:x[0])

ret = ""
for k, v in ans_sorted:
  ret += k * v
print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(void){
    int n,cnt1 = 0,cnt2 = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < n;i++){
        if(s[i] == 'R') cnt1++;
        else cnt2++;
    }
    if(cnt1 > cnt2)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//                                  _                 ______   ______   ______   ______
//                                 | |               |  __  | |  __  | |  __  | |____  |
//    __ _   ____    _____    _  _ | |____           | |__| | | |__| | | |__| |      | |
//  / _` | |  __| /  __  |  / _` | |  __  |          |____  | |____  | |____  |      | |
// | (_| | | |    | |  | | | (_| | | |__| |  ______   ____| |  ____| |  ____| |      | |
//  \__,_| |_|    |_|  |_|  \__,_| |______| |______| |______| |______| |______|      |_|

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

#define ll long long
#define endl '\n'
#define REP(i, n) for(int i=0; i<n; i++)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9+7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  ll n, i;
  cin >> n;
  ll sum = 0, x = 0;

  for (i = 1; i <= n; i++){
    if(i%15 == 0)
      x += i;
    else if(i%3 == 0)
      x += i;
    else if(i%5 ==0)
      x += i;
    else
      sum += i;
  }

  cout<< sum <<endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int a,b;
  cin >> a >> b;
  int idx = b - a;
  int height = 0;
  srep(i,1,idx) {
    height += i;
  }
  cout << height - a<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
//constant
const double    EPS     = 1e-10;
const double    PI      = acos(-1.0);
const int       INFTY   = (1<<21);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main() {
    ll n; cin >> n;
    vll a, b;
    REP(i, n) {
        ll e; cin >> e;
        a.push_back(e);
    }
    REP(i, n) {
        ll e; cin >> e;
        b.push_back(e);
    }
    ll need = 0, have = 0;
    REP(i, n) {
        if (b[i] < a[i]) need += a[i] - b[i];
        else have += (b[i] - a[i]) / 2;
    }
    TFOUT(have - need >= 0, "Yes", "No");
}

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

int H;

void maxHeapify(int *A,int i){
    int l=2*i,r=l+1,max;
    if(l<=H && A[l]>A[i]) max=l;
    else max=i;
    if(r<=H && A[r]>A[max]) max=r;

    if(max!=i){
        int t=A[i];
        A[i]=A[max];
        A[max]=t;
        maxHeapify(A,max);
    }
}

void buildMaxHeap(int *A){
    int i;
    for(i = H/2;i>0;i--)
        maxHeapify(A, i);
}

int main(void){
    scanf("%d",&H);
    int i,*A=malloc(sizeof(int)*(H+1));
    for(i=1;i<=H;i++)
        scanf("%d",A+i);
    buildMaxHeap(A);

    for(i=1;i<=H;i++)
        printf(" %d",A[i]);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>
int h,w,a,b,i,j;
int main(){
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for(i=h;i--;){
        for(j=w;j--;){
            if(j<a&&i<b||j>=a&&i>=b)printf("1");
            else printf("0");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int H,W;
          
        H = in.nextInt();
        W = in.nextInt();
          
        while(H!=0 || W!=0){
             
            char[][] sharps = new char[H][W];
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    sharps[i][j] = '#';
                }
            }
             
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    System.out.print('#');
                }
                System.out.println();
            }
            System.out.println();
            H = in.nextInt();
            W = in.nextInt();
        }
    }
}


Measured memory_bytes: 35536
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin >> n;
  vector<ll> va(n),vb(n),vc(n);
  for (int i=0;i<n;++i)cin>>va[i];
  for (int i=0;i<n;++i)cin>>vb[i];
  for (int i=0;i<n;++i)cin>>vc[i];

  sort(va.begin(),va.end());
  sort(vb.begin(),vb.end());
  sort(vc.begin(),vc.end());
  ll cnt =0;
  for(int i=0;i<vb.size();++i) {
    ll a = lower_bound(va.begin(),va.end(),vb[i])-va.begin();
    ll c = upper_bound(vc.begin(),vc.end(),vb[i])-vc.begin();
    cnt += a*(n-c);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define pds pair<double, string>
using namespace std;

int paz[11][6];
int h;

bool check() {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < 3; j++) {
            if (paz[i][j] == -1) continue;
            if (paz[i][j] == paz[i][j + 1] && paz[i][j] == paz[i][j + 2])
                return true;
        }
    }
    return false;
}

void fall() {
    for (int i = 0; i < 5; i++) {
        for (int j = h - 1; j >= 1; j--) {
            if (paz[j][i] == -1) {
                int k = j - 1;
                while (k >= 0 && paz[k][i] == -1) k--;
                if (k != -1) {
                    paz[j][i] = paz[k][i];
                    paz[k][i] = -1;
                }
            }
        }
    }
}

int main() {
    while (cin >> h, h) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < 5; j++) {
                cin >> paz[i][j];
            }
        }
        int score = 0;
        while (check()) {
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < 3; j++) {
                    if (paz[i][j] == -1) continue;
                    if (j == 0) {
                        int cur = paz[i][j], k;
                        for (k = 1; k < 5; k++) {
                            if (cur != paz[i][k]) break;
                        }
                        if (k > 2) {
                            score += cur * (k - j);
                            for (int l = 0; l < k; l++) paz[i][l] = -1;
                        }
                    } else if (j == 1) {
                        int cur = paz[i][j], k;
                        for (k = 2; k < 5; k++) {
                            if (cur != paz[i][k]) break;
                        }
                        if (k > 3) {
                            score += cur * (k - j);
                            for (int l = 1; l < k; l++) paz[i][l] = -1;
                        }
                    } else if (j == 2) {
                        int cur = paz[i][j], k;
                        for (k = 3; k < 5; k++) {
                            if (cur != paz[i][k]) break;
                        }
                        if (k > 4) {
                            score += cur * (k - j);
                            for (int l = 2; l < k; l++) paz[i][l] = -1;
                        }
                    }
                }
            }
            fall();
        }
        cout << score << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
let pn = 1000000007

let pow m n =
  let rec doit m n acc =
    if n = 0 then acc
    else if n mod 2 = 0 then doit (m * m) (n / 2) acc
    else doit m (n - 1) (acc * m) in
  doit m n 1

let str_fold_left f init s =
  let n = String.length s in
  let rec doit i acc =
    if i = n then acc
    else doit (i + 1) (f acc s.[i]) in
  doit 0 init

let () =
  let p = read_line () in
  let t = read_line () in
  let n = String.length p in
  let m = String.length t in
  let h = Array.make (n + 1) 0 in
  String.iteri (fun i c -> h.(i+1) <- h.(i)*pn + Char.code c) p;
  let ht = str_fold_left (fun acc c -> acc*pn + Char.code c) 0 t in
  let x = pow pn m in
  for i = m to n do
    if h.(i) - h.(i-m)*x = ht then Printf.printf "%d\n" (i - m);
  done

Measured memory_bytes: 14372
#include <stdio.h>

int main() {
	int a, b;
	int ch;
	int count;
	scanf("%d %d", &a, &b);
	ch = a < b ? a : b;
	count = a > b ? a : b;
	for(count -= 1; count >= 0; count--) {
		printf("%d", ch);
	}
	putchar('\n');
	return 0;
}
	

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

#define m ((L+R)>>1)
#define S(x,y) (2*Sin[x]*Sin[y]*Sin[n-x-y])

using namespace std;
typedef double db;
typedef long long LL;
const db pi = 3.14159265358979323846;

db o, l = 0, r = sqrt(3) * 3 / 4;
db Sin[200050];
LL n,k,p,q,L,R;
int main() {
	cin >> n >> k;
	cout << setprecision(50);
	if (n%3==0 && k>1LL*n*(n-1)*(n-2)/6-n/3)
		return printf("%.15lf\n",r), 0;
	k = k / n + (k%n>0);
	
	for (int _=1;_<=n;_++) Sin[_] = sin(_*pi/n);
	
	for (;;) {
		db mid = (l + r) / 2;
		p = 0, q = 0, o = 0;
		for (int _=1;_<=n/3;_++) {
			if (S(_,_) > mid) break;
			L = _, R = (n-_)/2 + 1;
			while (R-L>1) {
				(S(_,m) < mid) ? L = m : R = m;
			} 
			if (o < S(_,m)) o = S(_,m), q = 1 + (m!=_&&m*2!=n-_);
			p += 2 * (m-_) + 1 - (m*2==n-_);
		}
		if (k<=p && p-q<k) break;
		if (p < k) l = mid; else r = mid;
	}
	printf("%.15lf\n",o);
	return 0;
} 

Measured memory_bytes: 768
// Problem : B - FizzBuzz Sum
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

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

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define vi vector<int>
#define vvi vector< vector <int> >
#define vpii vector< pair<int, int> >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back

#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'

void printv(vector<int>  v){
	for(int i=0;i<v.size();i++) cout<<v[i]<<' '; 
	cout<<endl;
	}

int be(int m , int n, int mod) {
	int res=1;
	while(n){
	     if(n%2!=0) { res*=m; res%=mod; }
	     m*=m;   m%=mod;   n/=2;
	}
	return res;
     }

void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}


int32_t main ()
{
  //ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
int t=1; 
//cin>>t; 
  while(t--){
int n; cin>>n;
int sum=0;
f(i,1,n){
	if(i%3!=0 && i%5!=0)
	sum+=i;
}
cout<<sum<<endl;
   
  }
 
}








Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = readline().rstrip()
S = list(N)
bnk = len(N)-1
for i in range(2**bnk):
    op = ["-","-","-"]
    for j in range(bnk):
        if ((i>>j)&1):
            op[bnk-j-1] = "+"
    tmp = ""
    for k in range(3):
        tmp += S[k]+op[k]
    tmp = tmp+S[3]
    if eval(tmp)==7:
        print(tmp+"=7")
        break

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int left_count = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		char x = s.at(i);
		if (x == '(')left_count++;
		else {
			if (left_count >= 1)left_count--;
			else ans++;
		}
	}
	for (int i = 0; i < ans; i++)cout << "(";
	cout << s;
	for (int i = 0; i < left_count; i++)cout << ")";
	cout << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

const LL M=1e9;
int main() {
	LL low=1;
	LL hi=10;
	char a;
	while(1){
		if(low==M){
			int v=1;
			while(v<M){
				cout << "? " << v+1 << endl;
				cin >> a;
				if(a=='Y'){
					break;
				}
				v*=10;
			}
			cout << "! " << v << endl;
			break;
		}
		cout << "? " << hi << endl;
		cin >> a;
		if(a=='N'){
			hi--;
			while(low+1<hi){
				LL m=(low+hi)/2;
				cout << "? " << m*10 << endl;
				cin >> a;
				if(a=='Y'){
					hi=m;
				}
				else{
					low=m;
				}
			}
			cout << "! " << hi << endl;
			break;
		}
		low*=10;
		hi*=10;
	}

	return 0;
}



Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int fn(string S,char c,int cn){
	string S2(S.length()-1,'a');
	bool flug=false;

	REP(i,(int)S.length()) if(S[i]!=c) flug=true;
	
	if(flug){
		REP(i,(int)S.length()-1){ 
			if(S[i]==c||S[i+1]==c) S2[i]=c;
			else S2[i]=S[i];
		}
		return fn(S2,c,cn+1);
	}else{
		return cn;
	}
}

int main(void){
	string S;
	int min=INF;
	
	cin>>S;
	REP(i,(int)S.length()) chmin(min,fn(S,S[i],0));
	print(min);

	return 0;
}




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

int main() {
    int n;
    cin >> n;
    vector<int> p(n,0);
    rep(i,n){
        cin >> p[i];
    }
    int ans = 0;
    rep(i,n-2){
        if((p[i+1] != min({p[i],p[i+1],p[i+2]})) &&  (p[i+1] != max({p[i],p[i+1],p[i+2]}))){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int H,W;
  while(cin>>H>>W){
    if(H==0&&W==0) break;
    for(int i=0;i<H;i++){    
      if(i==0||i==H-1){
	for(int j=0;j<W;j++)  cout << "#";      
	cout << endl;
      }
      else{ 
	cout << "#";
	for(int k=0;k<W-2;k++) cout << ".";
	cout << "#";
	cout << endl;	
      }
    }
    cout << endl;
  }
  return 0;  
}

Measured memory_bytes: 1152
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int A, B, C;
    cin >> A >> B >> C;

    vector<int> V;
    V.push_back(A);
    V.push_back(B);
    V.push_back(C);

    sort(ALL(V));

    int diff0 = V[2] - V[0];
    int diff1 = V[2] - V[1];
    int sum = diff0 + diff1;

    if(sum % 2 == 0){
        p(sum / 2);
    }else{
        p(sum / 2 + 2);
    }
    
    return 0;
}

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

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int n; cin >> n;
	vector<int> v(n, INF);
	for (int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		*lower_bound(v.begin(), v.end(), a) = a;
	}
	cout << find(v.begin(), v.end(), INF) - v.begin() << endl;
	return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			if(1 <= A && A <= 9 && 1 <= B && B <= 9) {
				System.out.println(A * B);
			}else {
				System.out.println(-1);
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	n, _ := strconv.Atoi(input())
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = input()
	}

	cnt := make(map[string]int)
	for i := 0; i < n; i++ {
		cnt[s[i]]++
	}

	maxCnt := 0
	for _, v := range cnt {
		maxCnt = max(maxCnt, v)
	}

	ans := make([]string, 0, n)
	for k, v := range cnt {
		if v == maxCnt {
			ans = append(ans, k)
		}
	}
	sort.Strings(ans)

	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 27520
from collections import deque

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

black_idx = []
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            black_idx.append([h,w])

distance = [[float("inf")]*W for _ in range(H)]
for b in black_idx:
    distance[b[0]][b[1]] = 0

d = deque(black_idx)
ans = 0

while d:
    y, x = d.popleft()
    for new_y, new_x in ([y+1, x], [y, x+1], [y-1, x], [y, x-1]):
        if 0 <= new_y <= H-1 and 0 <= new_x <= W-1 and distance[y][x] + 1 < distance[new_y][new_x]:
            distance[new_y][new_x] = distance[y][x] + 1
            ans = max(ans, distance[y][x] + 1)
            d.append([new_y, new_x])

print(ans)

Measured memory_bytes: 184192
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
 
int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));
 
  double dret = 1;
  ll ret = 1;
  rep(i,N){
    ret *= v[i];
    dret *= v[i];
    if(dret > 1e20) dret = 1e20;
  }

  if(dret < 1e19 && ret <= 1000000000000000000LL){
    cout << ret << endl;
  }else{
    cout << -1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4268
n, k = map(int,input().split())
s = list(input())

if s[k-1] == "A":
    s[k-1] = "a"
if s[k-1] == "B":
    s[k-1] = "b"
if s[k-1] == "C":
     s[k-1] = "c"
print("".join(s))

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int a,b,c;
    cin>>a>>b>>c;
    int cnt=0;
    if(a%2!=0 || b%2!=0 || c%2!=0)
    {
        cout<<0<<endl;
        exit(0);
    }
    if(a==b && b==c && c==a)
    {
        cout<<-1<<endl;
        exit(0);
    }
    while(a%2==0 && b%2==0 && c%2==0)
    {
//        if(a==b && b==c && c==a)
//        {
//            cout<<-1<<endl;
//            exit(0);
//        }
        int A,B,C;
        A=(c+b)/2;
        B=(a+c)/2;
        C=(b+a)/2;
        a=A;
        b=B;
        c=C;
        cnt++;

    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  int n,m; cin >> n >> m;
  priority_queue<pair<ll,ll>> p;
  //vector<pair<ll, ll>> p(m);
  rep(i,0,n){ 
    ll a;
    cin >> a;
    p.emplace(a,1);
  }
  rep(i,0,m){
     ll b,c;
     cin >> b >> c;
     p.emplace(c,b);
  } 
  ll ans=0, cnt=n;
  while(cnt){
    ans+=p.top().first*min(p.top().second,cnt);
    cnt-=min(p.top().second,cnt);
    p.pop();
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
my $N = map {$_ + 0} split(/ /o, <STDIN>);
my @A;
my $j = 0;
foreach my $i ( map {$_ + 0} split(/ /o, <STDIN>) ) {
  my $ii = $i - 1;
  $A[$ii] = $j;
  $j++;
}
print join(" ", map {$_ + 1} @A);

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

using namespace std;

int main(){
	long long int a,b,k;	
	cin >> a >> b >> k;
	if(a==0 && b==0) { cout << "0 0" << endl; return 0; }
	if(a<=k) {
		k-=a;
		a=0;
		if(b<=k) b=0;
		else b-=k;
		cout << a << " " << b << endl;
		return 0;
	}
	a-=k;
	cout << a << " " << b << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	ll a[n];
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	ll x, y;
	x = y = 0;
	int color[h][w];
	for(int i = 0 ; i < h ; i ++){
		for(int j = 0 ; j < w ; j ++){
			color[i][j] = 0;
		}
	}
	int inc = 1;
	for(int i = 0 ; i < n ; i ++){
		while(a[i]-- and y < w){
			if(x >= 0 and  y >= 0  and x < h and y < w){
				// cout << x << " " << y << endl;
				color[x][y] = i + 1;
				if(inc)
					x++;
				else{
					x--;
				}
			}else{
				if(inc){
					inc = 0;
					x--;
				}else{
					inc = 1;
					x++;
				}
				y++;
				a[i]++;
			}
		}
	}
	for(int i = 0 ; i < h ;i ++){
		for(int j = 0 ; j < w ; j ++){cout << color[i][j] << " ";}cout << endl;
	}

}

Measured memory_bytes: 384
#include<iostream>
#include<queue>
using namespace std;
priority_queue<int> q1;
int main(){
	int i,j;
	for(i=0;i<10;i++){
		cin>>j;
		q1.push(j);
	}
	for(i=0;i<3;i++){
		cout<<q1.top()<<endl;
		q1.pop();
	}
	return 0;
}

Measured memory_bytes: 1212
H,W,M=map(int,input().split())

HSum=[0 for _ in range(H)]
WSum=[0 for _ in range(W)]


bombs = set()
for _ in range(M):
	hi,wi = map(lambda x:int(x)-1,input().split())
	HSum[hi] += 1
	WSum[wi] += 1
	bombs.add( (hi,wi) )
# print(HSum)
# print(WSum)



curMax = 0

## 計算量多すぎ。。
# for h in range(H):
# 	for w in range(W):
# 		tmp = HSum[h] + WSum[w]
# 		if curMax <= tmp:
# 			if (h,w) in bombs:
# 				tmp -= 1
# 			curMax = max( curMax, tmp )

hMax = max(HSum)
wMax = max(WSum)
tmpMax = hMax + wMax

ans = 0

hSumMaxOnly = [h for h, x in enumerate(HSum) if x == hMax]
wSumMaxOnly = [w for w, y in enumerate(WSum) if y == wMax]

for h in hSumMaxOnly:
	if ans == tmpMax:
		break
	for w in wSumMaxOnly:
		if (h,w) in bombs:
			ans = tmpMax - 1
		else:
			ans = tmpMax
			break



print(ans)


Measured memory_bytes: 83436
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	vector<vi> c(3,vi(3));
	for(auto &i:c)for(auto &j:i)cin>>j;
	int a1,a2,a3,b1,b2,b3;
	for(a1=0;a1<101;a1++) {
		b1=c[0][0]-a1;
		for(a2=0;a2<101;a2++){
			b2=c[1][1]-a2;
			for(a3=0;a3<101;a3++) {
				b3=c[2][2]-a3;
				if(c[0][1]==a1+b2&&c[0][2]==a1+b3&&c[1][0]==a2+b1&&c[1][2]==a2+b3&&c[2][0]==a3+b1&&c[2][1]==a3+b2){
					cout<<"Yes";
					return;
				}
			}
		}
	}
	cout<<"No";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3640
import sys

N = int(input())
A = sorted(list(map(int, input().split())))
A = A + [0]
if N == 1:
    print(1)
    sys.exit()
max = A[-2]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i in range(N):
    if memo[A[i]] == 'No':
        continue
    for j in range(A[i], max+1,A[i]):
        memo[j] = 'No'
    if A[i] == A[i+1]:
        continue
    ans += 1
 
print(ans)

Measured memory_bytes: 32360
/**
*    author:  Dooloper
*    created: 03.05.2020 21:01:01
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s == "ABC")cout << "ARC" << endl;
	if(s == "ARC")cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3636
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(input())

    if n % 2:
        print(((n - 1) / 2 + 1) / n)
        sys.exit()
    else:
        print(0.5)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  int n = s.size();

  int ans[n] = {};

  int nextL[n];

  rep(i, n) {
    if (s[i] == 'L') {
      nextL[i] = 0;
    }
  }

  int now = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == 'L') {
      now = 0;
    } else {
      ++now;
      nextL[i] = now;
    }
  }
  /*
  for (int i = 0; i < n; ++i) {
    cerr << nextL[i] << '\n';
  }
  */
  int prevR[n];

  rep(i, n) {
    if (s[i] == 'R') {
      prevR[i] = 0;
    }
  }

  int cur = 0;

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      cur = 0;
    } else {
      ++cur;
      prevR[i] = cur;
    }
  }
  /*
  rep(i, n) {
    cerr << prevR[i] << '\n';
  }
  */
  rep(i, n) {
    if (s[i] == 'L') {
      if (prevR[i] & 1) {
        ++ans[i - prevR[i] + 1];
      } else {
        ++ans[i - prevR[i]];
      }
    } else {
      if (nextL[i] & 1) {
        ++ans[i + nextL[i] - 1];
      } else {
        ++ans[i + nextL[i]];
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << '\n';

  return 0;
}

Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;

int main(){
   ll n;
   cin >> n;
   if(n%2 == 1){
       cout << 0 << endl;
       return 0;
   }

   ll ans = 0;
   n /= 10;
   ans += n;
   while(n >= 5){
       n /= 5;
       ans += n;
   }
   cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

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

    // solve
    vector<vector<int>> next(60, vector<int>(N));
    vector<vector<ll>> val(60, vector<ll>(N)), all(60, vector<ll>(N));
    for (int v = 0; v < N; ++v) {
        next[0][v] = P[v];
        val[0][v] = all[0][v] = C[v];
    }

    for (int d = 0; d + 1 < 60; ++d) {
        for (int v = 0; v < N; ++v) {
            next[d+1][v] = next[d][next[d][v]];
            val[d+1][v] = val[d][v] + val[d][next[d][v]];
            all[d+1][v] = max(all[d][v], val[d][v] + all[d][next[d][v]]);
        }
    }
    ll res = -INF;
    for (int v = 0; v < N; ++v) {
        ll sum = 0;
        ll offset = v;
        for (int d = 59; d >= 0; --d) {
            if (K & (1LL<<d)) {
                res = max(res, sum + all[d][offset]);
                sum += val[d][offset];
                offset = next[d][offset];
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	//student
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	//point
	vector<int> c(m);
	vector<int> d(m);
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}

	vector<int> ans(n);
	int sum=0,minv=2147483647;
	for (int i = 0; i < n; i++) {
		minv = 2147483647;
		for (int j = 0; j < m; j++) {
			sum = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			//cout << sum << endl;
			if(sum==minv){
				continue;
			}else if (min(minv, sum) == sum) {
				minv = min(minv, sum);
				ans[i] = j;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] + 1 << endl;
	}

}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
	int a, L;
	char buf[32] = "";

	while(scanf("%d%d", &a, &L), L){
		map<int,int> mp;
		mp[a] = 0;

		int i;
		for(i = 1; ; ++i){
			sprintf(buf, "%0*d", L, a);
			sort(buf, buf + L);
			int x = strtol(buf, 0, 10);
			reverse(buf, buf + L);
			int y = strtol(buf, 0, 10);
			a = y - x;

			if(!mp.insert(make_pair(a, i)).second){
				break;
			}
		}

		int j = mp[a];
		printf("%d %d %d\n", j, a, i - j);
	}
}

Measured memory_bytes: 1076
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
		int A=in.nextInt();
		int B=in.nextInt();
		int C=in.nextInt();
		if((A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) | (A==7 && B==5 && C==5))
			System.out.println("YES");
		else
			System.out.println("NO");
	}	
}

Measured memory_bytes: 27076