akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    int MAX = max({a, b, c});
    int seek = abs(3*MAX-a-b-c);
    int ans;
    if(seek%2==0)
        ans = seek/2;
    else if(seek%2!=0){
        seek++;
        ans = seek/2+1;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

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

def gcd(a, b):
    if a < b: return gcd(b, a)
    elif b > 0: return gcd(b, a % b)
    else:
        return a

a = A[0]

for i in range(1,N):
	a = gcd(A[i] , a)

print(a)

Measured memory_bytes: 14224
#include<iostream>
using namespace std;
#include<queue>
#define int long long int
#define mod 1000000000;
int memo[2005][2005];
void bfs(int src,vector<int> adj[],int n)
{
	queue<int> q;
	int dist[n+1]={0};
	bool visited[n+1]={false};
    int i;
    for(i=0;i<=n;i++)
    {
		dist[i]=mod;
	}
	dist[src]=0;
	q.push(src);
	visited[src]=true;
	while(!q.empty())
	{
		int y=q.front();
		q.pop();
			for(int p:adj[y])
			{
				if(!visited[p])
				{
					visited[p]=true;
					dist[p]=1+dist[y];
					q.push(p);
				}
			}
	}
	for(i=1;i<=n;i++)
	{
		memo[src][i]=dist[i];
	}
}
int32_t main()
{
    int n,x,y;
    cin>>n>>x>>y;
    vector<int> adj[n+1];
    int i,j;
    for(i=1;i<=n-1;i++)
    {
		adj[i].push_back(i+1);
		adj[i+1].push_back(i);
	}
    adj[x].push_back(y);
    adj[y].push_back(x);
    for(i=1;i<=n;i++)
    {
		bfs(i,adj,n);
	}
	int count[n]={0};
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			int d=memo[i][j];
			count[d]++;
		}
	}
	for(i=1;i<n;i++)
	   cout<<count[i]<<endl;
}


