akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<int,int>pi;
const int MAXN=2000005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

ll qmult(ll X, ll Y, ll M) {
	return X * Y % M;
}

ll qexp(ll A, ll B, ll M) {
	if (B == 0) return 1; 
	ll half = qexp(A, B/2, M); 
	half = qmult(half, half, M);
	half %= M;
	if (B%2==1) half *= A%M;
	return half%M;
}

int f[MAXN], invf[MAXN], r1, r2, c1, c2; 

int g(int N, int M){
	int ans=0;
	FOR(i,0,N){
		int tmp=f[M+i+1];
		tmp*=invf[M];tmp%=MOD;
		tmp*=invf[i+1];tmp%=MOD;
		ans+=tmp;ans%=MOD;
	}
	return ans;
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> r1 >> c1 >> r2 >> c2;
	f[0]=1; invf[0]=1;
	FOR(i,1,r2+c2+1) {
		f[i]=(f[i-1]*i)%MOD;
	}
	invf[r2+c2+1]=qexp(f[r2+c2+1],MOD-2,MOD);
	DEC(i,r2+c2,1){
		invf[i]=(invf[i+1]*(i+1))%MOD;
	}
	int res=g(r2,c2);
	res-=g(r1-1,c2); res%=MOD;
	res-=g(r2,c1-1); res%=MOD;
	res+=g(r1-1,c1-1); res%=MOD;
	cout<<(res+MOD)%MOD;
}


Measured memory_bytes: 31488
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999


struct cir{
    int x,y,r,c;
};

bool same(cir a,cir b){
    double r2 = (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
    if((a.r+b.r)*(a.r+b.r)>r2)return true;
    else return false;
}

bool used(int n,vi vec){
    rep(i,vec.size()){
        int to = vec[i];
        if( (n&(1<<to)) != 0 )return false;
    }
    return true;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        vector<cir> data;
        
        rep(i,n){
            int x,y,r,c;
            cin>>x>>y>>r>>c;
            data.pb(cir{x,y,r,c});
        }
        
        
        vector<int> G[30];
        
        for(int i=data.size()-1;i>=0;i--){
            for(int j=i-1;j>=0;j--){
                if(same(data[i],data[j])){
                    G[i].pb(j);
                }
            }
        }
        
        static bool dp[1<<24];
        rep(i,1<<n)dp[i]=false;
        dp[(1<<n)-1]=true;
        
        
        for(int i=(1<<n)-1;i>=0;i--){
            if(dp[i]==false)continue;
            rep(j,n){
                for(int k=j+1;k<n;k++){
                    if( (i&(1<<j) )==0 || (i&(1<<k) )==0)continue;
                    if( data[j].c==data[k].c && used(i,G[j]) && used(i,G[k]) ) dp[(i^(1<<j))^(1<<k)] = true;
                }
            }
        }
        
        int ans=100;
        for(int i=(1<<n)-1;i>=0;i--){
            if(dp[i]==false)continue;
            ans = min(ans,__builtin_popcount(i));
        }
        cout<<n-ans<<endl;
    }
}

Measured memory_bytes: 19432
N = gets.to_i
current = N
ans = ""
i = 1
until current == 0
  # puts "current: #{current}, i: #{i}, 2**i: #{2**i}"
  # puts "割り切れるか?: #{current % (2 ** i) == 0}"
  if current % (2 ** i) == 0
    ans += "0"
  else
    current -= (-2) ** (i-1)
    ans += "1"
  end
  i += 1
  # break if i == 100
