akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const int N = 3e3+3;
ll mem[N][N];
ll pow2[N];
ll ar[N];
ll ans = 0;
ll n,s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	pow2[0] = 1;
	for(int i=1;i<N;i++) pow2[i] = (pow2[i-1]*2ll)%MOD;
	cin >> n >> s;
	for(int i=0;i<n;i++) cin >> ar[i];
	for(int i=0;i<n;i++) mem[i][0] = 2;
	if(ar[0] <= s) mem[0][ar[0]] = 1;
	for(int i=1;i<n;i++) for(int j=0;j<=s;j++){
		if(ar[i] <= j) mem[i][j] = ((2*mem[i-1][j])+mem[i-1][j-ar[i]])%MOD;
		else mem[i][j] = (2*mem[i-1][j])%MOD;
//		cout << i << ' ' << j << " : " << mem[i][j] << '\n';
	}
	cout << mem[n-1][s] << '\n';
}


Measured memory_bytes: 73988
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
    int N,max,t;
    cin >>N;
    vector<int> mt(N);
    for(int i=0;i<N;i++){
        cin >>mt.at(i);
    }
    t=1;
    max=mt.at(0);
    for(int i=1;i<N;i++){
        if(mt.at(i)>=max){
            t +=1;
            max =mt.at(i);
        }
    }
    cout << t <<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int h[N];
    int dp[N];
    for(int i = 0; i < N; i++) cin >> h[i];
    
    dp[0] = dp[1] = 0;
    dp[2] = abs(h[1]-h[0]);
    
    for(int i = 2; i < N; i++){
        dp[i+1] = min(dp[i] + abs(h[i]-h[i-1]), dp[i-1] + abs(h[i] - h[i-2]));
    }
    
    cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll dp[110][100100];

ll solve(int n, int w, vector<int> u, vector<int> v) {
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			if (u[i - 1] <= j) {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j - u[i - 1]] + v[i - 1]);
			} else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	return dp[n][w];
}

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> u(n), v(n);
	rep(i,n) cin >> u[i] >> v[i];
	cout << solve(n, w, u, v) << endl;
}

Measured memory_bytes: 89648
h, w, m = map(int, input().split())
hw = []
h_cnt = [0] * h
w_cnt = [0] * w
hw = []
hw_set = set()
for _ in range(m):
    r, c = map(int, input().split())
    r -= 1
    c -= 1
    h_cnt[r] += 1
    w_cnt[c] += 1
    hw.append((r, c))
    hw_set.add((r, c))
mh = max(h_cnt)
mw = max(w_cnt)
cand_r = []
for i in range(h):
    if h_cnt[i] == mh:
        cand_r.append(i)
cand_c = []
for j in range(w):
    if w_cnt[j] == mw:
        cand_c.append(j)
ans = mh + mw
for i in cand_r:
    for j in cand_c:
        if not (i, j) in hw_set:
            print(ans)
            exit()
print(ans - 1)


Measured memory_bytes: 106880
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.length() == 2) {
            System.out.println(s);
        } else {
            StringBuffer sb = new StringBuffer(s);
            System.out.println(sb.reverse());
        }
    }
}