Measured memory_bytes: 31744
#include<stdio.h>
#include<string.h>
#define ll long long
int main()
{
    char a[100+5];
    gets(a+1);
    int flag=1;
    for(int i=1;i<=strlen(a);i++)
    {
        if(i%2==1&&a[i]=='L')
        {
            flag=0;
            break;
        }
        if(i%2==0&&a[i]=='R')
        {
            flag=0;
            break;
        }

    }
    if(flag==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
  
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
   	
    int a = scan.nextInt();
    String s = scan.next();
 
    if (a < 3200) {
      System.out.println("red");
    } else { 
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 21076
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n=0,i,j,l,m=0;
	string s;
	cin>>s;
	l=s.length();
	FOR(i,0,l){
		n*=10;
		n+=s[i]-'0';
		m+=s[i]-'0';
	}
	//cout<<n<<m;
	if(n%m==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc138/tasks/abc138_c
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<double> vn(N);
    for(auto&& v:vn){
        cin>>v;
    }
    sort(vn.begin(),vn.end());
    double tmp=(vn[0]+vn[1])/2.0;
    for(ll i=2;i<N;++i){
        tmp=(tmp+vn[i])/2;
    }
    cout<<fixed<<std::setprecision(10)<<tmp<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int a[55];
bool pr[55];
long long C (int n,int m) {
	int b[55]={0},i,j;
	for (i=2;i<=50;i++) {
		int t=n;
		if (pr[i]) {
			while (t!=0) {
				t/=i;b[i]+=t;
			}
		}
		t=n-m;
		if (pr[i]) {
			while (t!=0) {
				t/=i;b[i]-=t;
			}
		}
		t=m;
		if (pr[i]) {
			while (t!=0) {
				t/=i;b[i]-=t;
			}
		}
	}
	long long r=1;
	for (i=2;i<=50;i++) {
		if (pr[i]) {
			for (j=1;j<=b[i];j++) r*=i;
		}
	}
	return r;
}
int main ( ) {
	int n,p,i,j,s0=0,s1=0;
	scanf("%d%d",&n,&p);
	memset(pr,true,sizeof(pr));
	pr[1]=false;
	for (i=2;i<=50;i++) {
		if (pr[i]) {
			for (j=i*2;j<=50;j+=i) pr[j]=false;
		}
	}
	for (i=1;i<=n;i++) {
		scanf("%d",&a[i]),a[i]%=2;
		if (a[i]==0) s0++; else s1++;
	}
	long long w=0,ans=1;
	if (p==0) {
		for (i=1;i<=s0;i++) ans*=2;
		for (i=0;i<=s1;i+=2) w+=C(s1,i);
	}
	else {
		for (i=1;i<=s0;i++) ans*=2;
		for (i=1;i<=s1;i+=2) w+=C(s1,i);
	}
	/*int f[50]={0},g[50]={0},anss[100]={0};
	for (i=1;i<=30;i++) f[i]=ans%10,ans/=10;
	for (i=1;i<=30;i++) g[i]=w%10,w/=10;
	for (i=1;i<=30;i++) {
		for (j=1;j<=30;j++) {
			anss[i+j-1]+=f[i]*g[j];
			anss[i+j]+=anss[i+j-1]/10;
			anss[i+j-1]%=10;
		}
	}
	i=50;
	while (anss[i]==0 && i>1) i--;
	for (;i>=1;i--) cout<<anss[i];*/
	cout<<ans*w<<endl;
	return 0;
}
/*
Sample Input 1
2 0
1 3
Sample Output 1
2
Sample Input 2
1 1
50
Sample Output 2
0
Sample Input 3
3 0
1 1 1
Sample Output 3
4
Sample Input 4
45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26
Sample Output 4
17592186044416
*/

Measured memory_bytes: 256
# include <stdio.h>
int main()
{
	int a[200000];
	int n;
	int max = -1000000000;
	

	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	int min = a[0];
	for (int i = 1; i < n; i++)
	{
		int tem;
		if ( a[i-1] < min)	min = a[i - 1];
		tem = a[i] - min;
	
		if( tem > max)   max = tem;
	}
	printf("%d\n",max);
 } 


Measured memory_bytes: 2612
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		int n = int.Parse(Console.ReadLine());
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int[] vv = (int[])vals.Clone();
		Array.Sort(vv);
		int low = vv[n / 2-1];
		int hight = vv[(n / 2)];
		for (int i = 0; i < n; i++) {
			int res = -1;
			if (vals[i] > low) { res = low; } else { res = hight; }


			Console.WriteLine(res);
		}

			//deug
			//Console.WriteLine("");

		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



}

Measured memory_bytes: 34120
#include<iostream>
#include<vector>
#include <iomanip>
#include <cmath>
#include <math.h>
#include <algorithm> 
#include <bits/stdc++.h> 
#include<map>
using namespace std;
int main()
{
        vector<long int>::iterator it;
         // std::vector<long int>::iterator upper; 
 //long long long int l,r,m,i,t,a,b,n;
long long int n,t{0},l,i,d,k,x,sum{0},a,y,j,r,b,z,m{0},cnto{0},cnte{0};//diff{0};
string s,s1,s3;
long long int ans{0};
// cin>>t;
// while(t>0)
{
    cin>>x>>n;
 vector<int>a(n);
 for(i=0;i<n;i++)
 {
     cin>>a[i];
 }
 sort(a.begin(),a.end());
if(!binary_search(a.begin(),a.end(),x))
{
    cout<<x;
}
else
{
    i=1;
    while(1)
    {
        
        if(!binary_search(a.begin(),a.end(),x-i))
        {
        cout<<x-i;
        break;
        }
        else if(!binary_search(a.begin(),a.end(),x+i))
        {
        cout<<x+i;
        break;
        }
        i++;
    }
}

t--;
}
return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

int main() {
  int a, b;

  cin >> a >> b;

  if (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k; cin>>n>>k;
    ll arr[n],dp[n];
    rep(i,0,n){
        cin>>arr[i]; dp[i]=inf1;
    }
    dp[n-1]=0;
    repr(i,n-2,0){
        rep(j,i+1,min(i+k+1,n)) dp[i]=min(dp[i],dp[j]+abs(arr[j]-arr[i]));
    }
    cout<<dp[0]<<endl;
}

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

using namespace std;

int main(){
	int n; string str;
	cin >> n >> str;
	for(int i=0; i<str.length(); i++){
		int c = (str[i] - 'A' + n) % 26;
		cout << (char) (c + 'A');
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	float a, b;
	
	while (scanf("%f %f", &a, &b) != EOF){
		if (a < 35.5 && b < 71){
			printf("AAA\n");
		}
		else if (a < 37.5 && b < 77){
			printf("AA\n");
		}
		else if (a < 40 && b < 83){
			printf("A\n");
		}
		else if (a < 43 && b < 89){
			printf("B\n");
		}
		else if (a < 50 && b < 105){
			printf("C\n");
		}
		else if (a < 55 && b < 116){
			printf("D\n");
		}
		else if (a < 70 && b < 148){
			printf("E\n");
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], t = tmp[1];

	int ans = 1001;
	for (int i = 0; i < n; i++)
	{
	    tmp = ReadIntArray();
	    int ci = tmp[0], ti = tmp[1];
	    if (ti <= t)
	    {
		ans = Math.Min(ci, ans);
	    }
	}

	if (ans > 1000)
	{
	    WriteLine("TLE");
	}
	else
	{
	    WriteLine(ans);
	}
    }
}


Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		String s = in.readLine().toUpperCase();
		int count[] = new int[4];
		boolean[] vis = new boolean[4];
		for (int i = 0; i < s.length(); i++) {
			switch (s.charAt(i)) {
			case 'S':
				count[0]++;
				vis[0] = true;
				break;
			case 'N':
				count[1]++;
				vis[1] = true;
				break;
			case 'E':
				count[2]++;
				vis[2] = true;
				break;
			case 'W':
				count[3]++;
				vis[3] = true;
				break;

			}
		}
		if (vis[0] && vis[1] && vis[2] && vis[3]) {
			System.out.println("Yes");
		} else if (vis[0] && vis[1] && !vis[2] && !vis[3]) {
			System.out.println("Yes");
		} else if (vis[2] && vis[3] && !vis[0] && !vis[1]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		out.close();
		in.close();
	}

	// static bb(long[]arr, int pi,int pf){
	// for(int i= pi+1:i<=pf;i++)for(int j = pf;j>=i;j--)
	// }
}


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

using namespace std;

int main(){
	long long n;
	cin >> n;
	long long a = 0, b = 0, all = 0, count = 0;
	string temp;
	while(n --) {
		cin >> temp;
		long long l = temp.length();
		for(long long i = 1; i < l; i ++ ) {
			if(temp[i - 1] == 'A' and temp[i] == 'B') {
				count ++; 
			}
		}
		if(temp[0] == 'B' and temp[l - 1] == 'A') all ++;
		if(temp[l - 1] == 'A') a ++;
		if(temp[0] == 'B') b ++;
	}
//	cout << "a: " << a << " b: " << b << " all: " << all << endl;
	if(b == all and a == all and all != 0) count --;
	cout << min(a, b) + count << endl;
//	else cout << min(a, b)+ count << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

R = i()
G = i()
print(R+(G-R)*2)

Measured memory_bytes: 77448
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    bool ret = false;
    for(int i=0;i<=x;++i)
    {
      if(i*2 + (x-i) * 4 == y){
        ret = true;
      }
    }
    cout << (ret ? "Yes" : "No") << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MX = 100 * 1000 + 7;

void add(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

void sub(int &x, int y) {
    x -= y;
    if (x < 0) x += MOD;
}

int mul(int x, int y) {
    return 1LL * x * y % MOD;
}

int pw(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) {
        int t = pw(x, y / 2);
        return 1LL * t * t % MOD;
    } else {
        return 1LL * pw(x, y - 1) * x % MOD;
    }
}

int inv(int x) {
    return pw(x, MOD - 2);
}

int a[MX];
int fc[MX], rfc[MX];

int cnk(int n, int k) {
    if (k < 0 || k > n) return 0;
    return mul(fc[n], mul(rfc[k], rfc[n - k]));
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    n++;
    map<int, int> pos;
    int lp = -1, rp = -1;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (pos.count(a[i])) {
            lp = pos[a[i]];
            rp = i;
        }
        pos[a[i]] = i;
    }
    fc[0] = 1;
    for (int i = 1; i <= n; i++) {
        fc[i] = mul(fc[i - 1], i);
    }
    rfc[n] = inv(fc[n]);
    for (int i = n - 1; i >= 0; i--) {
        rfc[i] = mul(rfc[i + 1], i + 1);
    }
    for (int i = 1; i <= n; i++) {
        int res = cnk(n, i);
        int len = rp - lp + 1;
        sub(res, cnk(n - len, i - 1));
        printf("%d\n", res);
    }
}



Measured memory_bytes: 7040
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;	
int d[N], maxi = 0, dp[N];
vector <int> g[N];
void dfs (int v, int p) {
	for (auto to : g[v]) {
		if (to != p) {
			dfs (to, v);
			maxi = max (maxi, d[v] + d[to] + 1);
			d[v] = max (d[v], d[to] + 1);            
		}
	}	
}
void solve () {
	int n;
	cin >> n;
	for (int i = 1; i < n; i ++) {
		int l, r;
		cin >> l >> r;
		g[l].pb (r);
		g[r].pb (l);
	}
	dfs (1, -1);
	maxi ++;
	dp[1] = 1;
	dp[0] = 1;
	for (int i = 2; i <= maxi; i ++) {
		if (dp[i - 1] == 0 || dp[i - 2] == 0) {
			dp[i] = 1;
		}	
		else {
			dp[i] = 0;
		}
	}
	if (dp[maxi] == 1) cout << "First";
	else cout << "Second";
}                         	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 24704
N,M = map(int,input().split())
ac = [False]*N
pe = [0]*N
acnum,penanum = [0]*2
for i in range(M) :
  p,s = input().split()
  p = int(p)-1
  if ac[p] :
    continue
  if s=="AC" :
    ac[p] = True
    acnum += 1
    penanum += pe[p]
  elif s=="WA" :
    pe[p] += 1   
print(acnum,penanum)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll>prime=vectorprime(55555);
	vector<ll> ans;
	rep(i,prime.sz){
		if(prime[i]%5==1) ans.pb(prime[i]);
	}
	rep(i,N) cout<<ans[i]<<" ";	
}

Measured memory_bytes: 384
N=int(input())
TA=[list(map(int,input().split())) for i in range(N)]
Taka=1
Aoki=1

def UP(V1,V2,R1,R2):
    n=max(-(-V1//R1),-(-V2//R2))
    return(n*R1,n*R2)

for i in range(N):
    up=UP(Taka,Aoki,TA[i][0],TA[i][1])
#    print(up)
    Taka=up[0]
    Aoki=up[1]

print(Taka+Aoki)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;

  vll hurui(55555, 0);

  vll ans;
  rep(i, 55555) {
    if (i == 0) continue;
    if (i == 1) continue;

    if (hurui[i] == 0) {
      if (i % 5 == 1) {
        ans.pb(i);
      }
      if ((ll)ans.size() == N) {
        break;
      }
      ll num = i;
      while (num < 55555) {
        hurui[num] = -1;
        num += i;
      }
    }
  }

  rep(i, N) {
    if (i == 0) {
      cout << ans[i];
    } else {
      cout << " " << ans[i];
    }
  }
  ENDL;
  return 0;
}

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

int N;
int Y;
int main(){
    cin >> N >> Y;
    int y_max, h_max, n_max, tmp;
    bool flag;
    flag = true;
    y_max = min(Y/10000, N);
    for(int y=y_max; y>=0 && flag; y--){
        h_max = (Y-y*10000)/5000;
        for(int h=h_max; h>=0 && flag && N-y-h>=0; h--){
            n_max = (Y-y*10000-h*5000)/1000;
            for(int n=n_max; n>=0 && flag && N-y-h-n>=0; n--){
                tmp = Y - 10000*y - 5000*h - 1000*n;
                
                if (tmp==0 && y+h+n==N){
                    cout << y << ' ' << h << ' ' << n << endl;
                    flag = false;
                }
            }
        }
    }
    if(flag){
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
template <class T> int size(const T &x) { return x.size(); }
const int INF = 2147483647;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

int main() {
    ll n, x;
    cin >> n >> x;
    ll res = 0;
    while (true) {
        if (2*x == n) {
            res += 3*x;
            break;
        } else if (2*x < n) {
            ll k = n/(2*x);
            res += 3*x*k;
            n -= x*k;
        } else {
            x = n-x;
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
s=input()
K=int(input())
l=len(s)

S=set([])

for i in range(l):
    for j in range(i,min(l,i+5)):
#        print(s[i:j+1])
        S.add(s[i:j+1])
print(list(sorted(S))[K-1])


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

public class Main {
   
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt(); 
		int a = in.readInt(); 
		int b = in.readInt();
		int r = 0; 
		for(int i = 1; i<=n; i++) {
			int c = 0; 
			int t = i; 
			for(int j = 0; j<5; j++) {
				c+= t%10; 
				t/=10;
			}
			if(a<=c && c<=b) r+=i; 
		}
		System.out.println(r);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
int main()
{
	string s;
	cin >> s;
	if (s.size() == 2)
	{
		if (s[0] == s[1])printf("1 2\n");
		else printf("-1 -1\n");
	}
	else
	{
		for (int i = 0; i < s.size() - 2; i++)
		{
			if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2])
			{
				printf("%d %d\n", i + 1, i + 3);
				return 0;
			}
		}
		printf("-1 -1\n");
	}
}

Measured memory_bytes: 512
n, m = map(int, input().split())
ac_lst = [False] * (n + 1)
wa_lst = [0] * (n + 1)
w = 0
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if ac_lst[a]:
        continue
    if b == 'WA':
        wa_lst[a] += 1
    else:
        w += wa_lst[a]
        ac_lst[a] = True
print(sum(ac_lst), w)


Measured memory_bytes: 4596
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s10(c, s, last_date, di, i, mul):
    score = s[di - 1][i]
    score += 0.5 * mul * c[i] * (di - last_date[i])
    return score


def f11(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        mul = np.mean(s[di - 1]) / np.mean(c)
        score_list = []
        for i in range(26):
            score_list.append(s10(c, s, last_date, di, i, mul))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f11(D, c, s):
    print(ti + 1)

Measured memory_bytes: 27280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main()
{
   int h, w;
   cin >> h >> w;
   vector<string> a(h);
   rep(i,h) cin >> a[i];
   int ans = 0;
   queue<P> que;
      if(que.empty()){
         //＃を探す
         rep(i,h)rep(j,w){
            if(a[i][j] =='#')
            que.push(P(i,j));
         }
      }

   while(1)
   {
      bool end = true;
      rep(i,h){
         rep(j,w){
            if(a[i][j] =='.')
            {
               end = false;
               break;
            }
         }
         if(!end) break;
      }

      if(end) break;     
      queue<P> next;
      while(!que.empty())
      {
         P p = que.front(); que.pop();
         rep(i,4){
            int nx, ny;
            nx = p.second + dx[i];
            ny = p.first + dy[i];
            if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
            if(a[ny][nx] =='#')continue;
            a[ny][nx] = '#';
            next.push(P(ny,nx));
         }
      }
      ans ++;
      que = next;
   }

   cout << ans << endl;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int ans = 0;

		for(int i = 0; i < n; i++) {
			int p = sc.nextInt();
			ans += p;
			max = Math.max(max, p);
		}
		System.out.println(ans - (max/2));

	}

}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


struct S{
    ll x;
    ll y;
    ll c;
};

int main(){
    ll A,B,M;
    ll a_min = 1e10;
    ll b_min = 1e10;
    cin >> A >> B >> M;
    vector<ll> a(A);
    rep(i,A){
        cin >> a[i];
        if(a[i]<a_min){
            a_min = a[i];
        }
    }
    vector<ll> b(B);
    rep(i,B) {
        cin >> b[i]; 
        if(b[i]<b_min){
            b_min = b[i];
        }
    }

    ll ans = a_min + b_min;

    vector<S> s(M);
    rep(i,M){
        cin >> s[i].x >> s[i].y >> s[i].c;
        s[i].x--;
        s[i].y--;
    }


    rep(i,M){
        ll tmp = 0;
        tmp += a[s[i].x];
        tmp += b[s[i].y];
        tmp -= s[i].c;
        if(tmp<ans){
            ans = tmp;
        }
    }

    cout << ans << endl;

    return 0;
}  

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  char c;
  int ca = 0, cb = 0;
  int t = 3;
  while (t--) {
    cin >> c;
    if (c == 'A') {
      ca++;
    } else {
      cb++;
    }
  }
  cout << ((ca == 0 || cb == 0) ? "No" : "Yes") << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    vector<int>A(2500000);
    vector<int>B(2500000);
    vector<int>C(2500000);
    cin >> A[0] >> B[0] >> C[0];
    if (A[0] % 2 == 1 || B[0] % 2 == 1 || C[0] % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    REP(i, 2500000) {
        A[i] = B[i - 1]/2 + C[i - 1]/2;
        B[i] = A[i - 1]/2 + C[i - 1]/2;
        C[i] = A[i - 1]/2 + B[i - 1]/2;
        if (A[i] % 2 == 1 || B[i] % 2 == 1 || C[i] % 2 == 1) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  vector<pair<ll, ll> > C;
  rep(i, N) {
    cin >> A[i] >> B[i];
    C.push_back(make_pair(B[i], A[i]));
  }
  sort(C.begin(), C.end());
  ll S = 0;
  rep(i, N) {
    S += C[i].second;
    if(S > C[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 9584
#define max(x,y) x>y?x:y
pm[51],m[51],pl,v;
main(l){
	while(~scanf("%d",&v)){
		m[l++]=v;
		if(getchar()=='\n'){
			if(l>pl){
				pl=l;
				while(--l){
					m[l]+=max(pm[l],pm[l-1]);
				}
				l=1;
			} else {
				pl=l;
				while(--l){
					m[l]+=max(pm[l],pm[l+1]);
				}
				l=1;
			}
			memcpy(pm,m,sizeof(pm));
		}
	}
	printf("%d\n",pm[1]);
	exit(0);
}

Measured memory_bytes: 0
import System.IO

combinations n = [[a,b,c,d] |a<-[0..9],
                             b<-[0..9],
                             c<-[0..9],
                             d<-[0..9],
                             a+b+c+d==n ]
main = do
  n <- getLine
  print $ length $ combinations (read n)
  eof <- isEOF
  if eof then return ()
         else do
           main

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

int main() {

	int A,B;
	cin >> A >> B;
	int ans = 0;
	for (int i = A; i <= B; i++)
	{
		string num = to_string(i);
		if(num[4] == num[0] && num[3] == num[1]){
			ans++;
		}
	}


	cout << ans << endl;





}

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

using namespace std;

int main(){
    int grid[100][100];
    int H, W, N, a[10000];
    cin >> H >> W >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    int itr = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < a[i]; ++j) {
            grid[itr/W][itr%W] = i+1;
            itr++;
        }
    }
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if(i%2){
                cout << grid[i][W-j-1] << " ";
            } else {
                cout << grid[i][j] << " ";
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;
const ll mod = 1000000007;

namespace modop {
	ll madd(ll a, ll b) {
	  return (a + b) % mod;
	}
	ll msub(ll a, ll b) {
	  return (((a - b) % mod) + mod) % mod;
	}
	ll mmul(ll a, ll b) {
	  return ((a % mod) * (b % mod)) % mod;
	}
	ll mpow(ll base, ll exp) {
	  ll res = 1;
	  while (exp) {
		if (exp % 2 == 1){
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	  }
	  return res;
	}
	ll minv(ll base) {
	  return mpow(base, mod - 2);
	}
	ll mdiv(ll a, ll b) {
	  return mmul(a, minv(b));
	}
}

using namespace modop;

ll fact[500007], ifact[500007];

ll npk(ll n, ll k) {
  return (fact[n] * ifact[n - k]) % mod;
}

ll nck(ll n, ll k) {
  return (npk(n, k) * ifact[k]) % mod;
}

void solve() {
  ll n, m; cin >> n >> m;

  if (m == 1) {
    cout << 0 << '\n';
    return;
  }

  fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
  f1r(i, 2, 500005) {
    fact[i] = (fact[i - 1] * i) % mod;
    ifact[i] = minv(fact[i]);
  }

  ll va = npk(m, n);

  ll vb = va;

  f1rd(i, n, 1) {
    ll cur = (nck(n, i) * npk(m - i, n - i)) % mod;
    
    if ((i - 1) % 2 == 0) vb = msub(vb, cur);
    else vb = madd(vb, cur);
  }

  // cout << vb << endl;
  cout << (va * vb) % mod << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 11468
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    string S;
    cin >> S;

    int N = S.length();
    vector<int> A(N + 1, 0);
    REP(i, N) {
        if (S[i] == '<') { chmax(A[i + 1], A[i] + 1); }
    }

    FORR(i, N, 0) {
        if (S[i] == '>') { chmax(A[i], A[i + 1] + 1); }
    }

    cout << accumulate(ALL(A), 0LL) << endl;
    return 0;
}

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

using namespace std;

#define debug(x) cout << "\n" << __LINE__ << " " <<  (#x) << " is " << (x) << endl

int main(){
	#ifdef EVAL	
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int N;
	cin >> N;
	cout << 3 * N * N;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/cdescription.jsp?cid=ACPC2017Day1&pid=D
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
 
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M, s, t; cin >> N >> M >> s >> t;
    s--; t--;
    vector<int> d(N);
    vector<vector<int>> G(N);
    for (int i = 0; i < N;i++) cin >> d[i];
    for (int i = 0; i < M;i++) {
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
    }
    for (int i = 1; i < N;i++)G[i].push_back(i - 1);
    vector<ll> dist(N, INF);
    queue<pair<int, int>> q;
    q.push({ s,s });
    dist[s] = 0;
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        int n = p.first, max_n = p.second;
        for (auto next : G[n]) {
            int cost = d[next];
            if (next < max_n) cost = 0;
            if (dist[next] > dist[n] + cost) {
                dist[next] = dist[n] + cost;
                q.push({ next,max(max_n,next) });
            }
        }
    }
    cout << dist[t] << endl;
    return 0;
}

Measured memory_bytes: 10732
#include <stdio.h>

int main() {
  int a,b;
  scanf("%d%d",&a,&b);
  double x;
  int y;
  x = (double)(a+b)/2;
  y = (a+b)/2;

  if (x == y) {
    printf("%d\n", y);
  }else{
    printf("%d\n", y+1);
  }


  return 0;
}


Measured memory_bytes: 128
N=int(input())
mod=10**9+7

ANSLIST=[1]
for i in range(61):
    ANSLIST.append((ANSLIST[-1]*3-1)%mod)

ANS=[1, 2, 4, 5]
ANSDICT=dict()
def ans(k):
    if 0<=k<=3:
        return ANS[k]
    if ANSDICT.get(k)!=None:
        return ANSDICT[k]
    for i in range(61):
        if k==2**i-2:
            return ANSLIST[i]-1
        if k==2**i-1:
            return ANSLIST[i]
        if 2**i-1>k:
            break
    x=k-(2**(i-1)-1)

    ANSDICT[k]=(ans(x-1)+ANSLIST[i-1]*2-ans(2**(i-1)-x-2)-1)%mod
    return ANSDICT[k]

print(ans(N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << "time consumed : " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    //filein;
    //fileout;

    string str;
    cin >> str;
    int len=str.size();
    int ans=len;
    int temp;
    for(int i=0;i<len-1;i++)
    {
		if(str[i]!=str[i+1])
		{

			temp=max(len-i-1,i+1);
		    ans=min(temp,ans);

		}
    }
    printf("%d\n",ans);





}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    S = input()
    T = input()

    counter_max = len(T)
    for i in range(len(S) - len(T) + 1):
        counter = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                counter += 1
        counter_max = min(counter_max, counter)        
    print(counter_max)

if __name__ == "__main__":
    main()



Measured memory_bytes: 9056
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define mkp(a,b) make_pair(a,b)
#define PI 3.14159265359
#define mset(arr,val) memset(arr,val,sizeof arr)
#define MAXN (ll)2e5+1
#define eb emplace_back
#define mod (long long)(1e9+7)
#define FILE_READ freopen("input.txt","r",stdin)
#define FILE_WRITE freopen("output.txt","w",stdout)
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    FILE_READ;
//    FILE_WRITE;

    string s;
    cin>>s;
    bitset<MAXN> bs(0);
    int ans1=0,ans2=0;
    for(int i=0;i<MAXN;i+=2) {
        bs.set(i,true);
    }
    for(int i=0;i<s.size();++i) {
        ans1+=(bs[i]^(s[i]-'0'));
    }
    bs.flip();
    for(int i=0;i<s.size();++i) {
        ans2+=(bs[i]^(s[i]-'0'));
    }
    cout<<min(ans1,ans2);

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
int main(){
    // Your code
    int a,b,c,d;
    cin >> a;

    if(a==1){
        cout << "Hello World"<<endl;
    }

    if(a==2){
        cin >> b >> c;
        cout << b+c <<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    ll sum = 0;
    rep(i,0,N)rep(j,i+1,N){
        sum += V[i] * V[j];
    }
    cout << sum << endl;
}

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

vector<int> g[100005];

int dis[100005];
int ind[100005];
bool vis[100005];

void dfs(int cur){
   vis[cur] = true;
   
   for(auto i: g[cur]){
	   
	   if(!vis[i]) dfs(i);
	     
	   dis[cur] = max(dis[cur],1 + dis[i]);
   }	
	
} 



int main() {
	
	int n,m;
	cin >> n >> m;
	int u,v;
	memset(vis,false,sizeof(vis));
	
	for(int i =0;i<m;i++){
		cin >> u >> v;
		g[u].push_back(v);
     //   ind[v]++;		 
	}
	
	int ans = 0;
	
	for(int i =1;i<=n;i++){
		
		if( vis[i] == false){
			dfs(i);
		}	
	}
	
   for(int i =1;i<=n;i++) ans = max(ans,dis[i]);
	
   cout << ans << endl; 	
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls ro<<1
#define fi first
#define se second
#define rs ro<<1|1
#define ll long long
#define pb push_back
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define lson ro<<1,l,mid
#define umap unordered_map
#define uset unordered_set
#define rson ro<<1|1,mid+1,r
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;
const int N=1e6+10;

int a[N];

int main() {
	IOS;
	int n,k;
	cin>>n>>k;
	int sum=0;
	for(int i=1;i<=k;i++){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=n)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 640
one = list(map(int, input().split()))
two = list(map(int, input().split()))
thr = list(map(int, input().split()))

n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

ans = False

#斜め
if one[0] in b and two[1] in b and thr[2] in b:
    ans = True
if one[2] in b and two[1] in b and thr[0] in b:
    ans = True
#縦
if one[0] in b and two[0] in b and thr[0] in b:
    ans = True
if one[1] in b and two[1] in b and thr[1] in b:
    ans = True
if one[2] in b and two[2] in b and thr[2] in b:
    ans = True
#横
if one[0] in b and one[1] in b and one[2] in b:
    ans = True
if two[0] in b and two[1] in b and two[2] in b:
    ans = True
if thr[0] in b and thr[1] in b and thr[2] in b:
    ans = True

if ans == False:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064