end
puts ans.empty? ? 0 : ans.reverse


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;


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

    int A;
    cin >> A;
    if(A < 1000){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public final class Main {

    private static class UnionFind {
        private final int[] parent;
        private final int[] size;
        private int count;

        public UnionFind(int n) {
            parent = new int[n];
            size = new int[n];
            count = n;
            for (int i = 0; i < n; i++) {
                parent[i] = i;
                size[i] = 1;
            }
        }

        public int find(int p) {
            // path compression
            while (p != parent[p]) {
                parent[p] = parent[parent[p]];
                p = parent[p];
            }
            return p;
        }

        public void union(int p, int q) {
            final int rootP = find(p);
            final int rootQ = find(q);
            if (rootP == rootQ) {
                return;
            }
            // union by size
            if (size[rootP] > size[rootQ]) {
                parent[rootQ] = rootP;
                size[rootP] += size[rootQ];
            } else {
                parent[rootP] = rootQ;
                size[rootQ] += size[rootP];
            }
            count--;
        }

        public int count() { return count; }

        public int[] size() { return size; }
    }

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int m = fs.nextInt();
        final UnionFind uf = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            final int u = fs.nextInt() - 1;
            final int v = fs.nextInt() - 1;
            uf.union(u, v);
        }
        int max = 0;
        for (int size : uf.size()) {
            max = Math.max(max, size);
        }
        System.out.println(max);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 58784
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(1000000, prime);

    vector<int> num;
    for(int i=0; i<=1000000; ++i){
        if(prime[i])
            num.push_back(i);
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        for(unsigned i=0; num[i]<=n/2; ++i){
            if(prime[n-num[i]])
                ++ ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
program two
  implicit none
  integer :: i
  integer :: n, h, w
  integer, allocatable :: a(:), b(:)
  integer :: count

  count=0

  read(*,*)n,h,w
  
  allocate(a(n))
  allocate(b(n))
  
  do i=1,n
     read(*,*)a(i),b(i)
  end do

  do i=1,n
     if (h<=a(i) .and. w<=b(i)) then
        count=count+1
     end if
  end do

  write(*,*)count

end program two

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
	int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res % p;
}
int lcm(int a, int b)
{
	return a / __gcd(a, b) * b;
}

void solve()
{
	 int n;
	 cin>>n;
	 int a[n];
	 for (int i = 0; i < n;i++)
		 cin >> a[i];
	int i = 1, l = 0, ans = 0;
	 while(i<n){
		 if(a[i]<=a[i-1]){
			 i++;
		 }
		 else{
			 ans = max(ans, i - l - 1);
			 l = i;
			 i++;
		 }
	 }
	 ans = max(ans, i - l - 1);
	 cout << ans << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 4428
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 1000 + 5;
const int inf = 1 << 30;

int n, t;

int main(){
    cin >> n >> t;
    int mc = inf;
    for (int i = 0; i < n; i++){
        int t1, t2; cin >> t1 >> t2;
        if (t2 <= t) {
            mc = min(mc, t1);
        }
    }
    if (mc == inf) puts("TLE");
    else printf("%d", mc);
    return 0;
}

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

int main() {
    int N, A;
    cin >> N;
    map<int, int> cnt;
    int64_t ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> A;
        ans += cnt[i - A];
        cnt[A + i]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 20548
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int AC =0;
    int WA =0;

    Map<Integer, List<String>> m = new TreeMap<>();
    for (int i = 0; i < M; i++) {
      int q = sc.nextInt();
      String res = sc.next();

      if(!m.containsKey(q)){
        m.put(q,new ArrayList<String>());
      }
      m.get(q).add(res);
    }


    for (Map.Entry<Integer,List<String>> e :m.entrySet()) {
      int q = e.getKey();

      int waCnt =0;
      int acCnt =0;

      List<String> l = e.getValue();

      for (String res: l){
        if(res.equals("WA")){
          waCnt++;
        }else{
          acCnt++;
          break;
        }
      }
      if(acCnt!=0){
        WA+=waCnt;
        AC+=acCnt;
      }


    }

    System.out.println(AC+" "+WA);

  }
}


Measured memory_bytes: 76416
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define test4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define test5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define test6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    cin>>n;
    ll arr[n];
    rep(i,0,n){
        cin>>arr[i];
    }
    ll sum[n];
    sum[n-1] = arr[n-1];
    for(i=n-2;i>=0;i--){
        sum[i] = (sum[i+1]%mod+arr[i]%mod)%mod;
    }
    ll res=  0;
    rep(i,0,n-1){
        res = (res%mod + (arr[i]%mod*sum[i+1]%mod)%mod)%mod;
    }
    cout<<res;
}

Measured memory_bytes: 6776
import java.util.Scanner;

public class Main {
	private Scanner sc;

	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String line = sc.nextLine();
			
			int state = 0;
			int loops = 0;
			for (int i = 0; i < line.length(); i++) {
				switch (state) {
				case 0:
					if (line.charAt(i) == '@') state++;
					else System.out.print(line.charAt(i));
					break;
					
				case 1:
					loops = line.charAt(i) - '0';
					state++;
					break;
				
				case 2:
					char c = line.charAt(i);
					for (int j = 0; j < loops; j++) {
						 System.out.print(c);
					}
					state = 0;
				}
			}
			
			System.out.println();
		}
	}
}

Measured memory_bytes: 26016
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList
  as <- getIntList
  let l = length (takeWhile (/= 1) as)
  let l' = n - (l + 1)
  let k' = k - 1
  print $ (l + l' + k' - 1) `div` k'


