akhauriyash/Code-Regression huggingface dataset:
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll gcd(ll a,ll b){
    if(a<b) return(gcd(b,a));
    if(a%b==0) return b;
    else return(gcd(b,a%b));
}

int main()
{
    ll a,b,i=2;
    cin>>a>>b;
    ll g=gcd(a,b);
    ll n=g;
    vector<ll> v;
    v.pb(1);

    while(i<=sqrt(n)){
        if(g%i==0)
        v.pb(i);
        while(g%i==0)
        g=g/i;
        i++; 
    }
    if(g!=1) v.pb(g);
    cout<<v.size();
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0 )break;
			else calc(n);
			
		}
	}
	public void calc(int n){
		int[][] days = new int[n][31];
		int[][][] memo = new int[n][31][n];
		
		for(int i = 0; i < n; i++){
			memo[i][0][i] = 1;
		}
		
		for(int i = 0; i < n; i++){
			int f = sc.nextInt();
			for(int j = 0; j < f; j++){
				int d = sc.nextInt();
				days[i][d] = 1;
			}
		}
	
		int ans = -1;
		for(int d = 1; d < 31; d++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(memo[i][d-1][j] == 1){
						memo[i][d][j] = 1;
					}
					if(days[i][d] == 1 && days[j][d] == 1){
						for(int k = 0; k < n; k++){
							if(memo[j][d-1][k] == 1){
								memo[i][d][k] = 1;
							}
						}
					}
				}
				int sum = 0;
				for(int j = 0; j < n; j++){
					if(memo[i][d][j] == 1) sum++;
					else break;
				}
				if(sum == n){
					ans = d;
					break;
				}
			}
			if(ans != -1){
				break;
			}
		}
		System.out.println(ans);
	}
	

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 95796
package main


import "fmt"


func max(a int, b int) int {
  if a > b {
    return a
  } else {
    return b
  }
}


func min(a int, b int) int {
  if a < b {
    return a
  } else {
    return b
  }
}


func main () {
  var a, b int
  fmt.Scanf("%d %d", &a, &b)

  if a != b {
    fmt.Println(2*max(a, b)-1)
  } else {
    fmt.Println(2*a)
  }
}


Measured memory_bytes: 512
"use strict";