Measured memory_bytes: 21844
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		string[] strArray = Console.ReadLine().Split(' ').ToArray();
		List<string> ls = new List<string>();
		for(int i = 0;i < strArray.Length; i++)
		{
			if (!ls.Contains(strArray[i]))
			{
				ls.Add(strArray[i]);
			}
		}
		if(ls.Count == 2)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();


Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,res=0;
    string s;
    cin>>n>>s;
    for(ll i=0;i<n-2;i++)
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
    res++;
    cout<<res;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_164_b
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            var ar = ReadIntArray();
            int a_life = ar[0]; // 体力
            int b_attack = ar[1]; // 攻撃力
            int c_life = ar[2]; // 体力
            int d_attack = ar[3]; // 攻撃力

            int f = 0;
            bool end = false;
            string result = "";
            while(! end)
            {
                if (f == 0)
                {
                    f = 1;
                    // 高橋君の攻撃
                    c_life -= b_attack;
                    if (c_life <=0)
                    {
                        // 高橋君の勝ち
                        result = "Yes";
                        end = true;
                    }
                }
                else
                {
                    f = 0;
                    a_life -= d_attack;
                    if (a_life <= 0)
                    {
                        // 高橋君の負け
                        result = "No";
                        end = true;
                    }
                }
            }
            Write(result);
        }


        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif

Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a >= b + 1){
    cout << 2*a -1 << endl;
  }
  else if ( b >= a + 1){
    cout << 2*b -1 << endl;
  }
  else{
    cout << a + b << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000
int H , A[MAX+1];
void maxHeapify(int i)
{
	int l,r,largest;
	l = 2 * i;
	r = 2 * i + 1;
	int dmp = 0;
	if(l <= H && A[l] > A[i])
	{
		largest = l;
	}
	else 
	{
		largest = i;
	}
	if(r <= H && A[r] > A[largest])
	{
		largest = r;
	}
	
	if(largest != i)
	{
		
		dmp = A[i];
		A[i] = A[largest];
		A[largest] = dmp;
		maxHeapify(largest);
	}
}

int main()
{
	scanf("%d",&H);
	for(int i = 1;i <= H;i++)
	{
		scanf("%d",&A[i]);
	}
	for(int i = H/2;i >= 1;i--)
	{
		maxHeapify(i);
	}
	for(int i = 1;i <= H;i++)
	{
		printf(" %d",A[i]);
	}
	printf("\n");
	return 0;
}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,n,i,j,s=0;
    cin>>n;
    long long A[n];
    for(i=0;i<n;i++)
      cin>>A[i];
    for(i=0;i<n;i++)
    {
      for(j=i+1;j<n;j++)
      {
         s+=A[i]*A[j];
      }
    }
  cout<<s<<endl;



return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using namespace std;
typedef vector<int> PP;
typedef vector<PP> P;
int n,r;

struct block{
	int x1,x2,y,f;
};

block b[20002];
int fie[10002][2];

bool comp(const block &b1,const block &b2){
	return b1.y<b2.y;
}

int main(void){
	while(1){
		scanf("%d%d",&n,&r);
		if(n==0 && r==0)break;
		memset(fie,0,sizeof(fie));
		memset(b,0,sizeof(b));
		for(int i=0;i<n;i++){
			int y1,y2;
			scanf("%d%d%d%d",&b[i*2].x1,&y1,&b[i*2].x2,&y2);
			b[i*2].x2--;
			b[i*2+1].x1=b[i*2].x1;
			b[i*2+1].x2=b[i*2].x2;
			b[i*2].y=y1;
			b[i*2+1].y=y2;
			b[i*2].f=1;
			b[i*2+1].f=-1;
		}
		sort(b,b+n*2,comp);
		int ny=0;
		int now=0,prev=1;
		int res=0,res2=0;
		for(int i=0;i<n*2;i++){
			if(ny!=b[i].y){
				swap(now,prev);
				int cnt=0;
				int cnt2=0,bt=0,cnt3=0;
				for(int j=0;j<=10000;j++){
					if(fie[j][now]>0 && fie[j][prev]==0)cnt3++;
					if(fie[j][now]==0 && fie[j][prev]>0)cnt3++;
					fie[j][now]=fie[j][prev];
					if(fie[j][now]>0){
						cnt++;
						if(bt==0)cnt2++,bt=1;
					}else bt=0;
				}
				res+=cnt*(b[i].y-ny);
				res2+=cnt2*2*(b[i].y-ny)+cnt3;
			}
			ny=b[i].y;
			for(int j=b[i].x1;j<=b[i].x2;j++)fie[j][now]+=b[i].f;
			//printf("%d\n",res2);
			
		}
		printf("%d\n",res);
		if(r==2){
			swap(now,prev);
			int cnt3=0;
			for(int j=0;j<=10000;j++){
				if(fie[j][now]>0 && fie[j][prev]==0)cnt3++;
				if(fie[j][now]==0 && fie[j][prev]>0)cnt3++;
				fie[j][now]=fie[j][prev];
			}
			res2+=cnt3;
			printf("%d\n",res2);
		}
	}
	return 0;
}

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

string orCheck(bool matrix[21][21]){
    for(int i = 0; i < 21; i++){
        for(int j = 0; j < 21; j++){
            if(matrix[i][j]) return "No";
        }
    }
    return "Yes";
};

int main(int argc, const char * argv[])
{
    int n;
    while(true){
        cin >> n;
        if(n == 0) break;
        bool tile[21][21];
        for(int i = 0; i < 21; i++){
            for(int j = 0; j < 21; j++){
                tile[i][j] = false;
            }
        }
        
        // 宝石
        for(int i = 0; i < n; i++){
            int gx, gy;
            cin >> gx >> gy;
            tile[gy][gx] = true;
        }
        
        // 命令
        int m;
        cin >> m;
        int x = 10, y = 10;
        tile[y][x] = false;
        for(int i = 0; i < m; i++){
            char direction;
            int distance;
            cin >> direction >> distance;
            //cout << "direction: " << direction << "\tdistance: " << distance << "\n";
            
            switch (direction) {
                case 'N':
                    for(int j = 1; j <= distance; j++)
                        tile[y + j][x] = false;
                    y += distance;
                    break;
                    
                case 'S':
                    for(int j = 1; j <= distance; j++)
                        tile[y - j][x] = false;
                    y -= distance;
                    break;
                    
                case 'E':
                    for(int j = 1; j <= distance; j++)
                        tile[y][x + j] = false;
                    x += distance;
                    break;
                    
                case 'W':
                    for(int j = 1; j <= distance; j++)
                        tile[y][x - j] = false;
                    x -= distance;
                    break;
            }
            //cout << "position: " << x << " " << y << "\n";
        }
        cout << orCheck(tile) << "\n";
    }
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  for(int bit = 0; bit < (1<<3); bit++) {
    int tmp = S[0] - '0';
    for(int i = 0; i < 3; i++) {
      if(bit & (1<<i)) tmp += (S[i+1] - '0');
      else tmp -= (S[i+1] - '0');
    }
    if(tmp == 7) {
      cout << S[0];
      for(int i = 0; i < 3; i++) {
        if(bit & (1<<i)) cout << '+';
        else cout << '-';
        cout << S[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll X, N, i, a;
    set<ll> p;

    cin >> X >> N;

    for(i=1; i<=N; i++){
        cin >> a;
        p.insert(a);
    }

    if(!p.count(X)) cout << X << endl;

    else{
        for(i=1; i<=200; i++){
            if(!p.count(X-i)){
                cout << X-i << endl;
                return 0;
            }

            if(!p.count(X+i)){
                cout << X+i << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

int H,W,Ch,Cw,Dh,Dw;

bool is_in_map(int h,int w){
    return (h >= 0 && h < H && w >= 0 && w < W);
}

bool is_movable(int h,int w,char c){
    return c=='.';
}

bool is_move_A(int i,int j){
    return ((i==0&&(j==-1 || j==1)) || (j==0 && (i==-1 || i==1)));
}

int main(){
    
    cin >> H >> W;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;
    --Ch;--Cw;--Dh;--Dw;
    vector<string> S(H);
    rep(i,H) cin >> S[i];
    

    int INF = 1000000000;
    
    vector<vector<int>> cost(H,vector<int>(W,INF));
    vector<vector<bool>> searched(H,vector<bool>(W,false));

    
    deque<array<int,3>> q(0,array<int,3>());
    array<int,3> pos{Ch,Cw,0};
    q.push_front(pos);
    while(!q.empty()){
        int w,h,c;
        
        h = q.front()[0];
        w = q.front()[1];
        c = q.front()[2];
        q.pop_front();
        searched[h][w] = true;

        for(int i=-2;i<3;i++){
            for(int j=-2;j<3;j++){
                int next_h,next_w;
                next_h = h + i;
                next_w = w + j;
                if(!is_in_map(next_h,next_w) || !is_movable(next_h,next_w,S[next_h][next_w]))continue;
                if(!searched[next_h][next_w]){
                    if(is_move_A(i,j)){
                        pos[0] = next_h;pos[1] = next_w;pos[2] = c;
                        q.push_front(pos);
                        cost[next_h][next_w] = min(cost[next_h][next_w],c);
                    }
                    else{
                        pos[0] = next_h;pos[1] = next_w;pos[2] = c+1;
                        q.push_back(pos) ;
                        cost[next_h][next_w] = min(cost[next_h][next_w],c+1);
                    }
                }

            }
        }
    }
    if(searched[Dh][Dw])cout << cost[Dh][Dw] << endl;
    else cout << -1 << endl;
}

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

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

	int ans = 0;
	for (int i = 1; i < n; i++) {
		int cnt = 0;
		for (char target = 'a'; target <= 'z'; target++) {
			bool left = false, right = false;
			for (int j = 0; j < i; j++) if (s[j] == target) left = true;
			for (int j = i; j < n; j++) if (s[j] == target) right = true;

			if (left && right)cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;

	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()
{
    ll a;
    cin >> a;
    string b;
    cin >> b;

    ll bb = 0;
    ll d = 0;
    for (int i = 0; i < b.size(); i++) {
        if (b[i] == '.') {
            d = b.size() - 1 - i;
            continue;
        }
        bb = bb * 10 + (b[i] - '0');
    }
    ll ans = (ll)(a * bb);
    while (d > 0) {
        ans /= 10;
        d--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
def main():
    A, B, C = map(int, input().split())
    K = int(input())
    for i in range(K):
        if A >= B:
            B *= 2
        elif B >= C:
            C *= 2
    return (A < B) and (B < C)
if main():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9116
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int a[100];
	int s=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
		a[i]*=n;
		s+=a[i];
	}
	s/=n;
	int mn=10000000;
	for(int i=0; i<n; i++){
		mn=min(mn, abs(s-a[i]));
	}
	for(int i=0; i<n; i++){
		if(mn==abs(s-a[i])){
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int weekNum = sc.nextInt();

		int debt = 100000;
		int roundUpNum = 1000;

		for (int i = 0; i < weekNum; i++) {
			debt *= 1.05;

			debt = (int) Math.ceil((double) debt / roundUpNum) * roundUpNum;
		}
		System.out.println(debt);
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<int> b(n);
  rep(i, n) cin >> b.at(i);
  ll pl = 0, mi = 0;
  rep(i, n){
    if(a.at(i) > b.at(i)) mi += a.at(i) - b.at(i);
    else pl += (b.at(i) - a.at(i))/2;
  }
  if(mi <= pl) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3708
#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, k;
	cin >> n >> k;
	vector<int>a(200000,0);
	int num;
	repp(i, 0, n) {
		cin >> num;
		++a[num];
	}
	int count = 0, type = 0,check=0;
	repp(i, 0, a.size()) {
		if (a[i] != 0)++type;
	}
	sort(a.begin(), a.end());
	if(type-k>0)for (int i = 0;; ++i) {
		if (a[i] != 0) {
			count += a[i];
			++check;
		}
		if (check == type - k)break;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int dp[4000][7000];

int main() {
    int n, t;
    cin >> n >> t;
    vector<P> AB(n);
    rep(i, n) cin >> AB[i].first >> AB[i].second;
    sort(AB.begin(), AB.end());
    rep(j, 7000) dp[0][j] = 0;
    dp[1][0] = 0;

    // 配るdp
    /*
        i番目までで時間j以内に食べたものの最高満足度
        配るdpで注文を再現 jで注文したものはj+AB[i-1].firstで食べ終わる
        jをt未満に限定
    */
   int ans = 0;
    rep(i, n+1)rep(j, 7000){
        if(i==0) continue;
        if(j<t){
            dp[i][j+AB[i-1].first] = max(dp[i-1][j+AB[i-1].first], dp[i-1][j] + AB[i-1].second);
        }
        chmax(dp[i][j], dp[i-1][j]);
        if(j!=0){
            chmax(dp[i][j], dp[i][j-1]);
        }
    }
    ans = dp[n][6999];

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

Measured memory_bytes: 84224
ha=[]
for i in range(3):
  ha+=list(map(int, input().split()))

visits=[0 for i in range(9)]
k=int(input())
for i in range(k):
  n=int(input())
  if n in ha:
    x=ha.index(n)
    visits[x]=1
if visits[0:3]==[1,1,1] or visits[3:6]==[1,1,1] or visits[6:9]==[1,1,1]:
  print("Yes")
elif [1,1,1] in ([visits[0],visits[3],visits[6]],[visits[1],visits[4],visits[7]],[visits[2],visits[5],visits[8]]):
  print("Yes")
elif [1,1,1] in ([visits[0],visits[4],visits[8]],[visits[2],visits[4],visits[6]]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
h, w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
c = []

for i in range(n):
    while a[i] > 0:
        a[i] -= 1
        c.append(str(i + 1))

for i in range(h):
    if i % 2 == 0:
        print(" ".join(c[i * w:(i + 1) * w]))
    else:
        print(" ".join(reversed(c[i * w:(i + 1) * w])))


Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (410)
#define P (998244353)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
typedef vector<int> vc;
int n,ans,S,a[N],b[N],jc[N],inv[N];
vector<int> f[N],e[N];
vc mul(vc a,vc b){
	vc c; c.resize(a.size()+b.size()-1);
	for(int i=0;i<a.size();i++)
	for(int j=0;j<b.size();j++)
	(c[i+j]+=1ll*a[i]*b[j]%P)%=P;
	return c;
}
vc dec(vc &a,vc b){
	a.resize(max(a.size(),b.size()));
	for(int i=0;i<b.size();i++)
	a[i]=(a[i]-b[i]+P)%P;
	return a; 
}
vc inc(vc &a,vc b){
	a.resize(max(a.size(),b.size()));
	for(int i=0;i<b.size();i++)(a[i]+=b[i])%=P;
	return a;
}
int ksm(int a,int p){
	int res=1;
	while(p){
		if(p&1)res=1ll*res*a%P;
		a=1ll*a*a%P,p>>=1;
	}
	return res;
}
int main(){
	read(n),jc[0]=inv[0]=1;
	for(int i=1;i<=n;i++)read(a[i]),read(b[i]),S+=a[i];
	for(int i=1;i<=405;i++)jc[i]=1ll*jc[i-1]*i%P,inv[i]=ksm(jc[i],P-2);
	for(int i=1;i<=n;i++)
	for(int j=0;j<b[i];j++)e[i].push_back(1ll*ksm(a[i],j)*ksm(jc[j],P-2)%P);
	for(int i=1;i<=n;i++){
		for(int j=S-a[i];j;j--)
		if(f[j].size()){
//			cout<<a[i]+j<<" faq"<<endl;
			dec(f[a[i]+j],mul(e[i],f[j]));
		}
		inc(f[a[i]],e[i]);
	}
//	for(int i=1;i<=S;i++){
//		for(int j=0;j<f[i].size();j++)cout<<f[i][j]<<" "; puts("");
//	}
	for(int i=1;i<=S;i++)
	for(int j=0,t=ksm(i,P-2);j<f[i].size();j++)
	(ans+=1ll*f[i][j]*ksm(t,j+1)%P*jc[j]%P)%=P;
	cout<<1ll*ans*S%P;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  string s; cin>>s;
  vector<int> k(26,0);
  rep(i,s.size()){
    k[s[i]-'a']++;
  }
  rep(i,26){
    if(k[i]%2!=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const int N=7;
const int INF=1e9+7;

int main(){
	int a,b; scanf("%d%d",&a,&b);
	if((a*b)&1)printf("Yes\n");
	else printf("No\n"); 
	return 0;
}


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

using namespace std;


int N;
vector<vector<int>> A;

int M;
vector<vector<int>>match_glaph;
vector<int> close;

int get_match_index(int a, int b);
int topological(int n);

int main()
{
	
	cin >> N;
	
	A = vector<vector<int>>(N + 1, vector<int>(N));
	M = get_match_index(N, N);
	match_glaph = vector<vector<int>>(M+1);

	for (int i = 1;i <= N; i++) {
		int last_index = 0;
		for (int j = 1; j <= N-1 ; j++) {
			cin >> A[i][j];
			int mi = get_match_index(i, A[i][j]);

			if (last_index > 0) {
				match_glaph[last_index].push_back(mi);
			}
			else {
				match_glaph[0].push_back(mi);
			}

			last_index = mi;
		}
	}

	close = vector<int>(M+1, 0);

	int ans = topological(0);
	if (ans != -1) { ans--; }

	cout << ans << endl;

	return 0;
}

int get_match_index(int a, int b)
{
	if (b > a) {
		swap(a,b);
	}

	return  (N*(b-1)) - (b*(b-1))/2 + (a - b);
}

int topological(int n)
{
	if (close[n] != 0) {
		return close[n];
	}

	close[n] = -1;

	int ret = 1;
	for (int i : match_glaph[n]) {
		int rd = topological(i);
		if (rd == -1) { ret = -1; break; }

		ret = max(ret,rd+1);
	}
	close[n] = ret;

	return ret;
}

Measured memory_bytes: 33536
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		int[][] dp = new int[s.length()+1][t.length()+1];
		for (int i=1;i<s.length()+1;i++) {
			for (int j=1;j<t.length()+1;j++) {
				if (s.charAt(i-1)==t.charAt(j-1)) {
					dp[i][j]=dp[i-1][j-1]+1;
				}else {
					dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}

		String res = "";
		int i = s.length(), j = t.length();
		while (i > 0 && j > 0) {
        	if (dp[i][j] == dp[i-1][j]) {
        	i--;
			}else if(s.charAt(i-1)==t.charAt(j-1)){
			res = s.charAt(i-1) + res;
			i--;
			j--;
        	}else {
        	j--;
        	}
		}
		System.out.println(res);
	}
}

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

int main() {
  string a,b; cin >> a >> b;
  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n*3);
  REP(i,n*3) cin >> a[i];
  SORT(a);
  LL answer = 0ll;
  REP(i,n) answer+=a[n+i*2];
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string S;
	cin>>S;
	int x=0,y=0,z=0;
	rep(i,3){
		if(S[i]=='a')x++;
		if(S[i]=='b')y++;
		if(S[i]=='c')z++;
	}
	if(x==1&&y==1&&z==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::io;

fn main() {
	let ln = read_line();
	let nm: Vec<_> = ln.split_whitespace().collect();
	let n: i32 = nm[0].parse().unwrap();
	let m: i64 = nm[1].parse().unwrap();
	let ln = read_line();
	let a: Vec<i64> = ln.split_whitespace().map(|s| s.parse().unwrap()).collect();
	
	let mut sum = vec![0i64];
	for x in &a {
		let last = *sum.last().unwrap();
		sum.push(last + *x);
	}
	let mut map = HashMap::new();
	let mut ans = 0i64;
	for x in &sum {
		let cnt = map.entry(*x % m).or_insert(0);
		ans += *cnt;
		*cnt += 1;
	}
	
	println!("{}", ans);
}

fn read_line() -> String {
	let mut ln = String::new();
	io::stdin().read_line(&mut ln).ok();
	ln.pop();
	return ln;
}


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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main(){
    int N; cin >> N;
    vector<int> X(N);
    int M = 0, m = 10000000;
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
        M = max(M, X.at(i));
        m = min(m, X.at(i));
    }
    int sum, ans = 100000000;
    for (int P = m; P <= M; P++) {
        sum = 0;
        for (int i = 0; i < N; i++) {
            sum += pow(X.at(i) - P, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x,y,z,d;
    scanf("%d%d",&x,&y);
    
    if(x<y){
        while(x != 0){
            d=y%x;
            y=x;
            x=d;
        }
        printf("%d\n",y);
    }
    else{
    while(y !=0){
        d=x%y;
         x=y;
        y=d;
     
    }
    printf("%d\n",x);
    }
    return 0;
}


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

int main() {
  int n;
  while(cin >> n) {
    vector<int> v;
    for (int i=0; i<n;i++) {
      int in;
      cin >> in;
      v.push_back(in);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    int ans = 0;
    for (int i=0; i<v.size(); i++) {
      ans += sum + v[i];
      sum += v[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
from sys import stdin
input = stdin.readline

def SumOfProductParis(n):
    if n == 0:
        return 0
    elif n == 1:
        return A[0]
    else:
        result = 0
        temp = sum(A)
        result = temp**2
        for i in range(n):
            result -= A[i]**2
        return (result//2)%(10**9+7)

N = int(input())
A = list(map(int, input().split()))

print(SumOfProductParis(N))

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

using namespace std;

int main() {
    long long int n;
    cin >> n;

    vector<long long int> a(n);
    for (long long int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector< vector<long long int> > dp(n, vector<long long int>(2, 0));
    dp[1][0] = a[0]+a[1];
    dp[1][1] = -(a[0]+a[1]);

    for (long long int i = 2; i < n; i++) {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]) + a[i];
        dp[i][1] = max(dp[i-1][0]-2*a[i-1], dp[i-1][1]+2*a[i-1]) - a[i];
        //cout << dp[i][0] << ' ' << dp[i][1] << endl;
    }

    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
    return 0;
}

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

const int INF = 1e9+5;

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    cout<<a[k-1]<<'\n';
    return 0;
}

Measured memory_bytes: 384
def main():
   n = input()
   data = list(input())
   for i in data:
      a = ord(i) + int(n)
      if a > ord("Z"):
         a = a + ord("A") - ord("Z") - 1
      print(chr(a),end = "")

if __name__==  "__main__":
   main()


Measured memory_bytes: 4596
// =========
use std::cmp::{max, min};
use std::collections::HashSet;
use std::process::exit;
const MOD: usize = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        return a;
    } else if a < b {
        return gcd(a, b % a);
    } else {
        return gcd(b, a % b);
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        s: String,
        t: String,
    }
    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();

    let lcm = n * m / gcd(n, m);
    let mut nfac = HashSet::new();
    let mut mfac = HashSet::new();
    for i in 0..n {
        nfac.insert(lcm / n * i);
    }
    for i in 0..m {
        mfac.insert(lcm / m * i);
    }
    for i in nfac.intersection(&mfac) {
        if s[i * n / lcm] != t[i * m / lcm] {
            println!("{:?}", -1);
            exit(0);
        }
    }
    println!("{:?}", lcm);
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    int x;
    cin >> x;
    int i = 1,k = 1;
    while (k < x) {
        i++;
        k += i;
    } 
    cout << i << endl ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef pair<int,int> P;

int n;
double r[500];
double dist[500];

int main(){
	cin >> n;
	rep(i,n) cin >> r[i];
	rep(i,n){
		dist[i] = r[i];
		rep(j,i){
			dist[i] = max(dist[i],dist[j]+sqrt(pow(r[j]+r[i],2)-pow(r[j]-r[i],2)));
		}
	}
	double ans = 0.0;
	rep(i,n) ans = max(ans,dist[i]+r[i]);
	printf("%.9f\n",ans);
}

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B>C+D){
  	cout<<"Left"<<endl;
  }else if(A+B<C+D){
  	cout<<"Right"<<endl;
  }else{
  	cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
X = int(input())
isPrime = [True] * (X * 2)
isPrime[0] = False
isPrime[1] = False

for i in range(2,X):
  for j in range(i,X*2,i):
    isPrime[j] = False
  
ans = None
for i in range(X,X*2):
  if isPrime[i]:
    ans = i
    break
    
print(ans)
  


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

using namespace std;
#define X first
#define Y second
typedef pair<int,int> P;
int n;P dat[100005];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&dat[i].X),dat[i].Y=i;
	sort(dat+1,dat+n+1);
	int res=0;
	for(int i=1;i<=n;i++)
		if((dat[i].Y&1)&&!(i&1)) res++;
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 1024
#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++)
const int MOD =1e9+7;
using ll = long long;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if(X>Y){
        cout << min({A*X+B*Y, X*2*C, Y*2*C + (X-Y)*A}) << endl;
    }else {
        cout << min({A*X+B*Y, Y*2*C, X*2*C + (Y-X)*B}) << endl;
    }
}


Measured memory_bytes: 256
input = readlines
input.each{|num|
    num = num.chomp!
}


i = 0
stat = "0"

while i < (input.length-1)
    j = i + 1
    while j < (input.length-1) 

        dis = input[j].to_i - input[i].to_i

        if dis > input[input.length-1].to_i
            stat = ":("
        elsif stat != ":("
            stat = "Yay!"
        end
    
        j = j + 1
    end
    
    i = i + 1
end

print stat


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 13 17:57:26 2018


文字列に[Y]が入っていたら[Four]を出力
そうではなければ [Three]を出力


入力
6
G W Y P Y W

出力
Four


@author: Yuya
"""

N = int(input())

#整数(複数)入力
S = input().split()

flag = 0

for i in range(N):
    if S[i] == "Y":
        flag = 1
    
if flag == 1:
    print("Four")
else:
    print("Three")

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double pi = acos(-1);
  long double r = 2*(h/12+m/60/12 - m/60);
  long double theta = r*pi;
  long double ans = a*a + b*b - 2*a*b*cos(theta);

  cout << setprecision(10) << sqrt(ans) << endl;

}

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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; ++i) cin >> d[i];
    int total = 0;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            total += d[i] * d[j];
        }
    }
    cout << total << '\n';
}

Measured memory_bytes: 256
// input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// body
fn main() {
    input! {
        s: chars,
    }
    let mut prev = 'a';
    let mut ans = "Good";
    for char in s {
        if char == prev {
            ans = "Bad";
            break;
        }
        prev = char;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    int n; cin >> n;
    vector <int> A(n);
    for (int &i : A) cin >> i;

    vector <int> dp(n, 1e9);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        int jump = i + 1;
        if (jump < n) dp[jump] = min(dp[jump], dp[i] + abs(A[i] - A[jump]));
        jump++;
        if (jump < n) dp[jump] = min(dp[jump], dp[i] + abs(A[i] - A[jump]));
    }

    cout << dp[n-1];


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  vector<int> A(3);
  cin>>A.at(0)>>A.at(1)>>A.at(2);
  sort(A.begin(),A.end());
  cout<<A.at(2)-A.at(0)<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
       int x= sc.nextInt();
       int n = sc.nextInt();
       int sum=0;
       for(int i=0; i<n; i++) sum += sc.nextInt();
       if(x < sum)
           out.println(-1);
       else
           out.println(x-sum);
    }
    private static boolean helper(long x){
        double ans = Math.sqrt(x);
        return ans%1!=0;
    }

    private static int gcd(int a, int b){
        if(b==0)
            return a;
        return gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair  {
    int x;
    int y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

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

using namespace std;


int main()
{
    int a,b;
    int ans=0;
    cin >> a >> b;

for(int i=0;i<2;i++){
    if(a>=b){
        ans+=a;
        a--;
    }else{
        ans+=b;
        b--;
    }
}

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

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    l, r, d = MII()
    cnt = 0
    for i in range(l, r+1):
        if i%d == 0:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  ans += a[2] - a[1];
  a[0] += ans;
  ans += (a[2] - a[0] + 1) / 2;
  if ((a[2] - a[0]) % 2 == 1) ans++;
  cout << ans << endl;
}

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

namespace ConsoleApp1
{
    static class ACannotWaitforHoliday
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var weekdays = new List<string> { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            Console.WriteLine(7 - weekdays.IndexOf(s));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11104
#include <iostream>
#include <cstdio> 
#include <cstring>
using namespace std;
char a[110][110];
int row,col;
int delrow[110],delcol[110];

void deleteOneCol(int k){
int j,i;
  for(j=k+1;j<col;j++)
    for(i=0;i<row;i++)
      a[i][j-1]=a[i][j];
  col--;
}

void deleteOneRow(int k){
int i,j;
  for(i=k+1;i<row;i++)
    for (j=0;j<col;j++)
      a[i-1][j]=a[i][j];
  row--;  
}

void delRow(){
  for (int i=row;i>=0;i--)
    if (delrow[i]==1)
	  deleteOneRow(i);	
}

void delCol(){
	for (int j=col;j>=0;j--)
	  if (delcol[j]==1)
	    deleteOneCol(j);
}

void drow(){
  int i,j;
  char c='.';
  for(i=0;i<row;i++){
    for (j=0;j<col;j++)
	  if (a[i][j]!=c)
	    break;
	if (j>=col)
	  delrow[i]=1; 
	
  }
	
}

void dcol(){
  int i,j;
  char c='.';
  for(j=0;j<col;j++){
    for (i=0;i<row;i++)
	  if (a[i][j]!=c)
	    break;
	if (i>=row){
	  delcol[j]=1;	
	}
  }	
	
}

int main() {
	int i,j;

	
	//freopen("input01.txt","r",stdin);
	
	cin>>row>>col;

	for (i=0;i<row;i++)
	  for(j=0;j<col;j++)
	    cin>>a[i][j];
	
	drow();//检查并标记 
	dcol();//
	delRow();
	delCol();
	  
	for (i=0;i<row;i++){
	  for(j=0;j<col;j++)
		  cout<<a[i][j];
      cout<<endl;
 	}
	
	return 0;
}

Measured memory_bytes: 256