Measured memory_bytes: 6056
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 2000
int a[MN+5],u[MN+5],mn;
vector<int> v[MN+5],ans[MN+5];
int gcd(int x,int y){return y?gcd(y,x%y):x;}
void dfs(int x)
{
	u[x]=1;if(a[x]<a[mn])mn=x;
	for(int i=0;i<v[x].size();++i)if(!u[v[x][i]])dfs(v[x][i]);
}
bool cmp(int x,int y){return a[x]<a[y];}
void merge(vector<int>&x,vector<int>&y)
{
	vector<int> z;int i=0,j=0;
	while(i<x.size()&&j<y.size())z.push_back(x[i]>y[j]?x[i++]:y[j++]);
	while(i<x.size())z.push_back(x[i++]);
	while(j<y.size())z.push_back(y[j++]);
	x.clear();
	for(int i=0;i<z.size();++i)x.push_back(z[i]);
}
void solve(int x)
{
	u[x]=2;sort(v[x].begin(),v[x].end(),cmp);
	for(int i=0;i<v[x].size();++i)if(u[v[x][i]]<2)
		solve(v[x][i]),merge(ans[x],ans[v[x][i]]);
	ans[x].push_back(0);
	for(int i=ans[x].size();--i;)ans[x][i]=ans[x][i-1];
	ans[x][0]=a[x];
}
int main()
{
	int n=read(),i,j;
	for(i=1;i<=n;++i)a[i]=read();
	for(i=1;i<=n;++i)for(j=1;j<i;++j)if(gcd(a[i],a[j])>1)
		v[i].push_back(j),v[j].push_back(i);
	for(i=1;i<=n;++i)if(!u[i])dfs(mn=i),solve(mn),merge(ans[0],ans[mn]);
	for(i=0;i<ans[0].size();++i)printf("%d ",ans[0][i]);
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  vint u(3);cin>>u[0]>>u[1]>>u[2];
  //caricurate
  vsort(u);
  if((u[0]==5)&&(u[1]==5)&&(u[2]==7)){cout<<"YES"<<endl;return 0;}
  //output
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))
iters = 0
count = 0

