akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

struct State {
  int considered = 0;
  int64_t amount = 0;
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  const int64_t MOD = std::pow(10, 9) + 7;
  std::string s;
  cin >> n >> s;
  int64_t count[26] = {};
  int64_t result    = 0;
  for (auto c : s) {
    count[c - 'a']++;
  }

  for (int begin = 0; begin < 26; begin++) {
    std::queue<State> q;
    State origin;
    origin.considered = begin;
    origin.amount     = count[begin];
    q.push(origin);
    while (!q.empty()) {
      State target = q.front();
      q.pop();
      if (target.considered == 25) {
        result = (result + target.amount) % MOD;
      } else {
        State added = target;
        added.considered++;
        added.amount *= count[added.considered];
        added.amount = added.amount % MOD;
        q.push(added);
        State not_added = target;
        not_added.considered++;
        q.push(not_added);
      }
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 553416
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#define MN 300000
typedef std::pair<int,int> pii;

int h,w,m;
int cx[MN+5],cy[MN+5],mx=0,my=0;
std::set<pii> s;
std::vector<int> vx,vy;

int main(){
	scanf("%d%d%d",&h,&w,&m);
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		cx[x]++;
		cy[y]++;
		s.insert(pii(x,y));
	}
	for(int i=1;i<=h;i++)
		mx = std::max(mx,cx[i]);
	for(int i=1;i<=w;i++)
		my = std::max(my,cy[i]);
	for(int i=1;i<=h;i++)
		if(cx[i]==mx) vx.push_back(i);
	for(int i=1;i<=w;i++)
		if(cy[i]==my) vy.push_back(i);
	for(int i=0;i<vx.size();i++)
		for(int j=0;j<vy.size();j++)
			if(s.find(pii(vx[i],vy[j]))==s.end()){
				printf("%d\n",mx+my);
				return 0;
			}
	printf("%d\n",mx+my-1);
}


Measured memory_bytes: 23396
#include<bits/stdc++.h>
#define mod 1000000007L
using namespace std;

int main()
{
  int h, w;
  scanf("%d%d", &h, &w);
  char c[h][w];
  for(int i = 0; i < h; i++)
  {
    scanf("%s", c[i]);
  }
  long long dp[h + 1][w + 1];
  memset(dp, 0, sizeof dp);
  dp[1][1] = 1;
  for(int row = 1; row <= h; row++)
  {
    for(int col = 1; col <= w; col++)
    {
      if(c[row - 1][col - 1] == '#')
        dp[row][col] = 0;
      else
        dp[row][col] += dp[row - 1][col] + dp[row][col - 1];
      if(dp[row][col] >= mod)
        dp[row][col] -= mod; 
    }
  }
  printf("%lld", dp[h][w]);
  
  return 0;
}


Measured memory_bytes: 9088
A,B=map(int,input().split())
C,D=map(int,input().split())
E,F=map(int,input().split())
hoge=[]
no=0
hoge.append(A)
hoge.append(B)
hoge.append(C)
hoge.append(D)
hoge.append(E)
hoge.append(F)
if(hoge.count(1)==0):
  no=1
if(hoge.count(2)==0):
  no=1
if(hoge.count(3)==0):
  no=1
if(hoge.count(4)==0):
  no=1
if(hoge.count(1)==3):
  no=1
if(hoge.count(2)==3):
  no=1
if(hoge.count(3)==3):
  no=1
if(hoge.count(4)==3):
  no=1
if(no==1):
  print("NO")
else:
  print("YES")

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

const double pi = acos(-1);

int main ()
{
    int  a[10000],b[10000],c[10000],cnt;
    char op[10000];
    for(int i=0;i<10000;i++){
        cin >> a[i] >> op[i] >> b[i];
        
        if(op[i]=='+')  c[i]=a[i]+b[i];
        if(op[i]=='-')  c[i]=a[i]-b[i];
        if(op[i]=='*')  c[i]=a[i]*b[i];
        if(op[i]=='/')  c[i]=a[i]/b[i];
        if(op[i]=='?') break;
        cnt++;
    }
    
   for(int i=0;i<cnt;i++) cout << c[i] << endl;

    
}



Measured memory_bytes: 3108
n = int(input())
A = [int(input()) for _ in range(n)]
# print(A)
mf = max(A)
cnt_mf = A.count(mf)

if cnt_mf > 1:
    for _ in range(n):
        print(mf)
    exit()

Aset = set(A)
# print(Aset - {mf})
ms = max((Aset - {mf}))
# print(ms)

for e in A:
    if e != mf:
        print(mf)
    else:
        print(ms)


Measured memory_bytes: 19208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

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

    if (a >= 13)
    {
        cout << b << endl;
    }
    else if (a >= 6)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
inline void chmin(double &a, double b){if(a > b) a = b;}

int N, M;
vector<vector<int> > G;
void input(){
    fast_io();
    cin >> N >> M;
    G.resize(N);
    for (int i = 0; i < M; i++)
    {
        int s,t; cin >> s >> t;
        s--, t--;
        G[s].push_back(t);
    }
    for (int i = 0; i < N; i++) sort(G[i].begin(),G[i].end(),greater<int>());
}

int solve(){
    vector<double> dp(N,0);
    dp[N-1] = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        for(auto t:G[i]){
            dp[i] += (dp[t]+1)/G[i].size();
        }
    }
    double ans = dp[0];

    for (int i = N - 1; i >= 0; i--)
    {
        if(G[i].size()<=1) continue;
        // N-1に到達できないようなカットはしない.
        double dp_max = 0;
        int cut_idx = 0;
        for(auto t:G[i]){
            if(dp[t] > dp_max){
                cut_idx = t;
                dp_max = dp[t];
            }
        }
        // i->tのうちdp[t]が最大のものの辺をカットする
        // カットするindexをcut_idxとする
        vector<double> dp_i(N, 0);
        for (int s = N-1; s >= 0; s--)
        {
            for(auto t:G[s]){
                if(s==i && t==cut_idx) continue;
                if(s==i) dp_i[s] += (dp_i[t]+1)/(G[s].size()-1);
                else dp_i[s] += (dp_i[t]+1)/(G[s].size());
            }
        }
        chmin(ans, dp_i[0]);
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4668
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
a.sort()
d = deque(a)
seq = []
for i in range(n-2):
    l = d.popleft()
    r = d.pop()
    r2 = d.pop()
    if r2>0:
        seq.append((l,r2))
        d.appendleft(l-r2)
        d.append(r)
    else:
        seq.append((r,r2))
        d.appendleft(l)
        d.append(r-r2)

bb = d.pop()
aa = d.pop()
seq.append((bb,aa))
print(bb-aa)
for i in range(n-1):
    print("{} {}".format(seq[i][0], seq[i][1]))


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

int main()
{
  int k, n;
  cin >> k >> n;
  int idx = n - (k - 1);
  for(int i = 0; i < 2 * k - 1; i++)
  {
    if(i) cout << ' ';
    cout << idx + i;
  }
  cout << endl;
  return 0;
    
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AISing
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int H = int.Parse(Console.ReadLine());
            int W = int.Parse(Console.ReadLine());

            Console.WriteLine((N - H + 1) * (N - W + 1));
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m;
    cin >> n >> m;
    string s, p = string(m+2, '#');
    cout << p << endl;
    while (n--) {
        cin >> s;
        cout << '#' << s << '#' << endl;
    }
    cout << p << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;
int mo[200200];

signed main() {
    cin >> N >> K;
    int ans = 0;
    rep(i, K) {
        mo[i] = N / K + ((N - N / K * K) >= i);
    }
    mo[0]--;
    mo[K] = mo[0];
    rep(i, K) {
        if ((2 * (K - i)) % K == 0) {
            ans += mo[i] * mo[K - i] * mo[K - i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

string K;
int D, N;

int64_t dp[10001][100][2];

int64_t rec(int d, int r, bool less){
    if(d >= N) return (r==0);
    if(dp[d][r][less] >= 0) return dp[d][r][less];
    int64_t result = 0;
    for(int k=0; k<=(less ? 9 : K[d] - '0'); k++){
        add(result, rec(d+1, (r+k)%D, less | (k < K[d]-'0')));
    }
    dp[d][r][less] = result;
    return result;
}

int main(){
    cin >> K >> D;
    N = K.size();
    memset(dp, -1, sizeof(dp));
    cout << (rec(0, 0, 0) + MOD - 1) % MOD << endl;
    return 0;
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long
#define float long double


int32_t main()
{
	IOS
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(m<4 || (m==4&&d<=30) )cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
}
	
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 256
from collections import deque
N, M, K = map(int,input().split())
friendlist = [[] for _ in range(N+1)]
for n in range(M):
    A, B = map(int,input().split())
    friendlist[A].append(B)
    friendlist[B].append(A)

blocklist = [[] for _ in range(N+1)]
for n in range(K):
    C, D = map(int, input().split())
    blocklist[C].append(D)
    blocklist[D].append(C)

whatgroup = [-1 for _ in range(N+1)]
visited = [-1] * (N+1)
d = deque()
leaderdic = {}
for person in range(1,N+1):
    d.append(person)
    leader = person
    cnt = 0
    while len(d)>0:
        nowwho = d.popleft()
        if whatgroup[nowwho] != -1:
            continue
        d.extend(friendlist[nowwho])
        whatgroup[nowwho] = leader
        cnt += 1
    if cnt != 0:
        leaderdic[leader] = cnt
for person in range(1,N+1):
    ans = leaderdic[whatgroup[person]]
    ans -= 1
    ans -= len(friendlist[person])
    for block in blocklist[person]:
        if whatgroup[person]==whatgroup[block]:
            ans -= 1
    print(ans)

Measured memory_bytes: 109768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy\n";
    else if(s=="Cloudy")
        cout<<"Rainy\n";
    else
        cout<<"Sunny\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n, k;
	cin >> n >> k;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	for(int i = k; i < n; i++) {
		if(a[i] > a[i - k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 4048
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int M = cin.ReadInt;
            int C = cin.ReadInt;
            int tmp;
            var B = cin.ReadLine.Split(' ');
            int count = 0;

            for(int i=0; i<N; i++){
                tmp = 0;            
                for(int j=0; j<M; j++){
                    tmp += cin.ReadInt * int.Parse(B[j]);
                }
                tmp += C;
                if(tmp > 0) count++;
            }
            WriteLine(count);
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 13268
s=input()
n=len(s)
b=[]
b2=[]
ans=[0 for i in range(n)]

for i in range(n-1):
    if s[i]=='R' and s[i+1]=='L':
        b.append(i)
    if s[i]=='L' and s[i+1]=='R':
        b2.append(i)
       
b2.append(n-1)

cnt=0
for i in range(len(b2)):
    if i==0:
        for j in range(b2[i]+1):
            if (b[i]-j)%2==0:
                ans[b[i]]+=1
            else:
                ans[b[i]+1]+=1
        cnt=b2[i]
    else:
        for j in range(b2[i]-b2[i-1]):
            if (b[i]-cnt-j-1)%2==0:
                ans[b[i]]+=1
            else:
                ans[b[i]+1]+=1
        cnt=b2[i]

for i in range(len(ans)):
    ans[i]=str(ans[i])
print(' '.join(ans))

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

int main() {
  int n,c=0;
  string s;
  cin >>n>>s;
  
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  
  for(int i=0;i<n/2;i++){
    if(s.at(i)==s.at(i+n/2))c++;
  }
  
  if(c==n/2) cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}


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

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
    int n; cin >> n;
    vector<int> l; l.resize(2*n);
    REP(i, 2*n){
        cin >> l[i];
    }
    sort(l.begin(), l.end());

    int ans = 0;
    REP(i, n){
        ans += l[2*i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> red(A);
    vector<ll> green(B);
    vector<ll> nocolor(C);
    rep(i,A){
        cin >> red[i];
    }
    rep(i,B){
        cin >> green[i];
    }
    rep(i,C){
        cin >> nocolor[i];
    }
    sort(all(red));
    sort(all(green));
    sort(all(nocolor));
    vector<ll> allapple(0);
    for (ll i = 1; i <= X; i++){
        allapple.push_back(red[A - i]);
    }
    for (ll i = 1; i <= Y; i++){
        allapple.push_back(green[B - i]);
    }
    rep(i,C){
        allapple.push_back(nocolor[i]);
    }
    sort(all(allapple));
    ll ans = 0;
    ll len = allapple.size();
    for (ll i = 1; i <= X + Y; i++){
        ans += allapple[len - i];
    }
    cout << ans << endl;
}


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

long long koubaisuu(long long a, long long b);
long long koubaisuu2(long long a, long long b);

int main()
{
	long long a, b, c, d,cd,ans[5];
	cin >> a >> b >> c >> d;
	ans[0] = b / c - (a - 1) / c;
	ans[1] = b / d - (a - 1) / d;
	cd = koubaisuu2(c, d);
	ans[2] = b / (cd) - (a - 1) / (cd);
	ans[3] = ans[0] + ans[1] - ans[2];
	cout << b - a + 1 - ans[3];
}

long long koubaisuu(long long a, long long b)
{
	long long aa, bb;
	aa = a;
	bb = b;
	while (aa != bb)
	{
		if (aa > bb) bb += b;
		else aa += a;
	}
	return aa;
}

long long koubaisuu2(long long a, long long b)
{
	long long buffer[2] = { 1,1 };
	if (b > a)
	{
		buffer[0] = a;
		a = b;
		b = buffer[0];
	}
	buffer[0] = a*b;
	while (buffer[1]!=0)
	{
		buffer[1] = a%b;
		a = b;
		b = buffer[1];
	}
	return buffer[0]/a;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REP_(i, a, b) for(int i = a; i <= b; i++)
#define sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
const int maxn = 1e4;
int p[maxn][maxn];
int n,t, x, y, tt, xx, yy;bool flag = true;

int main()
{
    //memset(p, 0, sizeof(p));


	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d%d%d", &tt, &xx, &yy);
		if (abs(xx - x) + abs(yy - y) > (tt - t)|| (abs(xx - x) + abs(yy - y)) % 2 != (tt - t) % 2)
			flag = false;
        //如果无法走一圈直接排除
		t = tt;
		x = xx;
		y = yy;
		//储存上一次的
	}

    /*
    for(int i = 0; i < n; i++)
    {
        scanf("%d%d%d", &t, &x, &y);

        if(x - 0 + y - 0 <= t)
        {
            flag = true;
            if(p[x][y]!=0 && (int)(t - p[x][y])%4 == 0)
            {
                continue;
            }
            else
            {
                flag = false;
            }
        }
        else
        {
            flag = false;

        }
        p[x][y] = t;
    }
    */
    return (flag) ? printf("Yes\n") * 0 : printf("No\n") * 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc =  new java.util.Scanner(System.in);

	public static void main(String[] args) {
		
		int n = sc.nextInt();
		long x = 1 ;
		
		for ( int i = 1 ; i <= n ; i++ ){
			
			 x = x * i ;
			
		}
		
		System.out.println( x );

	}

}

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

int main(){
  int N;
  cin >> N;
  int64_t x,y,z,w;
  int64_t max_z=0;
  int64_t min_z=1e10;
  int64_t max_w=-1e10;
  int64_t min_w=1e10;
  for(int i=0;i<N;i++){
    cin >> x >> y;
    z=x+y;
    w=x-y;
    max_z=max(max_z,z);
    min_z=min(min_z,z);
    max_w=max(max_w,w);
    min_w=min(min_w,w);
  }
  cout << max(max_z-min_z,max_w-min_w) << endl;
  return 0;
}


Measured memory_bytes: 3644
//
//  main.cpp
//  ALDS1_10_C Longest Common Subsequence
//
//  Created by Kang on 2020/8/13.
//  Copyright © 2020 Kang. All rights reserved.
//

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char X[1001];
char Y[1001];

int LCS(int m, int n) {
    int c[1001][1001];
    for (int i = 0; i <= m; i++) {
        c[i][0] = 0;
    }
    for (int i = 0; i <= n; i++) {
        c[0][i] = 0;
    }
    
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i-1] == Y[j-1]) {
                c[i][j] = c[i-1][j-1] + 1;
            }
            else {
                c[i][j] = max(c[i][j - 1], c[i - 1][j]);
            }
            
        }
    }
    return c[m][n];
}

int main(int argc, const char * argv[]) {
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s", X);
        scanf("%s", Y);
        printf("%d\n", LCS((int)strlen(X), (int)strlen(Y)));
    }
    return 0;
}



Measured memory_bytes: 6648
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[float]"):
    dp = []
    for _ in range(0, N + 1):
        L = [0.0] * (N + 1)
        dp.append(L)
    
    dp[1][0] = 1 - p[0]
    dp[1][1] = p[0]

    for i in range(2, N + 1):
        for j in range(0, i + 1):
            if j == 0:
                dp[i][j] = dp[i - 1][j] * (1 - p[i - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1])

    res = 0
    for j in range(0, N + 1):
        if j < N / 2:
            continue
        res += dp[N][j]
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)

if __name__ == '__main__':
    main()


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

#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}

int F[123456];

signed main(){
  int n,k;cin>>n>>k;
  for(int i=1;i<=k;i++){
    F[i]+=i;
    for(int j=i+i;j<=k;j+=i){
      (F[j]-=F[i])%=MOD;
    }
  }
  int ans=0;
  for(int i=1;i<=k;i++){
    ans+=pw(k/i,n)*(MOD+F[i])%MOD;
  }
  cout<<ans%MOD<<endl;
}


Measured memory_bytes: 4392
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    int W,H,N;
    int x[100],y[100],a[100];
    cin>>W>>H>>N;
    for(int i=0;i<N;i++) cin>>x[i]>>y[i]>>a[i];
    int edge[2][2]={{0,0},{W,H}};
    for(int i=0;i<N;i++){
        switch (a[i])
        {
            case 1:
                if(edge[0][0]<x[i]) edge[0][0]=x[i];
                break; 
            case 2:
                if(edge[1][0]>x[i]) edge[1][0]=x[i];
                break;
            case 3:
                if(edge[0][1]<y[i]) edge[0][1]=y[i];
                break;       
            default:
                if(edge[1][1]>y[i]) edge[1][1]=y[i];
                break;
        }
    }
    cout<<max(edge[1][0]-edge[0][0],0)*max(edge[1][1]-edge[0][1],0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    sort(h,h+n);
    int min=999999999;
    for(int i=0;i<=n-k;i++)
    {
        if((h[i+k-1]-h[i])<min)
        min=h[i+k-1]-h[i];
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 640
class City
    attr_accessor :index, :name, :point
    def initialize(index, name, point)
        @index = index
        @name = name
        @point = point
    end
    def to_string
        "[#{@index}] #{@name}: #{@point}"
    end
end
N = gets.to_i
C = Array.new(N)
N.times do |i|
    s,p = gets.split
    city = City.new(i+1, s, p.to_i)
    C[i] = city
end
d = []
N.times do |i|
    if d.empty? then
        d.push C[i]
    else
        f = true
        d.each_with_index do |x, index|
            if C[i].name < x.name then
                d.insert(index, C[i])
                f = false
                break
            elsif C[i].name == x.name
                if C[i].point > x.point then
                    d.insert(index, C[i])
                    f = false
                    break
                end
            end
        end
        d.push C[i] if f
    end
end
d.each do |c|
    puts c.index
end

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

using Pair = pair<int, int>;

int N;
int M;
int g_idx;
char buf[114514];
int par[4145];
int myrank[4145];
bool used[4145];
bool isr[4145][4145];
bool isr2[4145][4145];

vector<int> vs[4145];
vector<int> es[4145];
vector<int> res[4145];
vector<int> bs[4145];
map<string, int> mp;

int root(int v) {
  if (par[v] == v) return v;
  return par[v] = root(par[v]);
}

void unite(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return;
  if (myrank[a] < myrank[b]) par[a] = b;
  else if (myrank[b] < myrank[a]) par[b] = a;
  else {
    par[a] = b;
    myrank[a]++;
  }
}


Pair GetIdx(string &s) {
  auto itr = s.find('-');
  string a;
  a.assign(s, 0, itr);
  string b;
  b.assign(s, itr+1, s.size()-itr-1);
  if (!mp.count(a)) mp[a] = g_idx++;
  if (!mp.count(b)) mp[b] = g_idx++;
  return Pair(mp[a], mp[b]);
}

void dfs1(int v, int k) {
  isr[k][v] = true;
  for (int u : es[v]) {
    if (isr[k][u]) continue;
    dfs1(u, k);
  }
}

void dfs2(int v, int k) {
  for (int dv : vs[root(v)]) {
    if (isr2[k][dv]) return;
  }

  for (int dv : vs[root(v)]) {
    isr2[k][dv] = true;
    for (int u : es[dv]) {
      if (isr2[k][u]) continue;
      dfs2(u, k);
    }
  }
}

int dfs3(int v, int k) {
  if (used[v]) return -1;
  if (v == k) return 0;
  used[v] = true;

  int ret = -1;
  for (int u : bs[v]) {
    ret = max(ret, dfs3(u, k));
  }
  if (ret == -1) return -1;
  //printf("%d %d: %d\n", v, k, ret);
  return ret+1;
}

int main() {
  while (1) {
    scanf("%d", &N);
    if (N == 0) return 0;

    mp.clear();
    g_idx = 0;
    for (int i=0; i<N; i++) {
      scanf("%s", buf);
      string s = buf;
      int a, b;
      tie(a, b) = GetIdx(s);
      bs[a].emplace_back(b);
      bs[b].emplace_back(a);
      es[a].emplace_back(b);
      res[b].emplace_back(a);
    }
    printf("%d\n", g_idx);

    for (int i=0; i<g_idx; i++) {
      par[i] = i;
      myrank[i] = 0;
      for (int j=0; j<g_idx; j++) {
        isr[i][j] = false;
        isr2[i][j] = false;
      }
    }

    for (int i=0; i<g_idx; i++) {
      dfs1(i, i);
    }

    for (int i=0; i<g_idx; i++) {
      for (int u : es[i]) {
        for (int v : es[i]) {
          if (!isr[u][v] && !isr[v][u]) unite(u, v);
        }
      }

      for (int u : res[i]) {
        for (int v : res[i]) {
          if (!isr[u][v] && !isr[v][u]) unite(u, v);
        }
      }
    }

    for (int i=0; i<g_idx; i++) {
      vs[root(i)].emplace_back(i);
    }

    for (int i=0; i<g_idx; i++) {
      dfs2(i, i);
    }
    
    scanf("%d", &M);
    for (int i=0; i<M; i++) {
      scanf("%s", buf);
      string s = buf;
      int a, b;
      tie(a, b) = GetIdx(s);
      //for (int i=0; i<g_idx; i++) used[i] = false;
      //printf("%d %d : %d\n", a, b, dfs3(a, b));
      for (int i=0; i<g_idx; i++) used[i] = false;
      if (isr2[a][b] && dfs3(a, b)%2 == 1) puts("YES");
      else puts("NO");
    }

    for (int i=0; i<g_idx; i++) {
      es[i].clear();
      res[i].clear();
      bs[i].clear();
      vs[i].clear();
    }
  }
}

Measured memory_bytes: 5352
def main():
    a,v=map(int,input().split())
    b,w=map(int,input().split())
    t=int(input())
    distance=abs(a-b)
    ve=v-w
    if ve<=0:
        print("NO")
        return
    if distance<=ve*t:
        print("YES")
        return
    else:
        print ( "NO" )
        return
main()

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(d == 1){
		printf("%d\n", 1);
	}else{
		printf("%d\n", 0);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] pArray = new int [n];
		int pmax = 0, sum = 0;
		for(int i = 0; i < n; i++) {
			pArray[i] = sc.nextInt();
			sum = sum + pArray[i];
			if(pmax <= pArray[i]) pmax = pArray[i];
		}
		System.out.println(sum - (pmax / 2));
		sc.close();
	}
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

using namespace std;
using ll=long long;

ll num[4][1010][1010];
ll sum[4][1010];

int main(void){
	ll d[3],p[3],n;
	rep(i,3) cin >> d[i];
	rep(i,3) cin >> p[i];
	cin >> n;

	num[0][0][0]=1LL;

	rep(cur,3){
		const int nxt=cur+1;
		
		rep(i,1,n) rep(j,n) num[cur][i][(j+1)%n]=num[cur][i-1][j];
		rep(i,n)rep(j,n) sum[cur][j]+=num[cur][i][j];

		ll l=p[cur],r=d[cur]-1-p[cur];

		rep(j,n) num[nxt][0][j]+=(l/n+r/n)*sum[cur][j];
		rep(i,l%n+1)rep(j,n) num[nxt][0][j]+=num[cur][i][j];
		rep(i,r%n+1)rep(j,n) num[nxt][0][j]+=num[cur][i][j];
		rep(j,n) num[nxt][0][j]-=num[cur][0][j];
	}

	rep(i,n) cout << (i?" ":"") << num[3][0][i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 26740
N = int(input())
A = [int(input()) for _ in range(N)]

B = [A[0]]

for i in range(1,N):
    if A[i]<=B[-1]:
        B.append(A[i])
    elif A[i]>B[0]: 
        B[0] = A[i]
    else:
        l = 0
        r = len(B)-1
        while l+1<r:
            c = (l+r)//2
            if B[c]>=A[i]:
                l = c
            else:          
                r = c
        if B[l]<A[i]:
            B[l] = A[i]
        else:
            B[r] = A[i]
print(len(B))


Measured memory_bytes: 56152
s = gets.chomp

m1 = 0
m2 = 0


s.length.times do |i|
  if(i%2 == 0)
    if s[i] == "0"
      m1 += 1
    else
      m2 += 1
    end
  else
    if s[i] == "1"
      m1 += 1
    else
      m2 += 1
    end
  end
end

puts [m1, m2].min


Measured memory_bytes: 1916
def f(a,c):
  b = [a.count(e) for e in a]
  if a!=b: b,c=f(b,c+1)
  return b, c

while int(raw_input())!=0:
  a = map(int,raw_input().split())
  a,c = f(a,0)
  print c
  print " ".join(map(str,a))

Measured memory_bytes: 4208
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<ll> a = inp(n);

    ll ans = 0;
    ll r = 1;
    REP(i, n) {
        if (a[i] == r) {
            r++;
        } else {
            ans++;
        }
    }
    if (ans == n) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    
}

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

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>x(n),y(n),ans(n);
	repp(i, 0, n) {
		cin >> x[i];
		y[i] = x[i];
	}
	sort(y.begin(), y.end());
	repp(i, 0, n) {
		if (x[i] >= y[n / 2])ans[i] = y[n / 2 - 1];
		else ans[i] = y[n / 2];
		cout << ans[i] << endl;
	}
	return 0;
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 1e5 + 100;

int N, M, e, Begin[Maxn], To[Maxn << 1], Next[Maxn << 1];
int deg[Maxn], Dp[Maxn];

inline void add_edge (int x, int y) { To[++e] = y; Next[e] = Begin[x]; Begin[x] = e; ++deg[y];}

inline void Solve ()
{
	queue <int> Q;
	for (int i = 1; i <= N; ++i) if (!deg[i]) Q.push(i);
	int ans = 0;
	while (!Q.empty())
	{
		int x = Q.front(); Q.pop();
		Chkmax(ans, Dp[x]);
		for (int i = Begin[x]; i; i = Next[i])
		{
			int y = To[i];
			Chkmax(Dp[y], Dp[x] + 1);
			--deg[y];
			if (!deg[y]) Q.push(y);
		}
	}
	cout<<ans<<endl;
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	for (int i = 1; i <= M; ++i) { int x = read<int>(), y = read<int>(); add_edge (x, y); }
}

int main()
{
#ifdef hk_cnyali
	freopen("G.in", "r", stdin);
	freopen("G.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


Measured memory_bytes: 2432
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N; cin >> N;
	string res;
	long A[100009]; for (int i = 0; i < N; i++) cin >> A[i];
	long mycount = 0;

	for (int i = 0; i < N; i++) if (A[i] % 2 == 1) mycount++;

	res = (mycount % 2 == 0) ? "YES" : "NO";

	cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;

int main()
{
    int n, m, i, a[100010], idx=0;
    lli dp[100010];
    scanf("%d%d",&n,&m);
    for(i=0; i<m; i++) {
        scanf("%d",a+i);
    }
    dp[0]=1;
    if(a[idx] == 1) {
        dp[1] = 0;
        idx++;
    } else {
        dp[1] = 1;
    }
    for(i=2; i<=n; i++) {
        if(i == a[idx]) {
            dp[i]=0;
            idx++;
        } else {
            dp[i] = (lli)(dp[i-1] + dp[i-2]);
            dp[i] %= MOD;
        }
        //printf("%d: %d\n",i,dp[i]);
    }
    printf("%lld",dp[n]);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int X, Y;
  cin >> X >> Y;
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> p(A);
  rep(i, A) {
    cin >> p[i];
  }
  vector<int> q(B);
  rep(i, B) {
    cin >> q[i];
  }
  vector<int> r(C);
  rep(i, C) {
    cin >> r[i];
  }

  sort(all(p), greater<int>());
  sort(all(q), greater<int>());
  sort(all(r), greater<int>());

  vector<int> m;
  rep(i, X) {
    m.pb(p[i]);
  }
  rep(i, Y) {
    m.pb(q[i]);
  }
  rep(i, C) {
    m.pb(r[i]);
  }

  sort(all(m), greater<int>());
  int ans = 0;
  rep(i, X + Y) {
    ans += m[i];
  }
  cout << ans << endl;
}

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

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

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int c[3][3];
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  int maxi = 0;
  rep(i, 3) rep(j, 3) maxi = max(maxi, c[i][j]);
  maxi++;

  string res = "No";
  rep(k, maxi) rep(m, maxi) rep(n, maxi) {
    int a[3], b[3];
    a[0] = k, a[1] = m, a[2] = n;
    b[0] = c[0][0] - a[0], b[1] = c[1][1] - a[1], b[2] = c[2][2] - a[2];
    bool skip = false;
    rep(i, 3) if (b[i] < 0) skip = true;
    if (skip) continue;
    int cnt = 0;
    rep(i, 3) rep(j, 3) {
      if (c[i][j] != a[i] + b[j]) continue;
      cnt++;
    }
    if (cnt == 9) {
      res = "Yes";
      goto RES;
    }
  }

RES:
  cout << res << endl;
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a - b) % c << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, C, K = map(int, input().split(' '))
T = sorted([int(input()) for _ in range(N)])

buf = []
ans = 0
c, n = C, 0
for t in T:
    if c == C:
        c = 1
        n = t + K
        ans += 1

        # print(buf)
        # buf = [t]

    else:
        if t <= n:
            c += 1
            # buf.append(t)
        else:
            c = 1
            n = t + K
            ans += 1

            # print(buf)
            # buf = [t]

# print(buf)
print(ans)


Measured memory_bytes: 51032
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll c=1e3,cn=1e7,con=1e4;
const ll mod=1e9+7;
int nm,m,cntr=1e9,pos=0,cntr2=0,sum=0,temp;
vector<pair<int,pair<int,int> > >v;
vector<ll>ve;
bool lef[cn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    ll x;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x;
        ve.push_back(x);
    }
    k--;
    sort(ve.begin(),ve.end());
    int mn=1e9,diff=0;
    for(int i=0;i<n;i++){
            if(i+k<n){
        diff=ve[i+k]-ve[i];
       // cout<<diff<<endl;
       mn=min(mn,diff);
    }
    }
    cout<<mn;
    return 0;
}


Measured memory_bytes: 1400
N, M = map(int, input().split())

ans = [0 for i in range(M)]
for i in range(N):
    KM = list(map(int, input().split()))
    for j in range(1, len(KM)):
        ans[KM[j]-1] += 1

count = 0
for i in range(M):
    if ans[i] == N:
        count += 1
        
print(count)

Measured memory_bytes: 9068
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   int n;
   cin>>n;
   vector<int>a(n);
   for(int i=0;i<n;i++)
   	cin>>a[i];
   int ans=0;
   for(int i=1;i+1<n;i++)
   {
   	vector<int>b;
   	b.pb(a[i]);
   	b.pb(a[i-1]);
   	b.pb(a[i+1]);
   	sort(all(b));
   	if(b[1]==a[i])
   		ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int A, B;
    cin >> A >> B;

    int numOfHole = 1;
    int ans = 0;
    while (numOfHole < B) {
        ans++;
        numOfHole--;
        numOfHole += A;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

    int a[n];

	int i;

	rep(i, n) cin >> a[i];

	sort(a, a + n);

	Out(a[n - 1] - a[0]);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;

int main(){
	

	ll n; cin>>n;
	ll ans=0;
	while(true){
		if(n<500){ break; }
		ans+=((n/500)*1000);
		n=n-((n/500)*500);
		//cout<<ans<<" ";
	}
	ans+=((n/5)*5);
	cout<<ans;
  cout<<"\n";
	return 0;
}

Measured memory_bytes: 256