akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
// taking inputs
static BufferedReader s;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends
//......................................@uthor_Alx..............................................

public static void main(String[] args) throws  IOException{
       assign();
      String s1=read();
      if(s1.charAt(0)==s1.charAt(1)&&s1.charAt(1)==s1.charAt(2)){
      	out.write("No\n");
      }
      else{out.write("Yes\n");}
             
        out.flush();
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define bang_bang ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cases int t;cin>>t;while(t--)
#define pb push_back
#define ppb pop_back
#define mem(x,a) memset(x,a,sizeof(x));
#define ld long double
#define mp make_pair
#define limit 200005
#define inf 1e18
const int md = 998244353;

int movesx[3]={-1,0,1};
int movesy[3]={-1,0,1};

int moves[4][2]={{1,0},{-1,0},{0,1},{0,-1}};


bool cmp(int a,int b)
{
	return a>b;
}

int gcd(int a, int b){return b?gcd(b,a%b):a;}
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int power(int base,int exponent,int mod=inf)
{
    if(exponent==0)
        return 1;
    int temp=power(base,exponent/2,mod);
    temp=(temp*temp)%mod;
    if(exponent%2!=0)
    {
        temp=(temp*base)%mod;
        return temp;
    }
    return temp;
}

int ncr(int a,int b)
{
    int dp[b+1];
    mem(dp,0)
    dp[0]=1;
    for(int i=1;i<=a;i++)
        for(int j=min(i,b);j>0;j--)
            dp[j]=(dp[j]+dp[j-1])%md;
            //C(n,r)=C(n-1,r-1)+C(n-1,r)
    return dp[b];
}
int n,t;
float p;


signed main(){
    bang_bang
    //cases
    {
        int n,d,ans=0;
        cin>>n>>d;
        for(int i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            if(a*a+b*b<=d*d) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

int n, k, ans = INF;
bool d[10];

void dfs(int sum, int dep) {
	if (sum >= n) {
		ans = min(ans, sum);
		return;
	}

	if (dep > 0 && sum == 0)
		return;

	for (int i = 0; i < 10; ++i) {
		if (d[i] == false) {
			dfs(sum * 10 + i, dep + 1);
		}
	}
}

int main() {
	cin >> n >> k;
	int t;
	for (int i = 0; i < k; ++i) {
		cin >> t;
		d[t] = true;
	}

	dfs(0, 0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N;
  cin >> N >> A;
 
 if (N % 500 <= A)
 {
 	cout << "Yes" << endl;
 }

 else 
 {
 	cout << "No" << endl;
 }
}

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

int main(void){
  int n,cnt=0,aor=0;
  char str[1000000];

  cin >> n;
  for(int i=0;i<n;i++) cin >> str[i];

  for(int i=0;i<n;i++,cnt++){
    if(str[i]=='x') aor++;
    if(str[i]=='o') aor=0;
    if(aor==2) break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3216
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, u, w, deg[2][200001] = {};
	char s[200002];
	list *adj[200001] = {}, e[400001], *p;
	scanf("%d %d", &N, &M);
	scanf("%s", &(s[1]));
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		if (u == w) {
			deg[s[u] - 'A'][u]++;
			continue;
		}
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
		deg[s[w] - 'A'][u]++;
		deg[s[u] - 'A'][w]++;
	}
	
	int flag[200001] = {}, q[200001], head, tail;
	for (i = 1; i <= N; i++) {
		if (flag[i] == 1 || (deg[0][i] != 0 && deg[1][i] != 0)) continue;
		flag[i] = 1;
		q[0] = i;
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			for (p = adj[u]; p != NULL; p = p->next) {
				if (flag[p->v] == 1) continue;
				w = p->v;
				deg[s[u] - 'A'][w]--;
				if (deg[s[u] - 'A'][w] == 0) {
					flag[w] = 1;
					q[tail++] = w;
				}
			}
		}
	}
	for (i = 1; i <= N; i++) if (flag[i] == 0) break;
	if (i <= N) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 11748
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,k,n;
 cin >> n >> k;
 int a[n];
 for(i=0;i<n;i++)
 cin >> a[i];
 sort(a,a+n);
 for(i=1;i<n;i++)
 a[i]+=a[i-1];
 cout << a[k-1];
 return 0;
}

Measured memory_bytes: 3652
N = int(input())
li = list(map(int,input().split()))
even_li = [x for x in li if x%2 == 0]
ap = 0
for i in even_li:
    if i % 3 == 0 or i % 5 == 0:
        ap += 1
if even_li == []:
    print("APPROVED")
elif ap == len(even_li):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
A,B = map(int,input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
GCD = gcd(A,B)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ps = prime_factorize(GCD)
ps_uniq = list(set(ps))
print(len(ps_uniq)+1)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int bill = sc.nextInt();
    int numCnt = sc.nextInt();
    String[] array = new String[numCnt];
    for(int i = 0; i < numCnt;i++){
      array[i] = String.valueOf(sc.nextInt());
    }
	
    
    while(true){
      boolean check = false;
      String strBill = String.valueOf(bill);
      for(int x = 0;x < strBill.length();x++){
        if(Arrays.asList(array).contains(String.valueOf(strBill.charAt(x)))){
          check = true;
          break;
        }
      }
      if(!check){
        break;
      }
      bill++;
    }
    
    System.out.println(bill);
  }
}

Measured memory_bytes: 30548
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<string>
#include<utility>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)

string c[3];




int main() {
	Rep(i,3) cin>>c[i];
	cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<bool, int>> pairs(n,pair<bool, int>(false,0));
  
  REP(i,m){
    int p;
    string s;
    cin >> p >> s;
    p--;
    
    if(pairs[p].first == false){
      if(s == "AC"){
        pairs[p].first = true;
      }
      else{
        pairs[p].second += 1;
      }
    }
    
  }
    
  int ans1 = 0,ans2 = 0;
    
  REP(i,n){
    if(pairs[i].first){
      ans1++;
      ans2 += pairs[i].second;
    }
  }
      
  
  cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 4036
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    int s, w;
    cin >> s >> w;

    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
#define P pair<int,int>
using namespace std;

int main() {
	int a;
	while (cin >> a, a) {
		char t[100];
		for (int i = 0; i < a; i++)cin >> t[i];
		int b[26]{};
		for (int c = 0; c < a; c++) {
			char d = t[c];
			b[d - 'A']++;
			P e[26];
			for (int f = 0; f < 26; f++) {
				e[f] = P(b[f], f);
			}
			sort(e, e + 26, greater<P>());
			if (e[0].first > e[1].first + a - c - 1) {
				cout << char(e[0].second+'A')<<" "<<c+1 << endl;
				goto l;
			}
		}
		puts("TIE");
	l:;
	}
}

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




void solve(){
	int n ; 
	cin >> n ;
	int a[n] = {0};
	int dp[1000000] = {0};
	int mp[1000007] = {0};
	for(int i = 0 ;i < n ;i++)
	cin >> a[i],mp[a[i]]++;
	sort(a,a+n);
	for(int i = 0 ; i < n;i++)
	{
		for(int j = 1 ; j *a[i] <= a[n-1] ; j++)
		{
			if(j!=1 && mp[j*a[i]])dp[a[i]*j] = 1;
			if(j == 1 && mp[a[i]] >1)dp[a[i]] = 1;
		}		
	}
	int cnt = 0;
	for(int i =0 ; i < n ;i++) if(dp[a[i]] == 0)cnt++;
	cout << cnt ;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //f();
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


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

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<string> sub;
    for (int i = 1; i <= 5; ++i) {
        for (int j = 0; j < n - i + 1; ++j) {
            sub.emplace_back(s.substr(j, i));
        }
    }
    sort(sub.begin(), sub.end());
    sub.erase(unique(sub.begin(), sub.end()), sub.end());
    sort(sub.begin(), sub.end());
    cout << sub[k - 1] << endl;
}


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

int main(){
    int N, M;
    cin >> N >> M;

    const int costs[] = {2,5,5,4,5,6,3,7,6};
    vector<int> A(M);
    for(auto& a : A){
        cin >> a;
    }

    vector<vector<int>> dp(N + 1);
    dp[0].assign(10, 0);
    for(int i=0;i<N;i++){
        if(dp[i].size() == 0) continue;
        for(auto& a : A){
            int c = costs[a - 1];
            if(i + c > N) continue;
            vector<int> next_vec = dp[i];
            next_vec[0]++;
            next_vec[10 - a]++;
            if (dp[i + c].size() == 0){
                dp[i + c] = next_vec;
            }else{
                dp[i + c] = max(dp[i + c], next_vec);
            }
        }
    }
    assert(dp[N].size() != 0);

    for(int j=9;j>=1;j--){
        for(int k=0;k<dp[N][10 - j];k++){
            cout << j;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
from fractions import gcd
from functools import reduce
n = int(input())
l = list(int(input()) for _ in range(n))
 
def lcm_base(x,y):
  return x*y//gcd(x,y)
 
def lcm_list(t):
  return reduce(lcm_base,t)
  
print(int(lcm_list(l)))

Measured memory_bytes: 5076
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define int __int64_t
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}

pair<int, int> a[MAXN];

 main() {
  int n = readInt();
  for (int i = 1; i <= n; i++) {
    a[i] = {readInt(), readInt()};
  }
  sort(a + 1, a + 1 + n);
  multiset<int> s1;
  multiset<int> s2;
  for (int i = 1; i <= n; i++) {
    s2.insert(a[i].S);
  }
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    /// min(R) - max(L) + 1
    s2.erase(s2.find(a[i].S));
    s1.insert(a[i].S);
    
    int min_R_1 = *s1.begin();
    int min_R_2 = *s2.begin();
    
    ans = max(ans, max(1ll * min_R_1 - a[i].F + 1, 0ll) +
                       max(1ll * min_R_2 - a[n].F + 1, 0ll));
    s1.erase(s1.find(a[i].S));
    auto nxt = s1.end();
	if (nxt != s1.begin()) {
        nxt--;
        int kek = *nxt;
        if (kek <= a[i].S) {
        	ans = max(ans,
                  max(1ll * a[i].S - a[i].F + 1, 0ll) +
                      max(1ll * min((s1.size() > 0 ? *s1.begin() : (int)MOD), min_R_2) - a[n].F + 1, 0ll));
			
        } else {
        	s1.erase(s1.find(kek));
        	ans = max(ans,
                  max(1ll * min(1ll * a[i].S, 1ll * (kek)) - a[i].F + 1, 0ll) +
                      max(1ll * min((s1.size() > 0 ? *s1.begin() : (int)MOD), min_R_2) - a[n].F + 1, 0ll));
			s1.insert(kek);
		}
	}
	s1.insert(a[i].S);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,K=1,x,ok,ng,mid;
  cin>>N;
  vector<ll> a;
  a.push_back(-1);
  rep(i,N){
    cin>>x;
    ng=-1;ok=K;
    while(labs(ok-ng)>1){
      mid=(ok+ng)/2;
    //  cout<<mid<<" "<<a[mid]<<" "<<x<<"sdfhklasdg"<<endl;
      if(a[mid]<x){
        ok=mid;
      }else{
        ng=mid;
      }
    }
    a[ok]=x;
  //  cout<<i<<ok<<ng<<x<<endl;
    if(ok==K){
      a.push_back(x);
      K++;
    }
  }
  cout<<K<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)  //最大公約数
{
	if (a < b)
		swap(&a, &b);

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

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

long power(long x, int n) { //x^n 計算量O(logn)
	long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

int combination(int n, int r)
{
	if (r == 0 || r == n)
		return (1);
	else if (r == 1)
		return (n);
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int keta(int a, int n)
{
	if (n == 1)
		return a % 10;

	for (int i = 0; i < n - 1; i++)
		a /= 10;

	return a % 10;
}

int main()
{
	int N, M, L, K;
	int a[100000];

	scanf("%d%d", &N,&M);

	if (N == 1 && M == 1)
	{
		printf("0");
		return 0;
	}

	if (N == 0)
	{
		printf("%d", combination(M, 2));
		return 0;
	}

	if(N>=2 && M>=2)
		printf("%d", combination(N,2)+combination(M,2));
	else if(M>=2)
		printf("%d", combination(M, 2));
	else
		printf("%d", combination(N,2));


}


Measured memory_bytes: 256
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();
        if ((a * b) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }

}

Measured memory_bytes: 22996
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n, k;
  cin >> n >> k;
  cout << (n % k ? 1 : 0) << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int gcd(int x,int y) {
    if(y == 0) return x;
    else return gcd(y,x%y);
}
int main() {
   int k;
   cin >> k;
   int sum = 0;
   for(int a = 1; a <= k; a++) {
       for(int b = 1; b <= k;b++) {
           for(int c = 1; c <=k;c++) {
               sum += gcd(gcd(a,b),c);
           }
       }
   }
   cout << sum << endl;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>

bool prime[1300001];

int main(void){
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=1300000;i++){
		if(prime[i]){
			for(int j=i*2;j<=1300000;j+=i)prime[j]=false;
		}
	}
	while(1){
		int k;
		scanf("%d",&k);
		if(k==0)break;
		if(prime[k]){
			printf("0\n");
			continue;
		}
		int l=k,r=k;
		while(!prime[l])l--;
		while(!prime[r])r++;
		printf("%d\n",r-l);
	}
	return 0;
}

Measured memory_bytes: 2316
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double eps=1e-7;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double cross(P a,P b){return real(b*conj(a));}
double dot(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}
 
//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return imag((c-a)*conj(b-a))/abs(b-a);
}
 
bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}
 
//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  return min(min(abs(a-c),abs(a-d)),min(abs(b-c),abs(b-d)));
}
 
int main(){
  int T;
  cin>>T;
  while(T--){
    double ax,ay,bx,by,cx,cy,dx,dy;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;
     
    cout<< isintersect ( P(ax,ay) , P(bx,by) , P(cx,cy) , P(dx,dy) ) <<endl;
  //    printf("%.12f\n",dist( P(ax,ay) , P(bx,by) , P(cx,cy) , P(dx,dy) ) );
  }
}

Measured memory_bytes: 3268
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
#define NUM 6
#define MAX 5000
struct Data{int weight,cost;};
int main()
{
  int n;
  int dp[MAX+1]={0};
  Data item[NUM]={
    {200,380},{300,550},{500,850},{1000,1520},{1200,1870},{1500,2244}
  };
  for(int j=0;j<=MAX;j++)dp[j]=INT_MAX>>2;
  dp[0]=0;
  for(int i=0;i<NUM;i++){
    for(int j=item[i].weight;j<=MAX;j++){
      dp[j] = min( dp[j], dp[j-item[i].weight] + item[i].cost );
    }
  }

  while(cin>>n,n){
    cout<<dp[n]<<endl;
  }
}

Measured memory_bytes: 0
package main

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

func main() {
	A := nextInt()
	B := nextInt()

	if A < 10 && B < 10 {
		fmt.Println(A * B)
	} else {
		fmt.Println(-1)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  map<int,int> m;
  ll ans = 0;
  rep(i,n) {
    cin >> a[i];
    m[a[i]]++;
  }
  for (auto p : m) {
    int d = p.first - p.second;
    if (d > 0) ans += p.second;
    else ans += abs(d);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> mas(n, 0);
    for(int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        mas[tmp] = 1;
    }

    int sum1 = 0, sum2 = 0;
    for(int i = x; i < n; i++){
        sum1 += mas[i];
    }
    for(int i = x; i > 0; i--){
        sum2 += mas[i];
    }

    if(sum1 < sum2){
        cout << sum1 << endl;
    }
    else{
        cout << sum2 << endl;
    }

    return 0;
}

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

ll mod = 1e9+7 ;
const ld error = 1e-8;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
//mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll
//mt19937 rng(199);

inline ll MOD(ll x, ll m = mod){
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 2e5+ 10;
///===========================================  template  =======================================================

char str[nmax];
int lwork[nmax];
int rwork[nmax];

int main(){
    FASTIO;
    int n, k, c;
    cin>>n>>k>>c;

    cin>>str;

    for(int i = 0, last = 0; i<k; i++){
        for(; last<n; last++){
            if(str[last]  == 'o'){
                lwork[last] = i+1;
                last = last+c+1;
                break;
            }
        }
    }

    for(int i = 0, last = n-1; i<k; i++){
        for(; last>=0; last--){
            if(str[last]  == 'o'){
                rwork[last]++;
                last = last-c-1;
                break;
            }
        }
    }

    for(int i = n-1; i>0; i--)
        rwork[i-1] += rwork[i];

//    for(int i= 0; i<n; i++) cout<<lwork[i];
//    cout<<endl;
//    for(int i= 0; i<n; i++) cout<<rwork[i];
//    cout<<endl;

    for(int i = 0 ; i<n; i++){
        if(lwork[i] != 0 && rwork[i+1]<k+1-lwork[i]){
            cout<<i+1<<"\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3328
//雋ｰ縺・DP繝ｫ繝ｼ繝・
#include<bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Printarray(T f,U n){for(U i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<endl;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int h[n];rep(i,n)cin>>h[i];

  int dp[n];

  dp[0]=0;
  dp[1]=dp[0]+abs(h[1]-h[0]);

  rep2(i,2,n){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  //Printarray(dp,n);
  cout<<dp[n-1]<<endl;
}


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 5e5 + 5, LOG = 20;

int main() {
 
	sync;

	ll x, y; cin >> x >> y;
	int cnt = 0;
	while (x <= y) x *= 2, cnt++;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
// 11.07.2017



# include <iostream>
# include <cstdio>
//# include <conio.h>

using namespace std;



int main ()
{
//
//freopen ("A.TXT", "r", stdin);
//freopen ("A.OUT", "w", stdout);
//

   int a, i, n, p, m=0, k=0;
   long long int sum = 0, t;

//   scanf ("%d%d\n", &n, &p);
   cin >> n >> p;
   for ( i=0; i < n; i++ )
   {
//      scanf ("%d", &a);
      cin >> a;
      if ( a % 2 == 0 )
         k++;
      else
			m++;
   }
//
//printf ("n=%d p=%d m=%d k=%d\n", n, p, m, k);
//
   if ( p == 0 )
   {
      t = 1;
      sum = t;
      for ( i=2; i <= m; i+=2 )
      {
		   t = t*(m-i+1)*(m-i+2)/i/(i-1);
		   sum += t;
//printf ("== sum=%I64d t=%I64d\n", sum, t);
		}
		for ( i=0; i < k; i++ )
		   sum *= 2;
   }
   else
   {
	 	t = m;
	 	if ( m > 0 )
	 	   sum = m;
      for ( i=3; i <= m; i+=2 )
      {
		   t = t*(m-i+1)*(m-i+2)/i/(i-1);
		   sum += t;
//printf ("=  sum=%I64d t=%I64d\n", sum, t);
		}
      for ( i=0; i < k; i++ )
		   sum *= 2;
   }

   cout << sum;
//   printf ("%lld", sum);
//   printf ("%I64d", sum);

   return 0;
}


Measured memory_bytes: 256
S = list(input())
if 'N' in S and 'W' in S and 'S' in S and 'E' in S:
    print('Yes')
elif 'N' in S and 'S' in S and 'W' not in S and 'E' not in S:
    print('Yes')
elif 'N' not in S and 'S' not in S and 'W' in S and 'E' in S:
    print('Yes')
else:
    print('No')

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

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

notgoods = [False for _ in range(N)]

for m in range(M):
    a, b = list(map(int, input().split()))
    if H[a - 1] <= H[b - 1]:
        notgoods[a - 1] = True
    if H[b - 1] <= H[a - 1]:
        notgoods[b - 1] = True

print(N - sum(notgoods))


Measured memory_bytes: 20112
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 998244353;
long double const ep = .000000000000000001;
ll a , k , arr[N] , cul[N];
ll test(ll y){
	ll re = y * k;
	int p = a;
	re += 5 * (cul[p] - cul[p-y]);
	p -= y;
	for(int i = 5 ; i < 10000000 ; i+=2){
		if(y >= p){
			re += i * cul[p];
			return re;
		}else{
			re += i * (cul[p] - cul[p-y]);
			p -= y;
			if(re > 1e18)return 1e18;
		}
	}
}
int main() {
	
	scanf("%d%d",&a , &k);
	for(int i = 1 ; i <= a ; i++)scanf("%lld" , arr+i);
	for(int i = 1 ; i <= a ; i++)cul[i] = cul[i-1] + arr[i];
	ll ans = 1e18;
	for(int i = 1 ; i <= a ; i++){
		ans = min(ans , test(i));
	}
	printf("%lld\n", ans + a * k);
	return 0;	
}

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

#define const INF=1<<21;
int main(){
	int N,M,ans=0,count=1;
    std::cin >> N >> M;
    std::vector<std::pair<std::pair<int,int>,int>> a(M);
    std::vector<std::pair<int,int>> b(M);
    for(int i=0;i<M;++i){
        std::cin >> a[i].first.first >> a[i].first.second;
        a[i].second=i;
    }
    std::sort(a.begin(),a.end());
    for(int i=0;i<M;++i){
        b[a[i].second].first=a[i].first.first;
        b[a[i].second].second=count;
        if(a[i].first.first==a[i+1].first.first&&i!=M-1){
            count++;
        }else{
            count=1;
        }
        
    }
    for(int i=0;i<M;i++){
        printf("%06d",b[i].first);
        printf("%06d",b[i].second);
        std::cout << std::endl;

    }
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <limits.h>
#include <queue>

#define N 100

int n;
int M[N][N];
int d[N];

static void bfs(int s)
{
    std::queue<int> q;
    q.push(s);

    d[s] = 0;

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] == 0)
                continue;
            if (d[v] != INT_MAX)
                continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }

    for (int i = 0; i < n; i++) {
        printf("%d %d\n", i + 1, (d[i] == INT_MAX) ? -1 : d[i]);
    }
}

int main()
{
    int u, k;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
        d[i] = INT_MAX;
    }
    
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; j++) {
            int v;
            scanf("%d", &v);
            M[u - 1][v - 1] = 1;
        }
    }
    
    bfs(0);
    return 0;
}


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

ll get(ll a, ll b) {
  ll res = 1ll;
  while(b) {
    if(b & 1) res = (res * a) % MOD;
    b >>= 1ll;
    a = (a * a) % MOD;
  }
  return res;
}

int main() {
  int n; cin >> n;
  vector <int> a(n);
  for(auto &x : a) cin >> x;
  int sum = accumulate(a.begin(), a.end(), 0);
  if(sum % 10) {
    print(sum);
    return 0;
  }
  int ans = 0;
  for(auto x : a) {
    if((sum - x) % 10) {
      ans = max(ans, sum - x);
    }
  }
  print(ans);
}

Measured memory_bytes: 256
import numpy as np
 
k, n = map(int, input().split())
arr = list(map(int, input().split()))
diff = [0] * n
 
for i in range(1, n):
  diff[i] = arr[i] - arr[i-1]
diff[0] = k - arr[-1] + arr[0]
 
print(int(np.sum(diff) - max(diff)))

Measured memory_bytes: 34152
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int K = in.nextInt();
      int X = in.nextInt();
      int start = X - K + 1;
      int end = X + K - 1;
      
      System.out.print(start);
      for (int i = start + 1; i <= end; ++i) {
        System.out.print(" " + i);
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

signed main(){
    int n, m;
    cin >> n >> m;
    vi p(n);
    rep(i, n) p[i] = i;
    int ans = 0;

    UnionFind uni(n);
    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uni.unite(x, y);
    }
    rep(i, n){
        chmax(ans, uni.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5624
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

bool JudgeSquare(int n)
{
    int a = (int)sqrt((double)n); /* Nの平方根を求めint型に格納することで小数部分を捨てる。 */
    if (a*a == n) { /* a^2 と nが等しければ平方数と判断する */
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    char a[4], b[4];
    if (scanf("%s%s", a, b) < 2) return 0;

    string A = a;
    string B = b;

    string X = A + B;

    int x = stoi(X);

    printf("%s\n", JudgeSquare(x) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 1000000007
num = 0;
for i in range(N):
    Bi = A[i]
    n1 = 0
    for j in range(i):
        Bj = A[j]
        if(Bi > Bj):
            n1 += 1
    num += (K*(K-1)*n1//2)%MOD
    n2 = 0
    for j in range(i+1, N):
        Bj = A[j];
        if(Bi > Bj):
            n2 += 1;
    num += (K*(K+1)*n2//2)%MOD
print(num%MOD)


Measured memory_bytes: 3188
def prime_number(n)
  r = (0..n).to_a
  r[0] = r[1] = nil
  for d in r
    next unless(d)
    break if n**0.5 < d
    (2*d..n).step(d){|e| r[e] = nil}
  end
  r.delete(nil)
  return r
end

primes = prime_number(999999)

while n = gets
  n = n.to_i
  puts primes.select {|x| x <= n}.size
end

Measured memory_bytes: 16568
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll 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] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////



int main() {
	string s; cin >> s;
	string ans = "";
	REP(i, 3) {
		ans += s[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

struct RollingHash{
  vector<int64_t> hash;
  vector<int64_t> base_pow;
  int64_t base, mod;
  const int64_t DEFAULT_BASE = 1009, DEFAULT_MOD = 1e9+7;

  RollingHash(string S="", int64_t base_=-1, int64_t mod_=-1){
      base = base_ > 0 ? base_ : DEFAULT_BASE;
      mod = mod_ > 0 ? mod_ : DEFAULT_MOD;
      if(S.size() > 0) initialize(S);
  }

  void initialize(string& S){
      int N = S.size();
      vector<int> s(N);
      for(int i=0; i<N; i++) s[i] = S[i];
      initialize(s);
  }

  void initialize(vector<int>& S){
      hash.resize(S.size()+1);
      base_pow.resize(S.size()+1);
      hash[0] = 0;
      base_pow[0] = 1;
      for(int i=1; i<=S.size(); i++){
          hash[i] = (hash[i-1] * base + S[i-1]) % mod;
          base_pow[i] = base_pow[i-1] * base % mod;
      }
  }

  // 0-indexed, [a, b)
  int64_t between(int a, int b){
      return (mod + hash[b] - hash[a] * base_pow[b-a] % mod) % mod;
  }
};
 
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int ok = 0, ng = N/2+1;
  RollingHash rh1(S, 1007, 1e9+7), rh2(S, 2009, 1e9+9);

  while(ng-ok>1){
      int len = (ng+ok)/2;
      set<pair<int64_t, int64_t>> val;
      vector<pair<int64_t, int64_t>> v(N);
      bool success = false;
      for(int i=0; i+len<=N; i++){
          if(i >= len) val.insert(v[i-len]);
          v[i] = {rh1.between(i, i+len), rh2.between(i, i+len)};
          if(val.count(v[i])){
              success = true;
              break;
          }
      }
      (success ? ok : ng) = len;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 844
#include <stdio.h>
int main(){
    int n,i,p;
    char f[100][2];
    while(1){
        scanf("%d",&n);
        if (n==0) break;
        p=0;
        for (i=0;i<n;i++){
            getchar();
            scanf("%c%c",&f[i][0],&f[i][1]);
            if (i!=0){
                if ((f[i-1][0]!=f[i][0])&&(f[i-1][1]==f[i][1])){
                    p++;
                }
            }
        }
        printf("%d\n",p);
    }
    return 0;
}

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

int N, K;
const int MAX_N = 2100;
int A[MAX_N];
int MOD = 1.0e9 + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> A[i];

    ll plus_jun = 0;
    ll minus_jun = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            if (A[i] < A[j]) plus_jun++;
            else if (A[i] > A[j]) minus_jun++;
        }
    }

    ll A = minus_jun;
    A = (A * (K+1) )% MOD;
    A = (A * K) % MOD;
    A =  (A * modinv(2, MOD) ) % MOD;

    ll B = plus_jun;
    B = (B * (K-1)) % MOD;
    B = (B * K) % MOD;
    B = (B * modinv(2, MOD)) % MOD;

    ll ans = (A + B) % MOD;

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


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

namespace CSharpTest
{
	class Program
	{
		static void Main(string[] args)
		{
			var line1 = Console.ReadLine().Split(' ');
			var line2 = Console.ReadLine().Split(' ');

			var N = int.Parse(line1[0]);
			var K = int.Parse(line1[1]);
			var c = new Dictionary<int, int>();
			foreach(var l in line2)
			{
				c[int.Parse(l)] = c.ContainsKey(int.Parse(l)) ? c[int.Parse(l)] + 1 : 1;
			}

			//出現回数の少ない順にソート
			var sorted = c.OrderBy(a => a.Value).Take(Math.Max(0, c.Count - K));
			var ret = 0;
			foreach(var s in sorted)
				ret += s.Value;
			Console.WriteLine(ret);
		}
	}
}


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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    using ll = long long;
    ll a, b;
    cin >> a >> b;

    cout << a / __gcd(a, b) * b << endl;

    return 0;
%>

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N = int(input())
ad = [[] for i in range(N+1)]

edges = []
for i in range(N-1):
    a, b = list(map(int, input().split()))
    edges.append((a,b))
    ad[a].append(b)
    ad[b].append(a)

ans_max = 0
for i in range(1,N+1):
    ans_max = max(ans_max, len(ad[i]))

print(ans_max)

visited = [0 for i in range(N+1)]
seen = [0 for i in range(N+1)]
edge_color = defaultdict(int)
node_color = [0 for i in range(N+1)]

def bfs(u):
    stack = deque([u])
    seen[u] = 1
    node_color[u] = 0

    while len(stack) > 0:
        v = stack.popleft()

        c = 1
        for w in ad[v]:
            if seen[w] == 0:
                stack.append(w)
                if c != node_color[v]:
                    edge_color[(v, w)] = c
                    node_color[w] = c
                else:
                    c += 1
                    edge_color[(v, w)] = c
                    node_color[w] = c
                c += 1
                seen[w] = 1

        if stack == []: break

bfs(1)

for edge in edges:
    if edge_color[edge] != 0:
        print(edge_color[edge])
    else:
        print(edge_color[edge.reverse()])

Measured memory_bytes: 122616
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Map<String, Integer> sen = new HashMap<>();
		int max = 0; //単語の登場回数のカウント変数
        int count = 0; //出力が1単語の時の例外処理用変数
        int max_width = 0; //最長の長さ
		String most_frequent_word = null; //再頻出ワード
		String longest_word = null; //最長単語

		while(stdIn.hasNext()){
			String word = stdIn.next();
            
            if(count == 0){
            	most_frequent_word = word; //出力が1単語の際のための処理
            }

			if(max_width < word.length() ){
				max_width = word.length();
				longest_word = word;
			}

			if(sen.get(word) == null){
                
                sen.put(word, 0);
                
            }else{
            	int v = sen.get(word) + 1;
                sen.put(word, v);

                if(max <= v){
                	most_frequent_word = word;
                    max = v;
                }

            }
            
            //System.out.println(most_frequent_word + " " + longest_word);
            count++;
			 
		}
        System.out.println(most_frequent_word + " " + longest_word);
       
		stdIn.close();
	}

}


Measured memory_bytes: 26380
N = gets.to_i

$cnt = 0

def f(n)
  if n > N
    return
  else
    s = "#{n}"
    $cnt += 1 if s[?7] && s[?5] && s[?3]
    f(n * 10 + 7)
    f(n * 10 + 5)
    f(n * 10 + 3)
  end
end

f 0
p $cnt


Measured memory_bytes: 1788