while len(nums) != 0:
    size = len(nums)
    nums = list(map(lambda x: x//2, list(filter(lambda x:x%2 == 0, nums))))
    count += (size - len(nums))*iters
    iters += 1
    
print(count)

Measured memory_bytes: 4148
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int MAX = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    bool exist[100000]={false};
    sort(a.begin(),a.end());
    exist[0]=true;
    ans++;
    for(int i=1;i<n;i++){
        if(a[i] == a[i-1]){
            if(exist[i-1]){
                ans--;
                exist[i]=false;
            }
            else{
                ans++;
                exist[i]=true;
            }
        }
        else{
            ans++;
            exist[i]=true;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A+B>=10)
			System.out.println("error");
		else
			System.out.println(A+B);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  char c;
  cin>>n;
  r(o,n){
    int a[5][5],sum=0;
    r(i,5)r(j,5)cin>>a[i][j];
    r(i,5)r(j,5)if(j&&a[i][j])a[i][j]+=a[i][j-1];
    r(i,5)r(j,5){
      if(a[i][j]){
        int p=a[i][j],x=1;
        sum=max(sum,p);
        for(int k=i+1;k<5;k++){
          if(!a[k][j])break;
          p=min(p,a[k][j]);
          x++;
          sum=max(sum,x*p);
        }
        sum=max(sum,x*p);
      }
    }
    cout<<sum<<endl;
  }
}

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

using namespace std;

void trace(int* A, int n)
{
    cout << A[0];
    for(int i=1; i < n; i++)
    {
        cout << " " << A[i];
    }
    cout << endl;

    return;
}

void selectionSort(int A[], int n)
{
    int count = 0;

    for(int i = 0; i < n; i++)
    {
        int minj = i;
        for(int j = i; j < n; j++)
        {
            if(A[j] < A[minj])
                minj = j;
        }
        if(minj != i)
        {
            swap(A[i], A[minj]);
            count++;
        }
    }

    trace(A, n);
    cout << count << endl;

    return;
}

int main(void)
{
    int n;
    int input;
    int A[100];

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

    selectionSort(A, n);

    return 0;
}

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

int N,A,B;

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

  int sum = 0;
  for (int i=1; i<=N; ++i) {
    stringstream ss;
    string       s;
    ss << i;
    s = ss.str();
    int kakuketa_sum = 0;
    for (int j=0;j<s.length();j++) {
      //cout << s[j] << " ";
      int tmp_i = s[j] - '0';
      kakuketa_sum = kakuketa_sum + tmp_i;
    }
    if ((A <= kakuketa_sum) &&
        (kakuketa_sum <= B)) {
      sum += atoi(s.c_str());

    }
    //cout << ",sum=" << kakuketa_sum << "\n";
  }
  cout << sum << "\n";

#if 0
  cout << N << " " << A << " " << B << "\n";
#endif
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    n = int(input())
    dic = {}
    for i in range(n):
        tmp = 0
        num = i+1
        for j in range(7):
            num = num/2
            if num.is_integer():
                tmp+=1
            else:
                break
        dic[i+1] = tmp
    print(max(dic, key=dic.get))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a,int b)
{
	if(b>a)
		return gcd(b,a);
	else if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main()
{
	int k;cin>>k;
	int sum=0;
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++)
			for(int l=1;l<=k;l++){
				sum+=gcd(i,gcd(j,l));
			}

			cout << sum <<endl;

}


Measured memory_bytes: 3632
#include <stdio.h>

int sum(int data[], int n, int k)
{
    int i;
    int total = 0.0;     // 変数の宣言
  
    for(i=n; i<k; i++){
        total += data[i];   // 合計を計算
    }
      
    return total;           // 合計を返す
}

int main()
{
  int n,k;
  scanf("%d %d", &n, &k);
  int i;
  int p[n];
  for (int i = 0; i < n; ++i) 
  {
    scanf("%d", &p[i]);
  }
  double max_num;
  max_num = -1.0;
  double teki;
  for (int i = 0; i < n-k+1; ++i)
  {
    teki = sum(p, i, i+k) + k;
    teki = teki /2.0;
    if (teki>max_num)
    {
      max_num = teki;
    }
  }
  printf("%lf\n", max_num);
  return 0;
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main()
{ 
  int a;
  cin >> a;
  call(a);
  return 0;   
}


Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


class RollingHash():
    """
    Original code is https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
    """
    class RH():
        def __init__(self, s, base, mod):
            self.base = base
            self.mod = mod
            self.rev = pow(base, mod-2, mod)

            l = len(s)
            self.h = h = [0]*(l+1)
            tmp = 0
            for i in range(l):
                num = ord(s[i])
                tmp = (tmp*base + num) % mod
                h[i+1] = tmp

            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod

        def calc(self, l, r):
            return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

    @staticmethod
    def gen(a, b, num):
        result = set()
        while 1:
            import random
            import math
            random.seed()
            while 1:
                v = random.randint(a, b)//2*2+1
                if v not in result:
                    break
            for x in range(3, int(math.sqrt(v))+1, 2):
                if v % x == 0:
                    break
            else:
                result.add(v)
                if len(result) == num:
                    break
        return result

    def __init__(self, s, rand=False, num=5):
        if rand:
            bases = RollingHash.gen(2, 10**3, num)
        else:
            assert num <= 10
            bases = [641, 103, 661, 293, 547, 311, 29, 457, 613, 599][:num]

        MOD = 10**9+7
        self.rhs = [self.RH(s, b, MOD) for b in bases]

    def calc(self, l, r):
        return tuple(rh.calc(l, r) for rh in self.rhs)


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


def slv(N, S):
    srh = RollingHash(S)

    def f(m):
        h2i = defaultdict(list)
        for i in range(N-m+1):
            h2i[srh.calc(i, i+m)].append(i)

        for l in h2i.values():
            n = l[-1] - l[0]
            if n >= m:
                return 0
        return 1

    return Bisect(f).bisect_right(0, 1, N//2+1) - 1


def main():
    N = int(input())
    S = input()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 50012
n1 = int(input())
a1 = [int(x) for x in input().split()]
n2 = int(input())
a2 = [int(x) for x in input().split()]

res = set()

cnt = 0

for i in range(n1) :
    for j in range(n2) :
        if a1[i] == a2[j] :
            res.add(a1[i])
            
print(len(res))
            


Measured memory_bytes: 6552
import sys
dp=[[[0]*331 for i in xrange((1<<10)+1)] for j in xrange(12)]
#dp[12][1025][340]
dp[0][0][0]=1
for i in xrange(10):
    for j in xrange(1<<10):
        for c in xrange(331):
            if dp[i][j][c]==0:
                continue
            for k in xrange(10):
                if (j>>k&1)==0:
                    dp[i+1][j|(1<<k)][(i+1)*k+c]+=dp[i][j][c]
ans=[[0]*331 for unused in xrange(12)]
for i in xrange(11):
    for j in xrange(1<<10):
        for c in xrange(331):
            ans[i][c]+=dp[i][j][c]
for line in sys.stdin.readlines():
    n,s=map(int,line.strip().split())
    if s>330:
        print 0
    else:
        print ans[n][s]

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
ll a;
  cin >> a;
  return a;
}

vi sub(vector<bool> fin,ll n) {
  vi ret;
  REP(i,n) {
    if(fin.at(i))continue;
    vector<bool> cp = fin;
    cp.at(i) = true;
    vi result = sub(cp,n);
    ret.insert(ret.end(),result.begin(),result.end());
  }
  return ret;
}

int main() {
  ll a,b,x;
  cin >> a >> b >> x;
  cout << ((a<=x && x<=a+b)?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
#define pb                emplace_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define ff                first
#define ss                second
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define isBitset(S,i)     ((S>>i)&1)
#define print(x) 		  for(auto it:x) cout<<it<<" "; cout<<"\n"; 
#define gcd(a,b)		  __gcd(a,b)
#define lcm(a,b) 		  (a/gcd(a,b))*b
vector<ll>ar[100001];
ll vis[100001];
void dfs(ll node)
{
	vis[node]=1;
//	cout<<c<<" ";
	//c++;
	for(auto child:ar[node])
	{
		if(!vis[child])
			dfs(child);
	}
}
void solve()
{
	ll n,m;cin>>n>>m;
	for(ll i=0;i<=n;++i)
	{
		vis[i]=0;
		ar[i].clear();
	}
	ll x,y; 
	for(ll i=0;i<m;++i)
	{
		cin>>x>>y;
		ar[x].pb(y);
		ar[y].pb(x);
	}
	ll ans=0;
	// for(ll i=1;i<=n;++i)
	// cout<<vis[i]<<" ";
	// cout<<"\n";
	for(ll i=1;i<=n;++i)
	{
		//c=0;
		if(!vis[i])
		{
			dfs(i);
			ans++;
		}
		//ans=max(ans,c);
	}
	// for(ll i=1;i<=n;++i)
	// cout<<vis[i]<<" ";
	// cout<<"\n";
	ans--;
	cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
        solve();
    return 0;
}

Measured memory_bytes: 11112
h, w = map(int, input().split())

s = []
for _ in range(h):
    s.append(input())

for i in range(h):
    ss = ''
    for j in range(w):
        if s[i][j] == '#':
            ss += '#'
        else:
            cnt = 0
            for k in [-1, 0, 1]:
                for l in [-1, 0, 1]:
                    if 0 <= i+k <= h-1 and 0 <= j+l <= w-1 and s[i+k][j+l] == '#':
                        cnt += 1
            ss += str(cnt)
    print(ss)

Measured memory_bytes: 40620
(* 素集合データ構造 *)
module UnionFind = struct
  module Make (Set : sig
    type t
    val union : t -> t -> t
  end) : sig
    type t
    (* 与えられた集合から素集合データ構造を作る *)
    val make : Set.t -> t
    (* 与えられた素集合同士が同一かどうか判定する *)
    val equal : t -> t -> bool
    (* 与えられた素集合同士を合併する *)
    val unite : t -> t -> unit
    (* 与えられた素集合に属する要素を列挙する *)
    val elements : t -> Set.t
  end = struct
    type t = node ref
    and node =
      | Root of int * Set.t (* 木の高さと要素の集合の二つ組 *)
      | Link of t

    let make s = ref @@ Root (0, s)

    let rec find uf =
      match !uf with
      | Root _ -> uf
      | Link parent ->
          let root = find parent in
          uf := Link root; root

    let equal uf uf' = find uf == find uf'

    let unite uf uf' =
      let root = find uf in
      let root' = find uf' in
      if root != root' then begin
        let Root (rank, elts) = !root in
        let Root (rank', elts') = !root' in
        let root, root' =
          if rank <= rank'
          then root, root'
          else root', root in
        root := Link root';
        root' := Root (rank' + (if rank = rank' then 1 else 0), Set.union elts elts')
      end

    let elements uf =
      match find uf with
      | { contents = Root (_, elts) } -> elts
  end
end

module UF = UnionFind.Make (struct
  type t = int
  let union = ( + )
end)

let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ss = Array.init h @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
  let uf =
    Array.init h @@ fun i ->
      Array.init w @@ fun j ->
        UF.make @@ if ss.(i).[j] = '.' then 1 else 0 in
  for i = 0 to h - 1 do
    for j = 0 to w - 2 do
      if ss.(i).[j] <> ss.(i).[j + 1] then
        UF.unite uf.(i).(j) uf.(i).(j + 1)
    done
  done;
  for i = 0 to h - 2 do
    for j = 0 to w - 1 do
      if ss.(i).[j] <> ss.(i + 1).[j] then
        UF.unite uf.(i).(j) uf.(i + 1).(j)
    done
  done;
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left ( + )) 0 @@
  Array.init h @@ fun i ->
    Array.init w @@ fun j ->
      if ss.(i).[j] = '.'
      then 0
      else UF.elements uf.(i).(j)


Measured memory_bytes: 17920
local a, b, c = string.match(io.read(), "(%d+) (%d+) (%d+)")
a, b, c = tonumber(a), tonumber(b), tonumber(c)

local arr = {
    a, b, c
}

local max = 0
local min = 0

for i = 1, 3 do
    if max == 0 then
        max = arr[i]
    elseif arr[i] > max then
        max = arr[i]
    end

    if min == 0 then
        min = arr[i]
    elseif arr[i] < min then
        min = arr[i]
    end
end

local output = max - min

print(tostring(output))

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a[3], m, n, i, t;

	scanf("%d\n", &n);
	if (n == 2) scanf("%d %d", &a[0], &a[1]);
	if (n == 3) scanf("%d %d %d", &a[0], &a[1], &a[2]);

	if (a[0] > a[1]) {t = a[0]; a[0] = a[1]; a[1] = t;}
	if (a[1] > a[2]) {t = a[1]; a[1] = a[2]; a[2] = t;}
	if (a[0] > a[1]) {t = a[0]; a[0] = a[1]; a[1] = t;}

	m = a[0] / 2;

	for (i = 1; i <= m; i++) {
		if (a[0] % i == 0) {
			if (a[1] % i == 0) {
				if (n == 2) printf("%d\n", i);
				else if(a[2] % i == 0) {
					printf("%d\n", i);
				}
			}
		}
		if (a[1] % a[0] == 0) {
			if (n == 2) printf("%d\n", i);
			else if (a[2] % a[0] == 0) {
				printf("%d\n", i);
			}
		}
	}
}



Measured memory_bytes: 2032
e=Hash.new [];n=gets.to_i;(n-1).times{|i|a,b=gets.split;e[a]+=[i];e[b]+=[i]};a=[0]*(n-1);(1..n).map{|w|u={};e[v=w.to_s].map{|j|u[a[j]]=1};t=1;e[v].map{|j|1>a[j]&&(t+=1until u[t].nil?;a[j]=t;t+=1)}};p a.max;$><<a*$/

Measured memory_bytes: 183284
#include <stdio.h>
#include <ctype.h>

int main(){
    int c;
    
    while((c = getchar()) != EOF){
        if(isupper(c)){
            putchar(tolower(c));
        }
        
        else if(islower(c)){
            putchar(toupper(c));
        }
        
        else {
            putchar(c);
        }
    }
    
    return 0;
}



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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i+=2){
        if(s[i]=='h'&&s[i+1]=='i'){}
        else {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = 0;
    if(a + W < b) {
      ans = b - a - W;
    } else if(b + W < a) {
      ans = a - b - W;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

int d, e;
vector<double> v;

auto manhattan = [](int n, int m){return sqrt(n*n + m*m);};

int main(){
  while(cin >> d >> e, d){
    v.clear();
    double m=100000000;
    for(int i=0; i<d; i++)
      m=min(m, abs(sqrt(i*i + (d-i)*(d-i))-e)); 
    cout << m << endl;
  }
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000003
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

map<ll,int>mem;
int n,m;
vector<int>edge[50005],redge[50005];

int rec(int l,int r){
	while(edge[l].empty() && l <= r) l += 2;
	while(redge[r].empty() && l <= r) r -= 2;
	if(l > r) return 1;
	ll ky = 50005 * l + r;
	if(mem.find(ky) != mem.end()) return mem[ky];
	//use first edge
	int ans = 0;
	//decreasing order
	//for(int i=edge[l].size()-1;i>=0;i--){
	for(int i=0;i<edge[l].size();i++){
		if(edge[l][i] > r) continue;
		ans += 1LL * rec(l+1,edge[l][i]-1) * rec(edge[l][i]+1,r) % mod;
		if(ans >= mod) ans -= mod;
	}
	ans += rec(l+2,r);
	if(ans >= mod) ans -= mod;
	return mem[ky] = ans;
}
int main(){
	while(1){
		scanf("%d%d",&n,&m); if(n==0 && m==0) return 0;
		for(int i=1;i<=n;i++){
			edge[i].clear();
			redge[i].clear();
		}
		mem.clear();
		edge[1].pb(n);
		redge[n].pb(1);
		for(int i=1;i<=m;i++){
			int a,b; scanf("%d%d",&a,&b);
			if(a > b) swap(a,b);
			if(a%2 == b%2) continue;
			if(b-a == 1) continue;
			edge[a].pb(b);
			redge[b].pb(a);
		}
		if(n%2 == 1) {
			puts("0");
			continue;
		}
		for(int i=1;i<=n;i++){
			SORT(edge[i]);
			ERASE(edge[i]);
			SORT(redge[i]);
			ERASE(redge[i]);
			reverse(redge[i].begin(),redge[i].end());
		}
		cout << rec(1,n) << endl;
	}
}


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

int main() {
    int h,w;
    cin>>h>>w;
    string ss[h];
    for (int i=0;i<h;i++)
        cin>>ss[i];
    for (int i=0;i<2*h;i++) {
        for (char c:ss[i/2])
            cout<<c;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
typedef struct{
  char c;
  int num;
}pair;

void bubblesort(pair* , int );
void selectionsort(pair* , int);



int main(){

  int e,n,i,j,temp,flag = 0;
  pair box[64];
  pair in1[64];
  pair in2[64];
  char emp;

  scanf("%d\n",&n);
  // printf("n = %d\n",n);

  for(i = 0;i < n;i++){
    // printf("%d\n",i);
    scanf("%c",&box[i].c);
    scanf("%d",&box[i].num);
    if(i != n - 1) scanf("%c",&emp);
    // scanf("%c\n",&emp);

    // printf("c = %c,num = %d\n",box[i].c,box[i].num);
    in1[i].c = box[i].c;
    in2[i].c = box[i].c;
    in1[i].num = box[i].num;
    in2[i].num = box[i].num;
  }

  bubblesort(in1,n);
  
  for(i = 0;i < n;i++){
    printf("%c",in1[i].c);
    if(i != n - 1) printf("%d ",in1[i].num);
    else printf("%d\n",in1[i].num);
  }

  printf("Stable\n");

  selectionsort(in2,n);


  for(i = 0;i < n;i++){
    printf("%c",in2[i].c);
    if(i != n - 1) printf("%d ",in2[i].num);
    else printf("%d\n",in2[i].num);
  }

  for(i = 0;i < n;i++){
    if(in1[i].num != in2[i].num || in1[i].c != in2[i].c){
      flag = 1;
      break;
    }
  }
  if(flag == 0) printf("Stable\n");
  else printf("Not stable\n");


  return 0; 
}

void bubblesort(pair *c, int n){

  int temp,i,j;
  char tem;
  for(i = 0;i <= n - 1;i++){
    for(j = n - 1;j >= i + 1;j--){
      if(c[j].num < c[j - 1].num){
	temp = c[j].num;
	tem = c[j].c;
	c[j].num = c[j - 1].num;
	c[j].c = c[j - 1].c;
	c[j - 1].num = temp;
	c[j - 1].c = tem;
      }
    }
  }

}


void selectionsort(pair *c, int n){

  int i,j,temp,minj;
  char tem;
  for(i = 0;i <= n - 1;i++){
    minj = i;
    for(j = i;j <= n - 1 ;j++){
      if(c[j].num < c[minj].num){
	minj = j;
      }
    }
    temp = c[i].num;
    tem = c[i].c;
    c[i].num = c[minj].num;
    c[i].c = c[minj].c;
    c[minj].num = temp;
    c[minj].c = tem;
  }
}

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

bool arr[200005];
int offset = 0;
deque<int> borders;


int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    if (k>=2*n && n%2==0){
        for (int x = n-1; x>=0; x--){
            printf(x%2==0?"A":"B");
        }
        return 0;
    }
    for (int x = 0; x<n; x++){
        char c;
        scanf(" %c",&c);
        arr[x] = c=='B';
    }
    for (int x = n-1; x>=0; x--){
        if (x==n-1) borders.push_back(n-1);
        else if (arr[x]!=arr[x+1]){
            borders.push_front(x);
        }
    }
    for (int x = 0; x<min(k,2*n); x++){
        //printf("front %d - %d\n",borders.front(),offset);
        while (borders.front()-offset<0) borders.pop_front();
        if (!arr[0]) {
            arr[0] = true;
            if ((!borders.empty())&&borders.front()-offset==0){
                borders.pop_front();
            }
            else{
                borders.push_front(offset);
                //printf("HI %d\n",borders.size());
            }
            continue;
        }
        else{
            bool last = arr[0] ^ (borders.size()&1) ^1;
            //printf("last: %d first: %d size: %d\n",last,arr[0],borders.size());
            if (last){
                borders.pop_back();
            }
            if ((borders.empty()) || borders.front()-offset!=0){
                arr[0] ^= 1;
            }
            else{
                borders.pop_front();
            }
            offset++;

            borders.push_back(offset+n-1);
        }
    }
    while (borders.front()-offset<0) borders.pop_front();
    bool cur = arr[0];
    if (k<=2*n){
        for (int x = 0; x<n; x++){
            printf(cur?"B":"A");
            if (borders.front()-offset==x) {
                cur ^=1;
                borders.pop_front();
            }
        }
    }
    else{
        int rem = k-2*n;
        printf(((rem&1)^arr[0])?"B":"A");
        for (int x = n-2; x>=0; x--){
            printf(x%2==0?"A":"B");
        }
    }

}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int a,b;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    if(a<=8 && b<=8)cout<<"Yay!\n";
    else cout<<":(\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    lli c1 = 0, c2 = 0, c3 = 0, c4 = 0;
    tst
    {
        string s;
        cin >> s;
        if(s=="AC")
            c1++;
        else if(s=="WA")
            c2++;
        else if(s=="TLE")
            c3++;
        else
            c4++;
    }
    cout << "AC x " << c1 << "\n";
    cout << "WA x " << c2 << "\n";
    cout << "TLE x " << c3 << "\n";
    cout << "RE x " << c4 << "\n";
    return 0;
}

Measured memory_bytes: 3672
def main():
  while True:
    n, m = map(int, input().split())
    if n == 0:
      break
  
    items = sorted(list(map(int, input().split())))
    ans = 0
    for i in range(n - 1):
      p1 = items[i]
      for j in range(i + 1, n):
        p2 = p1 + items[j]
        if p2 > m:
          break
        if ans < p2:
          ans = p2
    if ans != 0:
      print(ans)
    else:
      print("NONE")
  
main()


Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first > b.first;
    }
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//string S;
	//cin >> S;
	//vector<int> A(N);
  	//int idx = 0;
  	//while(cin >> A[idx]) idx++;
  	
  	//vector<string> s = split(S, " ");
  	//cerr << s.size() << endl;
  	//for(int i=0;i<=s.size();i++) cout << s[i] << endl;
  	long N,M;
  	cin >> N >> M;
  	vector<long> A(N);
  	vector<pair<long, long> > BC(M);
  	int idx = 0;
  	while(cin >> A[idx])
    {
      idx++;
      if(idx == N) break;
    }
  	sort(A.begin(),A.end());
  
  	idx = 0;
  	long B,C;
  	while(cin >> B >> C)
    {
      BC[idx] = make_pair(B, C);
      idx++;
    }
  	sort(BC.begin(), BC.end(), compare_by_b);
  
  	idx = 0;
  	int count = 0;
  	long total = 0;
  	for(int i=0;i<N;i++)
    {
      if(idx < M && A[i] < BC[idx].second)
      {
        A[i] = BC[idx].second;
        count++;
      }
      if(count == BC[idx].first)
      {
        idx++;
        count = 0;
      }
      cerr << A[i] << endl;
      total+=A[i];
    }
    cout << total << endl;
  	return 0;
}


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

int main(){
    int a,b,c,k;
    cin >>a>>b>>c>>k;
    int ans;
    if(k<=a){
        ans=k;
    }else if(k<=a+b){
        ans=a;
    }else{
        ans=2*a+b-k;
    }
    cout << ans <<endl;
    return 0;
}

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

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

    int F[50];
    F[0] = F[1] = 1;

    for (int i = 2; i <= n; i++)
        F[i] = F[i - 1] + F[i - 2];

    cout << F[n] << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int x[N], y[N], a[N];
  rep(i, N)
    cin >> x[i] >> y[i] >> a[i];
  //ここまで入力

  //黒く塗った部分を「#」，白い部分を「.」で表す
  char rectangle[H][W];
  rep(i, H)
    rep(j, W)
    rectangle[i][j] = '.';

  //題意を満たすように黒で塗っていく
  rep(k, N){
    if(a[k] == 1){
      rep(i, H)
	rep(j, x[k])
	rectangle[i][j] = '#';
    }
    else if(a[k] == 2){
      rep(i, H)
	for(int j=x[k]; j<W; j++)
	rectangle[i][j] = '#';
    }
    else if(a[k] == 3){
      for(int i=H-1; i>=H-y[k]; i--)
	rep(j, W)
	rectangle[i][j] = '#';
    }
    else if(a[k] == 4){
      rep(i, H-y[k])
	rep(j, W)
	  rectangle[i][j] = '#';
    }
  }

  //白い部分を数える
  int area = 0;
  rep(i, H){
    rep(j, W){
      if(rectangle[i][j] == '.')
	area++;
    }
  }

  cout << area << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N;
  double x, sum;
  char s[3];
  int i;
  
  scanf("%d", &N);
  
  for(i=0;i<N;i++){
    scanf("%lf %s",&x ,s);
    if(s[0]=='J'){
    sum+=x;
      continue;
    }
    sum+=x*380000;
  }
  
  printf("%f", sum);
  return 0;
}

Measured memory_bytes: 128
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>
#include <math.h>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
#define PI (acos(-1))  // 円周率pi

/* typedef */
// long long
typedef long long ll;

// pair
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<double, double> d_d;

// 最大公約数
ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		gcd(b, a % b);
	}
}

//素因数分解
vector<l_l> factorsize(ll n) {
	vector<l_l> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}
		else {
			l_l fs{ i, 0 };
			while (n % i == 0) {
				n /= i;
				fs.second++;
			}
			res.push_back(fs);
		}
	}
	if (n != 1) {
		l_l gs{ n, 1 };
		res.push_back(gs);
	}
	return res;
}

/* main関数 */
int main(void) {
	ll a, b;
	cin >> a >> b;
	if (a < b) swap(a, b);
	ll c = gcd(a, b);
	vector<l_l>fact = factorsize(c);
	cout << fact.size() + 1;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a == c && a != b) {
		cout << "Yes" << endl;
		return 0;
	}
	if (b == c && a != b) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}


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

using namespace std;

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

    int a,  b;
    cin >> a >> b;

    if(b % a == 0 )
    {
        cout << a + b << endl;
    } else
    {
        cout << b - a << endl;
    }

    return 0;
}

Measured memory_bytes: 256