function main(input){
  const args = input.trim().split('\n');
  let bb = args[1].split(' ').map(_=>parseInt(_,10));
  
  let i=0;
  while(bb.every(_=>_%2==0)){
    bb = bb.map(_=>_/2);
    i++;
  }
  
  console.log(i);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

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

int ans = 0;

void pf(ll x) {
    if (x%2==0) {
        ans++;
        while (x%2==0) {
            x/=2;
        }
    }
    for (ll j=3; j*j<=x; j+=2) {
        if (x%j==0) {
            ans++;
            while (x%j==0) x/=j;
        }
    }
    if (x>2) ans++;
}

int main() {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    ll k = __gcd(a, b);
    ans = 0;
    pf(k);
    printf("%d\n", ans+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 100000 + 10;

int main() {
	ll n;
	cin>>n;
	for(int h=1;h<=10000;h++){
		for(int m=1;m<30000;m++){
			double q = (4.0/n);
			double v = (1.0/h)+(1.0/m);
			q -= v;
			double w = 1/q;
			ll t = 1/q;
			if(w > 0&&q!=0&&ceil(w)==t&&t!=0&&t<=3500){
				cout << h << " " << m << " " << w << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n, k;
	cin >> n >> k;
	ll min = 0;
	ll max = n;
	REP(_, k) {
		ll a, b;
		cin >> a >> b;
		MAX(min, a);
		MIN(max, b);
	}
	ll p = max - min;
	cout << ((p < 0) ? 0 : p + 1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    int a[30][30];
    for(int i = 0; i < h; i ++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    int ans = 1e9;
    for(int x = 0; x < h; x++)for(int y = 0; y < w; y++){
        int sum = 0;
        for(int i = 0; i < h; i++)for(int j = 0; j < w; j++){
            sum += min(abs(i-x),abs(j-y))*a[i][j];
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
}



Measured memory_bytes: 3116
N = int(input())
T = [[] for i in range(N)]
for i in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = u - 1, v - 1
    T[u].append([v, w])
    T[v].append([u, w])


color = [-1] * N
stack = [[0, 0]]
while stack:
    n, w = stack.pop()
    color[n] = w % 2

    for to, to_w in T[n]:
        if color[to] >= 0:
            continue

        stack.append([to, w + to_w])

print(*color, sep='\n')


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

int n,a,b,c,l[10],ans=2e9;

void dfs(int i, int x, int y, int z, int combo){
	if(i > n){
		if(x&&y&&z){
			ans = min(ans,abs(x-a)+abs(y-b)+abs(z-c)+combo*10);
		}
		return;
	}
	dfs(i+1,x+l[i],y,z,combo+1);
	dfs(i+1,x,y+l[i],z,combo+1);
	dfs(i+1,x,y,z+l[i],combo+1);
	dfs(i+1,x,y,z,combo);
}


int main()
{
	cin >> n >> a >> b >> c;
	for(int i = 1; i <= n; i++) cin >> l[i];
	dfs(1,0,0,0,-3);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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


 ll n;
 cin>>n;
 if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
 {
     cout<<"hon"<<endl;
 }
 else if(n%10==3)
 {
     cout<<"bon"<<endl;
 }
 else{
    cout<<"pon"<<endl;
 }
return 0;
}



Measured memory_bytes: 3656
import sys
input = sys.stdin.readline
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def solve():  
  n,m = (int(i) for i in input().split())
  p = list(int(i) for i in input().split())
  uf = UnionFind(n)
  for i in range(m):
    x,y = (int(i) for i in input().split())
    uf.union(x-1,y-1)
  ans = 0
  for i in range(n):
    number = p[i]
    if uf.same(i,number-1):
      ans += 1
  print(ans)
solve()

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

int main(void) {
	string c;
	cin >> c;
	if (c =="a") {
		cout << "vowel" << endl;
	}
	
	else if (c == "i") {
		cout << "vowel" << endl;
	}
	
	else if (c == "u") {
		cout << "vowel" << endl;
	}
	
	else if (c == "e") {
		cout << "vowel" << endl;
	}
	
	else if (c == "o") {
		cout << "vowel" << endl;
	}
	else {
		cout <<"consonant"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String s = in.next();
		String t = in.next();
		System.out.println(t + s);
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
 
int main(){
  
  int N,M,X;
  scanf("%d%d%d",&N,&M,&X);
  
  int i,A[M];
  for(i = 0; i < M; i++){
    scanf("%d",&A[i]);
  }
  
  int cost;
  i = 0;
  while(A[i] < X){
    i++;
  }
  
  cost = i < M - i ? i : M - i;
  printf("%d",cost);
  
  return 0;
  
}

Measured memory_bytes: 128
#coding:utf-8
s = input()
K = int(input())
n = len(s)
alpha = list("abcdefghijklmnopqrstuvwxyz")
ans = []
for al in alpha:
    if al in s:
        for i in range(n):
            if al == s[i]:
                for j in range(1,6):
                    if i+j <= n:
                        ans.append(s[i:i+j])
        ans = dict.fromkeys(ans)
        ans = list(ans.keys())
    if len(ans) >= 5:
        break

ans.sort()
try:
    ans.remove("")
except:
    pass
print(ans[K-1])
            


Measured memory_bytes: 4212
#include<stdio.h>

int main(void)
{
  int x,y;
  char a[10];
  int i = 0;
  scanf("%d", &x);
  scanf("%s", a);
  scanf("%d", &y);
  
  for (i = 0;i < x; i++){
    if(a[i] != a[y - 1]){
      a[i] = '*';
    }
  }
  printf("%s", a);
  return(0);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main() {
    int N;
    cin >> N;
    int i = 0;
    int ookii = 0;
    int goukei = 0;
    while(i < N){
        int tmp;
        cin >> tmp;
        if(tmp > ookii){
            ookii = tmp;
            i++;
        }
        else{
            i++;    
        }
        goukei = goukei + tmp;
    }
    if(goukei - ookii > ookii){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,ansn;
int main(){
	cin>>n;
	for (ll i=1,j=0;i<=n;i=j+1){
		j=n/(n/i);
		if (i==j){
			if (n%i==n/i)ansn+=i;
		}else{
			ll s=n/i;
			ll l=n%j,r=n%i,k=(n%(j-1))-(n%j);
			if (s>=l&&s<=r&&(s-l)%k==0)ansn+=j-((s-l)/k);
		}
	}
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;

int main() {
int n,i,count=0;
cin>>n;
int a[n];
for(i=1;i<=n;i++)
cin>>a[i];

for(i=1;i<=n;i++)
{
	if(i%2==1 && a[i]%2==1)
	count++;
}
cout<<count<<endl;
}

Measured memory_bytes: 3576
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(scan.hasNext())
	    {
	int n=scan.nextInt();
	int i=0,field=0;
	if(n==1)
	    {
		field=2*n;
	    }
	else
	    {
		field=2;
		for(i=2;i<=n-1;i++)
		    {
			field+=i;
			
		    }
		field+=n;
		
		
		
	    }
	System.out.println(field);
	    }
    }
}

Measured memory_bytes: 18080
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n,A[MAXN],dp[MAXN],b4[MAXN];
int main()
{
	// freopen("int","r",stdin);
	FAST
	cin>>n;
	FOR(i,0,n)cin>>A[i];
	pi ans=pi(-LLINF,-1);
	pi mx[2]={pi(-LLINF,0),pi(-LLINF,0)};
	FOR(i,0,n){
		if(mx[i%2].f>0) dp[i]=mx[i%2].f+A[i], b4[i]=mx[i%2].s;
		else dp[i]=A[i],b4[i]=i;
		mx[i%2]=max(mx[i%2],pi(dp[i],i));
	}
	FOR(i,0,n) ans=max(ans,pi(dp[i],i));
	cout<<ans.f<<'\n'; pi copyy=ans; ll op=0; for(ll i=n-1;i>ans.s;--i)op++;while(b4[ans.s]!=ans.s){ll diff=ans.s-b4[ans.s]-1; assert(diff>=1);ll times=(diff+1)>>1ll;ll add=0;while(times--){op++;++add;}ans.s=b4[ans.s];}for(ll i=0;i<ans.s;i++)op++;
	cout<<op<<'\n'; ans=copyy; for(ll i=n-1;i>ans.s;--i)cout<<i+1<<'\n';
	while(b4[ans.s]!=ans.s){
		ll diff=ans.s-b4[ans.s]-1; assert(diff>=1);
		ll times=(diff+1)>>1ll;++diff;diff/=2;
		ll add=0;while(times--){cout<<b4[ans.s]+diff+1-add<<'\n';++add;}
		ans.s=b4[ans.s];
	}
	for(ll i=0;i<ans.s;i++)cout<<1<<'\n';
}


Measured memory_bytes: 4352
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, r[2];
    int max = 0, num = 20;
    cin >> n;
    rep(i,n){
        cin >> r[0] >> r[1];
        if(max < r[1]){
            max = r[1];
            num = r[0];
        }else if(max == r[1] && num > r[0]){
            num = r[0];
        }
    }
    cout << num << ' ' << max << endl;
}

Measured memory_bytes: 1160
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = set()
for _ in range(n):
    b.add(int(input()))


if a[0][0] in b and a[0][1] in b and a[0][2] in b:
    print("Yes")
    exit()
elif a[1][0] in b and a[1][1] in b and a[1][2] in b:
    print("Yes")
    exit()
elif a[2][0] in b and a[2][1] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[0][0] in b and a[1][0] in b and a[2][0] in b:
    print("Yes")
    exit()
elif a[0][1] in b and a[1][1] in b and a[2][1] in b:
    print("Yes")
    exit()
elif a[0][2] in b and a[1][2] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n, k;
vector<int> bad_d(10, 0);

void read()
{
	cin >> n >> k;
	for(int i = 0; i < k; i++)
	{
		int x;
		cin >> x;
		bad_d[x] = 1;
	}
}

bool ok(int x)
{
	while(x)
	{
		if(bad_d[x % 10]) return false;
		x /= 10;
	}

	return true;
}

void solve()
{
	while(!ok(n)) n++;
	cout << n << endl;
}

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

	read();
	solve();
	return 0;
}



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

# N = 25

def calculate(n):
    result = {}

    for index in range(1, n + 1):

        i = int(str(index)[0])
        j = int(str(index)[-1])
        if result.get((i, j)) == None:
            if i != 0:
                result.__setitem__((i, j), 1)
        else:
            result.__setitem__((i, j), result.get((i, j)) + 1)

    res = 0
    for i in range(10):
        for j in range(10):
            s1 = result.get((i, j))
            s2 = result.get((j, i))

            s1 = 0 if s1 == None else s1
            s2 = 0 if s2 == None else s2

            res += s1 * s2

    print(res)


calculate(N)


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
#define MAX 3005
const int M=1e9+7;
const ll INF = 1LL << 60;
typedef pair<int,int> pii;
typedef double ld;
bool visited[MAX];
vector<int>adj[MAX];
ll n;
ll dp[MAX][MAX],a[MAX];
ll d(int i ,int j)
{
	if(dp[i][j])
		return dp[i][j];
	ll ret;
	if((n-(i-j))%2==0)
	{
		if(j-i==1)
			return a[i];
		ret=-INF;
		ret=max(d(i+1,j)+a[i],d(i,j-1)+a[j-1]);
	}
	else
	{
		if(j-i==1)
			return 0;
		ret=INF;
		ret=min(d(i+1,j),d(i,j-1));
	}
	return dp[i][j]=ret;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll x = d(0,n);
	ll y = sum-x;
	cout<<x-y<<endl;
	return 0;	
}


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

int main() {
    int h1, m1, h2, m2, K; cin >> h1 >> m1 >> h2 >> m2 >> K;
    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;
    cout << t2 - t1 - K << endl;
}

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

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

//#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
//template<typename Arg> void __f(const char* name, Arg&& arg) {
//  cerr << name << " = " << arg << std::endl;
//} template <typename Arg1, typename... Args>
//void __f(const char* names, Arg1&& arg1, Args&&... args) {
//  const char* comma = strchr(names + 1, ',');
//  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // OST: find_by_order, order_of_key
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//#pragma GCC optimize("Ofast")
//optimize("unroll-loops")
//target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
///*** RNGS ***/
//SEED=chrono::steady_clock::now().time_since_epoch().count();
//// or high_resolution_clock
//mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
//uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
//struct chash {int operator()(int x) const {return x^SEED;}};
//gp_hash_table<int,int,chash>m;//use cc if very less updates
///*** FAST IO ***/
//inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
//while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();}
//while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
//return y?-x:x; }

const int MAXN = 3010;
const int MOD = 1000000007;
int dp[MAXN][MAXN], psum[MAXN];

string s;

int main() {
    #ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
//    freopen("sample.out", "w", stdout);
    #else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    #endif
    int n;
    cin >> n;
    cin >> s;
    s = "  " + s;
    for(int pos=1; pos<=n; ++pos) {
        for(int val=1; val<=pos; ++val) {
            int &y = dp[pos][val];
            if(pos == 1) {
                y = 1;
                continue;
            }
            if(s[pos] == '<') {
                y = psum[val-1];
            }
            else { //s[pos] == '>'
                y = psum[pos-1] - psum[val-1];
                if(y < 0) y += MOD;
            }
        }
        for(int val=1; val<=pos; ++val) {
            psum[val] = dp[pos][val] + psum[val-1];
            if(psum[val] >= MOD) psum[val] -= MOD;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; ++i) {
        ans += dp[n][i];
        if(ans >= MOD) ans -= MOD;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31224
#include <bits/stdc++.h>
// #include<iostream>
// #include<vector>
// #include<cmath>
// #include<iomanip>
using namespace std;
 
const double PI= acos(-1.0);
 
int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
   // freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long a; double b; cin >> a >> b;
    b*=100;
    int bl = (int)(round(b));
    cout << (a*bl)/100;
    return 0;
}

Measured memory_bytes: 3752
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        Arrays.sort(s);
        String s_1 = new String(s);
        Arrays.sort(t);
        StringBuilder sb = new StringBuilder(new String(t));
        sb.reverse();
        String ans = s_1.compareTo(sb.toString()) < 0 ? "Yes" : "No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<string>
#include<iostream>


int main(){
	//入力機構
	std::string S;
	size_t N;
	std::cin>>N>>S;
	//処理機構
	//全ての場所について何人必要か数えてみるのは辛い。
	//i番目をリーダーとした時の人数を用いるとi+1番目をリーダーとした時の人数を計算するのはS[i]S[i+1]を調べれば良いだけになるのでそれを使う。
	//0番目をリーダーとした時の方向を変える必要のある人数を求める
	int count=0,ans;
	for(size_t i=1;i<N;i++){
		//1番目以降のうち東を向いている人の数を求める
		if(S[i]=='E'){
			count++;
		}
	}
	ans=count;
	//これを基準に答えを見つける
	for(size_t i=0;i+1<N;i++){
		//i+1番目をリーダーとする
		//i番目が西を向いていたら、それを東に向ける手間がかかるのでcountを+1する
		if(S[i]=='W'){
			count++;
		}
		//i+1番目が東を向いていたら、それを西に向ける手間が省けるのでcountを-1する
		if(S[i+1]=='E'){
			count--;
		}
		//ans更新
		if(ans>count){
			ans=count;
		}
	}

	//出力機構
	std::cout<<ans<<std::endl;

	return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MAX = 100000;
const long long INF = 1 << 21;

class Edge{
public:
    int t, w;
    Edge(){}
    Edge(int t, int w) : t(t), w(w){};
};

vector<Edge> G[MAX];
int n, d[MAX];

void bfs(int s){
    for(int i = 0; i < n; i++) d[i] = INF;

    queue<int> Q;

    Q.push(s);
    d[s] = 0;

    int u;
    while( !Q.empty() ){
        u = Q.front(); Q.pop();
        for( int i = 0; i < G[u].size(); i++ ){
            Edge e = G[u][i];
            if( d[e.t] == INF){
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
    
}

void solve(){
    bfs(0);

    int farther_point;
    int farther_dist = 0;
    for(int i = 0; i < n; i++){
        if(d[i] == INF) continue;
        if(d[i] > farther_dist){
            farther_dist = d[i];
            farther_point = i;
        }
    }

    bfs(farther_point);

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(d[i] == INF) continue;
        ans = max(ans, d[i]);
    }

    cout << ans << endl;
}

int main(){
    cin >> n;

    int s, t, w;
    rep(i,n-1){
        cin >> s >> t >> w;
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    solve();

    return 0;
}


Measured memory_bytes: 9868
#include<iostream>
using namespace std;
int main() {
    int S[14] = {0}, H[14] = {0}, C[14] = {0}, D[14] = {0};
    string s;
    int n, r;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s >> r;
        if (s == "S") S[r] = 1;
        else if (s == "H") H[r] = 1;
        else if (s == "C") C[r] = 1;
        else if (s == "D") D[r] = 1;
    }
    
    for (int i = 1; i <= 13; i++) {
        if (S[i] == 0) cout << "S " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (H[i] == 0) cout << "H " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (C[i] == 0) cout << "C " << i << endl;
    }
    for (int i = 1; i <= 13; i++) {
        if (D[i] == 0) cout << "D " << i << endl;
    }
    
    return 0;
}


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

using namespace std;

int64_t solve(const std::vector<int>& as) {
  int const n = as.size();
  int64_t ret = 0;
  for (int i = n - 2; i >= n / 3; i -= 2) {
    ret += as[i];
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n * 3);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::sort(as.begin(), as.end());
  std::cout << solve(as) << std::endl;
  return 0;
}

Measured memory_bytes: 1408
using System;

namespace AtCoder{
    class Program{
        static void Main(string[] args){
            string[] input = Console.ReadLine().Split(' ');
            Int64 a = int.Parse(input[0]);
            Int64 b = int.Parse(input[1]);
            Int64 c = int.Parse(input[2]);
            Int64 d = int.Parse(input[3]);
            Int64[] sum = new Int64[]{a * c, a * d, b * c, b * d};
            Array.Sort(sum);
            Console.WriteLine(sum[3]);
        }
    }
}


Measured memory_bytes: 27420
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_YX = 110;
const int INF = 1000000000;

long long int v[MAX_YX][MAX_YX];
int my[] = {0, 0, 1, -1};
int mx[] = {1, -1, 0, 0};

void dfs(int y, int x, long long int t){
  v[y][x] = -1;
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i];
    if(ny >= 0 && nx >= 0 && ny < MAX_YX && nx < MAX_YX && v[ny][nx] == t) dfs(ny, nx, t);
  }
}

int solve(){
  int res = 0;
  REP(i, MAX_YX){
    REP(j, MAX_YX){
      if(v[i][j] == -1) continue;
      ++res;
      dfs(i, j, v[i][j]);
    }
  }
  return res;
}

int main(){
  int N;
  while(cin >>N && N){
    memset(v, 0, sizeof(v));
    vector<int> L, T, R, B;
    set<int> Ys, Xs;
    REP(i, N){
      int l, t, r, b;
      cin >>l >>t >>r >>b;
      L.push_back(l); T.push_back(t); R.push_back(r); B.push_back(b);
      Ys.insert(t); Ys.insert(b); Xs.insert(l); Xs.insert(r);
    }
    Ys.insert(-1); Ys.insert(INF);
    Xs.insert(-1); Xs.insert(INF);
    vector<int> Y(Ys.begin(), Ys.end());
    vector<int> X(Xs.begin(), Xs.end());
    REP(i, N){
      int xl = lower_bound(X.begin(), X.end(), L[i]) - X.begin();
      int xr = lower_bound(X.begin(), X.end(), R[i]) - X.begin();
      int yt = lower_bound(Y.begin(), Y.end(), T[i]) - Y.begin();
      int yb = lower_bound(Y.begin(), Y.end(), B[i]) - Y.begin();
      FOR(x, xl, xr) FOR(y, yb, yt) v[x][y] |= (1LL << i);
    }
    cout <<solve() <<endl;
  }
  return 0;
}

Measured memory_bytes: 1892
#include <bits/stdc++.h>
using namespace std;
int main() {
string S, T; 
cin >> S >> T; 
int A[30] = {}, B[30] = {}; 
int L = S.size(); 
for (int i = 0; i < L; ++i){
A[S.at(i) - 'a'] ++; 
}
for (int i = 0; i < L; ++i){
B[T.at(i) - 'a'] ++; 
}
sort(A, A + 26);
sort(B, B + 26); 
string ans = "Yes"; 
for (int i = 0; i < 26; ++i){
if(A[i] != B[i]){
ans = "No"; 
break; 
}
}
cout << ans << endl; 
}

Measured memory_bytes: 776
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
a = n.times.map { gets.split.map(&:to_i) }
a.sort_by! { |a| a[0] }
sum = 0
cnt = 0
a.each do |aaa, bbb|
  if m < cnt + bbb
    sum += aaa * (m - cnt)
    break
  else
    sum += aaa * bbb
    cnt += bbb
  end
end
puts sum


Measured memory_bytes: 12664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = 0;
        int r = 0;
        double f = 0;
        
        d = a / b;
        r = a % b;
        f = (double)a / b;
        
    System.out.printf("%d %d %.6f\n", d, r, f);    
    }
}



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

int main() {
	int r[200001], n, max,min;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> r[i];
	}
	min = r[0];
	max = r[1] - r[0];
	for (int i = 1; i < n ; i++) {
			if (r[i] - min > max) {
				max = r[i] - min;
			}
			if (min > r[i])min = r[i];
	}
	cout << max << endl;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

vector<int> prime;
vector<int> ls;

void sieve(int N){
    prime.resize(N+1,1);
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<=N;i++){
        for(int j=i*i;j<=N;j+=i){
            prime[j] = 0;
        }
    }
    for(int i=2;i<=N;i++){
        if(prime[i])ls.push_back(i);
    }
}

int main() {
    sieve(int(1e5));
    int n;
    while(cin >> n){
        int cnt = 0;
        for(int i=0;ls[i]<=n;i++){
            if(prime[n+1-ls[i]]) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
from collections import deque
h, w = map(int, input().split())
c = [list(input()) for _ in range(h)]
moves = ((1, 0), (0, 1))
sy = 0
sx = 0
ty = h-1
tx = w-1

def bfs(sy, sx):
    a,b = 0,0
    dist = [[float('inf')]*w for _ in range(h)]
    dist[0][0] = 0
    if c[0][0] == '#':
        dist[0][0] = 1
    
    for i in range(h-1):
        if c[i+1][0] == "#" and c[i][0] == ".":
            dist[i+1][0] = dist[i][0] + 1
        else:
            dist[i+1][0] = dist[i][0]
            
    for i in range(w-1):
        if c[0][i+1] == "#" and c[0][i] == ".":
            dist[0][i+1] = dist[0][i] + 1
        else:
            dist[0][i+1] = dist[0][i]
            
    for i in range(1,h):
        for j in range(1,w):
            if c[i][j] == "#" and c[i-1][j] == ".":
                a = dist[i-1][j] + 1
            else:
                a = dist[i-1][j]
                
            if c[i][j] == "#" and c[i][j-1] == ".":
                b = dist[i][j-1] + 1
            else:
                b = dist[i][j-1]
                
            dist[i][j] = min(a,b)
 
    return dist 
 
dist = (bfs(0, 0))
print(dist[ty][tx])

Measured memory_bytes: 41840
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

H, W, D = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(H)]
aToHW = {}
for h, row in enumerate(A):
    for w, a in enumerate(row):
        aToHW[a] = (h, w)

Q = int(input())

@lru_cache(maxsize=None)
def search(now):
    if not now + D in aToHW:
        return 0

    l, r = aToHW[now], aToHW[now + D]
    return abs(l[0] - r[0]) + abs(l[1] - r[1]) + search(now + D)

ans = []
for _ in range(Q):
    l, r = map(int, input().split())

    ans.append(search(l) - search(r))

print(*ans, sep='\n')


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

int main()
{
    int n;
    cin >> n;
    int i = 1;
    while (++i <= n) {
      int x = i;
      if (x % 3 == 0) {
        cout << " " << i;
        continue;
      }
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
    cout << endl;
    return 0;
}


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

float mix(float x = 0, float y = 0){
    float res = (x + y) / 2;

    return res;
}

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

    int n = 0;
    cin>>n;
    vector<float> nums(n);

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


    while(nums.size() >= 2){
        sort(nums.begin(), nums.end());
        float first = nums[0];
        float last = nums[1];

        nums.erase(nums.begin() + 0, nums.begin() + 2);
        nums.push_back(mix(first, last));
    }

    cout<<nums[0];



    return 0;
}


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

using ll = long long;
const ll mod = 1e9 + 7;

void mkay(ll& a){
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
}

ll dp[22][1 << 22];
bool grid[22][22];
int n;

ll f(int idx, int mask){
	if(idx > n){
		/*if(mask != (1 << (n + 1)) - 1)
			return 0;*/
		return 1;
	}
	ll& ans = dp[idx][mask];
	if(ans != -1)
		return ans;
	ans = 0;
	for(int i = 1; i <= n; i++){
		if(mask & 1 << (i - 1) or !grid[idx][i])
			continue;
		mkay(ans += f(idx + 1, mask | (1 << (i - 1))));
	}

	return ans;
}


int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			cin >> grid[i][j];
	memset(dp, -1, sizeof dp);
	cout << f(1, 0) << endl;
}

Measured memory_bytes: 724548
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int x,y;
   cin >> x >> y;
   int ans = x+y/2;
   
   cout << ans << endl;




   return 0;
}

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

int main(){
  int ans = 0;
  int N,R,G,B; cin >> R >> G >> B >> N;
  for(int r = 0;r <= N; ++r){
    for(int g = 0; g <= N; ++g){
      double tmp = N-r*R-g*G;
      if(floor(tmp/B) == ceil(tmp/B) && tmp/B >= 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL m;
    LL ans=-1;
    LL d_num=0;
    LL tmp;

    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> tmp;
        d_num += tmp;
    }

    if(n>=d_num){
        ans = n-d_num;
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long
using namespace std;
const int kmod = 1e9 + 7;


int solve(int r ,int c , int rs ,int cs , vector<vector<int>>& dp ,vector<vector<char>> &board)
{
    if(r == rs  && c == cs)
     return 1;
    

    if(board[r][c] == '#')
     return 0;
    
    if(dp[r][c] != -1)
     return dp[r][c];

     int my = 0;
    if(r + 1 <= rs)
    my = (my % kmod + solve(r+1 , c , rs , cs ,dp , board)%kmod )%kmod ;

    if(c + 1 <= cs)
    my = (my % kmod + solve(r , c+1 , rs , cs ,dp , board) %kmod )%kmod;

    dp[r][c] = my;

    return my;
}
int main()
{
    
   int rs,cs;

   cin>>rs>>cs;


   vector<vector<char>>board(rs , vector<char>(cs));

   for(int i =0 ;i<rs ;i++)
   {
       for(int j = 0 ; j< cs ;j++)
        cin>>board[i][j];
   }
    
    vector<vector<int>>dp( rs , vector<int>( cs , -1));
   int ans = solve( 0 , 0 , rs -1 , cs -1, dp , board );

   cout<<ans<<endl;
}

Measured memory_bytes: 8680
import java.io.*;

class Main {
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {

            int n, x;
            int cnt, ave3, ave2;
            String[] tmpArray;  
            while( true ) {
                String str = kb.readLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                cnt = 0;
                ave3 = x / 3;
                int i, j, k;
                for( i=1; i<ave3; i++ ) {
                    ave2 = ( x-i ) / 2;
                    for( j=i+1; j<=ave2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            cnt++;
                        }
                    }
                }
                System.out.println( cnt );    
            }
        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}



Measured memory_bytes: 24408
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e5+200;
const int mod = 1e9+7;
int nxtpr[upperlimit];
bool isprime[upperlimit];
int main() {
	isprime[1]=true;
	int k=0;
	for(int i = 4; i < upperlimit; i+=2) isprime[i]=true;
	for(int i = 3; i*i < upperlimit; i+=2) if(! isprime[i]) for(int j = i*i; j < upperlimit; j+=2*i) isprime[j]=true;
	for(int i = upperlimit-1; i > 0; i--){
		if(! isprime[i]) k=i;
		nxtpr[i]=k;
	}
	int n;
	sd(n);
	pd(nxtpr[n]);
	return 0;
}

Measured memory_bytes: 768
import sys
MOD = 998244353


def main():
    n, *d = map(int, sys.stdin.buffer.read().split())
    e = [0]*n
    for i in d:
        e[i] += 1
    ans = e[0]
    for i in d[1:]:
        ans *= e[i-1]
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19112
#include <stdio.h>

int main(void){

	int n;
	int a, b, c;
	int i;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a > b && a > c){
			if(a * a == b * b + c * c){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}else if(b > a && b > c){
			if(b * b == a * a + c * c){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}else if(c * c == a * a + b * b){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
	}
	
	return 0;
}

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

int main() {
    int N; cin >> N;
    int a[N], sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += a[i] * a[j];
        }
    }
    cout << sum << endl;
}


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

int main() {
    int H1, M1, H2, M2, K, tstart, tend;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    tstart = H1 * 60 + M1;
    tend = H2 * 60 + M2;
    cout << tend - tstart - K << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N=500+7;
int n;
ll k;
int a[N];
int mod[N];

bool ok(int d)
{
        for(int i=1;i<=n;i++)
                mod[i]=a[i]%d;
        sort(mod+1,mod+n+1);
        int j=n;
        ll cost=0;
        for(int i=1;i<j;i++)
        {
                while(mod[i] && i<j)
                {
                        int t=min(mod[i],(d-mod[j])%d);
                        mod[i]-=t;
                        mod[j]+=t;
                        cost+=t;
                        mod[j]%=d;
                        if(mod[j]==0)
                                j--;
                }
        }
        return (cost<=k);
}

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

        cin>>n>>k;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
                cin>>a[i];
                sum+=a[i];
        }

        int best=1;
        for(int j=1;j*j<=sum;j++)
                if(sum%j==0)
                {
                        if(ok(j))
                                best=j;
                        if(ok(sum/j))
                        {
                                best=sum/j;
                                break;
                        }
                }
        cout<<best<<"\n";


        return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int a,b,c; cin >> a >> b >> c;
  cout << a+b+c-max({a,b,c});
  //if (a%3==0 || b%3==0 || (a+b)%3==0){cout << "Possible";}
  //else {cout << "Impossible";}

  return 0;
}


Measured memory_bytes: 256