akhauriyash/Code-Regression huggingface dataset:
function main(input){
  var inputLines=input.split('\n');
  var Ls=inputLines[1].split(' ');
  for(var i=0;i<Ls.length;i++){
    Ls[i]=parseFloat(Ls[i]);
  }
  var maxL=Math.max.apply(null,Ls);
  function reducer(acc,cur){
    return acc+cur;
  }
  var summedL=Ls.reduce(reducer);
  var isDrawable=(summedL>2*maxL);
  var result=(isDrawable)?'Yes':'No';
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 7372
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    while (in.next.head != 0) {
        val x = in.next.foldLeft((0.0, 0.0, 0)){case ((m, mean, n), d) =>
            (m - ((d + n * mean) / (n + 1) - d) * (d - mean), mean + (d - mean) / (n + 1), n + 1)
        }
        println(math.sqrt(x._1 / x._3))
    }
}

Measured memory_bytes: 44724
#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());
  
  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
  
}
 
int main(){
  
  int n; cin >> n;
  if (n%2 == 0){
    cout << n << endl;
  }
  else{
    cout << n*2 << endl;
  }

  return 0; 
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Task Scheduling Problem
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 3;

/* typedef */

/* global variables */

int as[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++) scanf("%d", &as[i]);
  sort(as, as + N);

  int sum = 0;
  for (int i = 1; i < N; i++) sum += abs(as[i] - as[i - 1]);

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())

P = set(list(map(int, input().split())))

if X in P:
    ans = -1
else:
    ans = 0
for i in range(102):
    if i in P:
        continue
    if abs(i-X) < abs(ans-X):
        ans = i

print(ans)


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

int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	}
	else {
		if (n < 2800) {
			cout << "ARC" << endl;
		}
		else {
			cout << "AGC" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
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

judge :: [Int] -> Int
judge [] = 0
judge [x] = 0
judge (x : y : xs)
  | x >= y = 1 + judge (y : xs)
  | otherwise = 0

tryMove :: [Int] -> [Int]
tryMove [] = []
tryMove (h : hs) = taken : tryMove hs'
  where
    taken = judge (h : hs)
    hs' = drop taken hs

main = do
  n <- getInt
  hs <- getIntList
  print $ maximum (tryMove hs)


Measured memory_bytes: 12924
#include <iostream>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <algorithm>
using namespace std;
const int MAXSIZE = 1e4+7;
struct point{
	double x, y;
	point(double a = 0, double b = 0):x(a),y(b){}
};
typedef point Point;
struct segment{
	point a, b;
};
typedef segment Segment;
Point operator *(Point a, double p){
	return Point(a.x * p, a.y*p);
} 
Point operator +(Point a, Point b){
	return Point(a.x + b.x, a.y + b.y);
}
Point operator -(Point a, Point b){
	return Point(a.x - b.x, a.y - b.y);
}
double norm(Point a){
	return a.x * a.x + a.y * a.y;
}
double abs(Point a){
	return sqrt(norm(a));
}
double dot(Point a, Point b){
	return a.x * b.x + a.y * b.y;
}
double cross(Point a, Point b){
	return a.x * b.y - a.y * b.x;
}
Point project(Segment s, Point p){
	Point base = s.b - s.a;
	double r = dot(p - s.a, base) / norm(base);
	return s.a + base * r;
}
Point reflect(Segment s, Point p){
	return p + (project(s,p)-p)*2.0;
}
int main(){
	Segment temp;
	scanf("%lf %lf %lf %lf",&temp.a.x, &temp.a.y, &temp.b.x, &temp.b.y);
	int n;
	Point p;
	scanf("%d",&n);
	while(n--){
		scanf("%lf %lf",&p.x, &p.y);
		Point get = reflect(temp,p);
		printf("%0.10lf %0.10lf\n", get.x, get.y);
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define f(n)                for (ll i=0;i<n;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define N                   100005
ll MOD=pow(10,9)+7;
ll INF=1ll<<60;

int dp[3002][3002];

int main()
{
    string s,t;
    cin>>s>>t;

    ll n,m;
    n=s.length(),m=t.length();

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            if(s[i-1]==t[j-1])
                dp[i][j]=max(1+dp[i-1][j-1],dp[i][j]);
        }
    }

    string res="";

    int i=n,j=m;
    while(i && j)
    {
        if(dp[i][j]==dp[i-1][j])
            i-=1;
        else if(dp[i][j]==dp[i][j-1])
            j-=1;
        else if(dp[i][j]==1+dp[i-1][j-1])
        {
            res=res=s[i-1]+res;
            i--;
            j--;
        }
    }

    cout<<res<<endl;
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

int main()
{
 
    std::string a;
    int64_t b,c;
    int64_t f_count = 0;
    c = 0;
    //int64_t c = 1;
    
    std::cin>> a;
    std::cin>> b;
 
    if( a.size() == 1 )
    {
        c = b / 2;
    }
    else
    {
        char aa = a[0];
        int64_t count = 0;
        int64_t cc = 0;
        bool f = true;
        bool o = true;
        
        for( int64_t i = 1; i < a.size(); i++ )
        {
            if( a[i] == aa )
            {
                count += 1;

                if( f )
                {
                    f_count += 1;
                }
            }
            else
            {
                if( count != 0
                    && !f )
                {
                    cc += ( count + 1 ) / 2;
                    count = 0;
                }

                f = false;
                aa = a[i];
                count = 0;
            }
        }
 
        if( f )
        {
            c = ( ( count + 1 ) * b ) / 2;
        }
        else
        {

            if( a[0] == a[ a.size() - 1 ] )
            {
                c += ( b - 1 ) * ( ( f_count + count + 2 ) / 2 );
                c += ( f_count + 1 ) / 2;
                c += ( count + 1 ) / 2;
            }
            else
            {
                cc += ( f_count + 1 ) / 2;
                cc += ( count + 1 ) / 2;
            }
            
            c += b * cc;
        }
    }
 
    std::cout<< c;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  int c=0,a=0,b=0;
  cin >> s;
  for(int i=0;i<3;i++){
    if(s[i]=='a') a++;
    if(s[i]=='b') b++;
    if(s[i]=='c') c++;
  }
  if((a==0)||(b==0)||(c==0)) cout <<"No" << endl;
  else cout <<"Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 998244353;


int main(void){
    int N;
    string S;
    cin >> N >> S;
    vector<int> B(N);
    int now = 0;
    for(int i = 0; i < N; i++){
        if(S.at(i) == '#'){
            now++;
        }
        B.at(i) = now;
    }
    
    vector<int> W(N);
    int now_ = 0;
    for(int i = N-1; i >= 0; i--){
        if(S.at(i) == '.'){
            now_++;
        }
        W.at(i) = now_;
    }
    int ans = INF;
    for(int i = 0; i < N; i++){
        ans = min((B.at(i) + W.at(i)), ans);
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	char ho[8]={'H','o','s','h','i','n','o'};
	int n;
	string s;
	cin>>n;cin.ignore();
	while(n--){
		getline(cin,s);
		int a=s.length();
		rep(i,a-6){
			if(s[i]=='H'&&s[i+1]=='o'&&s[i+2]=='s'&&s[i+3]=='h'&&s[i+4]=='i'&&s[i+5]=='n'&&s[i+6]=='o'){
				s[i+6]='a';i+=6;
			}
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll a,b,c,k;
  cin >> a >> b >> c >> k;

  ll ans = 0;
  if(a >= k){
    cout << k << endl;
    return 0;
  }
  else{
    k-=a;
    if(b >= k){
      cout << a << endl;
    }
    else{
      k-=b;
      cout << a -k << endl;
    }

  }

  return 0;
    

}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(){

    int ans = 0;
    int human = 1;
    int N;
    int A[15];
    int x[15][15], y[15][15];

    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> A[i];
        for(int j = 0; j < A[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }

    while(!(human >> N)){
        int f_next = 0;
        for(int i = 0; i < N; i++){
            if((human >> i) & 1){
                for(int j = 0; j < A[i]; j++){
                    if(((human >> (x[i][j]-1)) & 1) != y[i][j]){
                        f_next = 1;
                        break;
                    }
                }
            }
            if(f_next){
                break;
            }
        }

        if(!f_next){
            int sum = 0;
            for(int i = 0; i < N; i++){
                sum += ((human >> i) & 1);
            }

            if(ans < sum){
                ans = sum;
            }
        }

        human++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> vec(N);
    ll sum = 1;
    bool ok = true;
    for (ll i = 0; i < N; i++)
    {
        ll ai;
        cin >> ai;
        if (ai == 0){ 
            sum = 0;
            break;
        }
        if ((dd)1e18 / (dd)ai < (dd)sum) {
            ok = false;
        }
        sum *= ai;
    } 

    if (sum == 0) {
        cout << 0 << endl;
    } else if (ok) {
        cout << sum << endl;
    } else {
        cout << -1 << endl;
    }
    
}

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

int n;
string s;

vector<int> pos[10];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	cin >> s;

	for (int i = 0; i < n; ++i) {
		int c = s[i] - '0';
		pos[c].push_back(i);
	}

	int ans = 0;

	int d[3];
	for (d[0] = 0; d[0] < 10; ++d[0]) {
		for (d[1] = 0; d[1] < 10; ++d[1]) {
			for (d[2] = 0; d[2] < 10; ++d[2]) {
				int ls = -1;
				bool good = true;
				for (int i = 0; i < 3; ++i) {
					int c = d[i];
					auto it = upper_bound(pos[c].begin(), pos[c].end(), ls);
					if (it == pos[c].end()) {
						good = false;
						break;
					}
					ls = *it;
				}
				if (good) {
					++ans;
				}
			}
		}
	}

	cout << ans << '\n';
}


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

int main(int argc, char const *argv[])
{
    int n;cin>>n;
    vector<int> h(n);
    vector<int> dp(n,-1);
    for(int i=0;i<n;++i)cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    if (n==2){
        cout << dp[1]<< endl;
        return 0;
    }
    dp[2]=min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]));
    if (n==3){
        cout << dp[2]<< endl;
        return 0;
    }
    for(int i=3;i<n;++i){
        int d1 =dp[i-1]+abs(h[i]-h[i-1]);
        int d2 =dp[i-2]+abs(h[i]-h[i-2]);
        dp[i]=min(d1,d2) ;
    }
    cout << dp[n-1]<<endl;

    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n;
vll G[100005];
ll dist[100005];


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n;
  rep(i,n-1){
    ll a,b; cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dist[0]=1,dist[n-1]=2;
  queue<pll> q;
  q.emplace(0,1);
  q.emplace(n-1,2);
  while(!q.empty()){
    ll v=q.front().first, c=q.front().second;
    q.pop();
    for(auto nv:G[v]){
      if(dist[nv]!=0) continue;
      dist[nv]=c;
      q.emplace(nv,c);
    }
  }
  ll f=0,s=0;
  rep(i,n){
    if(dist[i]==1) f++;
    else s++;
  }
  if(f>s) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}

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

int main() {
	int W=0;
	int H=0;
	int x=0;
	int y=0;
	int r=0;
	
	cin>>W>>H>>x>>y>>r;
	
	if (x-r<0||y-r<0||x+r>W||y+r>H){
		cout<<"No"<<endl;
	} else {
		cout<<"Yes"<<endl; 
	}
	
}




Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, W;
    cin >> N >> W;
    vector<long long> dp(W + 1);
    for (int i = 0; i < N; ++i) {
        int w, v;
        cin >> w >> v;
        for (int j = W; j >= w; --j)
            dp[j] = max(dp[j], dp[j - w] + v);
    }
    cout << dp[W] << endl;
}



Measured memory_bytes: 1024
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,k;
        long sum;
        int[][] A = new int[101][101];
        int[][] B = new int[101][101];
        int[] n = new int[990];
        String[] str = new String[990];
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().split(" ");
        for(i=0;i<3;i++){
            n[i]=Integer.parseInt(str[i]);   
        }
        for(i=0;i<n[0];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[1];j++){
                A[i][j]=Integer.parseInt(str[j]);
            }
        }
        for(i=0;i<n[1];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[2];j++){
                B[i][j]=Integer.parseInt(str[j]);
            }
        }
        for(i=0;i<n[0];i++){
            for(j=0;j<n[2];j++){
                sum=0;
                for(k=0;k<n[1];k++){
                    sum += B[k][j]*A[i][k];             
                }
                if(j!=0) System.out.print(" ");
                System.out.print(sum);
            }
            System.out.println();
        }      
        System.out.flush();
    }
}

Measured memory_bytes: 38068
using System;
using System.Linq;

namespace aoj_ALDS1_1_D
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			int priceCount = int.Parse(Console.ReadLine());
			long[] priceArray = new long[priceCount];
            for (int i = 0; i < priceCount; i++)
			{
				priceArray[i] = long.Parse(Console.ReadLine());
			}

			long maxDifference = -999999999;
			long maxPrice = priceArray.Max();
			//long maxPriceIndex = priceArray.Where(d => d == maxPrice);
            for (int i = 0; i < priceCount; i++)
			{
				if (i == priceCount - 1) break;

				if (maxPrice == priceArray[i]) maxPrice = priceArray.Where((d, index) => index > i).Max();

				long difference = maxPrice - priceArray[i];
				if (difference > maxDifference)
				{
					maxDifference = difference;
				}
			}

			Console.WriteLine(maxDifference);
        }
    }
}



Measured memory_bytes: 13280
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    long double l=abs(a-b);
    long double s=v-w;
    if(l==0||(l/s<=t&&s>0)){
        out("YES");
    }
    else {
        out("NO");
    }
}

Measured memory_bytes: 3560
lst = [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]
k = int(input())

print(lst[k-1])

Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
//////////////////////////////////////////////////////////////////////

int main() {
	int n; cin >> n;
	vi a(n); rep(n)cin >> a[i];
	vi b(n);
	int mn = 0;
	int maxn = a[0];
	rep(n) {
		b[i] = a[i];
		if (a[i] > maxn) {
			maxn = a[i];
			mn = i;
		}
	}
	sort(all(b)); reverse(all(b));
	rep(n) {
		if (i != mn) {
			cout << b[0] << endl;
		}
		else {
			cout << b[1] << endl;
		}
	}
	return 0;
}

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

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

	int ans = 1;
	for (int i = n; i <= m / 2; ++i) {
		if (m%i == 0) {
			ans = m / i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,x;

int main(){
	ios::sync_with_stdio(0);
	cin>>n>>x;
	if(x==1||x==2*n-1) cout<<"No"<<endl;
	else{
		cout<<"Yes"<<endl;
		if(n==2){
			cout<<1<<endl<<2<<endl<<3<<endl;
		}
		else{
			vi a(5);
			a[0]=((x==2)?3:2);
			a[1]=2*n-1;
			a[2]=x;
			a[3]=1;
			a[4]=((x==2*n-2)?2*n-3:2*n-2);
			int tmp=3;
			if(tmp==a[0]) tmp++;
			for(int i=0;i<n-3;i++){
				if(tmp==x) tmp++;
				cout<<tmp<<endl;
				tmp++;
			}
			for(int i=0;i<5;i++) cout<<a[i]<<endl;
			tmp=2*n-3;
			if(tmp==a[4]) tmp--;
			for(int i=0;i<n-3;i++){
				if(tmp==x) tmp--;
				cout<<tmp<<endl;
				tmp--;
			}
		}
	}
}

Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n, w, d; cin >> n >> w >> d;
		if (w == 0) break;
		vector<int> x(1, w), y(1, d);
		while (n--) {
			int p, s; cin >> p >> s;
			p--;
			int w = x[p], d = y[p];
			x.erase(x.begin() + p);
			y.erase(y.begin() + p);
			s %= (w + d);
			int w1, d1, w2, d2;
			if (s < w) {
				w1 = s; w2 = w - s;
				d1 = d2 = d;
			}
			else {
				s -= w;
				w1 = w2 = w;
				d1 = s; d2 = d - s;
			}
			if (w1 * d1 > w2 * d2) {
				swap(w1, w2);
				swap(d1, d2);
			}
			x.push_back(w1);
			y.push_back(d1);
			x.push_back(w2);
			y.push_back(d2);
		}
		vector<int> v;
		for (int i = 0; i < x.size(); i++)
			v.push_back(x[i] * y[i]);
		sort(v.begin(), v.end());
		for (int i = 0; i < v.size(); i++)
			cout << v[i] << (i + 1 < v.size() ? ' ' : '\n');
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    if(n % 2){
        cout << 0 << endl;
        return 0;
    }

    ll res = 0LL;
    n /= 2;
    while(n >= 5){
        res += n / 5;
        n /= 5;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int main(){
	long i,j,k,z;
	long n,m,l,sum,a[100][100],b[100][100];
	char input[6002],*p=NULL;
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%ld %ld %ld",&n,&m,&l);
	
	for(i=0;i<n;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		a[i][0]=atol(p);
		
		for(j=1;j<m;j++){
			p=strtok(NULL," ");
			a[i][j]=atol(p);
		}
		
	}
	for(i=0;i<m;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		b[i][0]=atol(p);
		
		for(j=1;j<l;j++){
			p=strtok(NULL," ");
			b[i][j]=atol(p);
		}
		
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			sum=0;
			for(k=0;k<m;k++){
				sum+=a[i][k]*b[k][j];
			}
			printf("%ld",sum);
			if(j+1!=l){
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 2896
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


int main(){
    ll n,k; cin >> n >> k;
    ll r,s,p; cin >> r >> s >> p;
    string t;cin >> t;
    vector<ll> vec(n,0);
    rep(i,n){
        if(t[i] == 'r')vec[i] = p;
        if(t[i] == 's')vec[i] = r;
        if(t[i] == 'p')vec[i] = s;
    }
    bool same = false;
    ll sum = 0;
    rep(i,k){
        for(int j = i; j < n; j += k){
            if(j == i){
                sum += vec[j];
                same = false;
                continue;
            }
            if(t[j] == t[j-k]){
                if(same)sum += vec[j];
                same ^= true;
            }
            else{
                sum += vec[j];
                same = false;
            }
        }
    } 
    // ll sum = 0;
    // rep(i,n)sum += vec[i];
    cout << sum << endl;
    // string str[k];
    // rep(i,k){
    //     for(int j = i; j < n; j += k){
    //         str[i] += t[j];
    //     }
    // }
    // auto point = [&](string str, int index){
    //     ll ret = 0;
    //     if(str[index] == 'p')ret = s;
    //     else if(str[index] == 'r')ret = p;
    //     else ret = r;
    //     return ret;
    // };
    // auto solve = [&](string str){
    //     ll ret = 0;
    //     ll n = str.size();
    //     ll pre = -1;
    //     rep(i,n){
    //         if(!i)ret += point(str, i);
    //         else if(pre != point(str, i))ret += point(str, i);
    //         if(pre == point(str, i))pre = 0;
    //         else pre = point(str, i);
    //     }
    //     return ret;
    // };
    // ll ret = 0;
    // rep(i,k)ret += solve(str[i]);
    // cout << ret << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
const int N=101;
const int K=100001;
ll dp[N][K];


int main()
{
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];

  dp[0][0]=1;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=k;j++)
    {
      dp[i][j]+=dp[i-1][j];
      dp[i][j]=dp[i][j]%mod;
      if(j!=0)
      {
        dp[i][j]=dp[i][j]+dp[i][j-1];
        dp[i][j]=dp[i][j]%mod;
      }

      if(j-a[i-1]-1>=0)
      {
        dp[i][j]+=mod;
        dp[i][j]-=dp[i-1][j-a[i-1]-1];
        dp[i][j]=dp[i][j]%mod;
      }
    }
  }
  cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 81724
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;



int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){ cin>>a[i]; a[i]-=(i+1); sum+=a[i]; }
  sort(a.begin(),a.end());

  
  
  sum /= n;
  if(n%2==1){sum=a[n/2];}else{sum=(a[n/2]+a[n/2-1])/2;}
  
  ll ans=0;
  rep(i,n){ ans+=abs(a[i]-sum); }
  
  ll res=0;
  sum--;
  rep(i,n){ res+=abs(a[i]-sum); }
  ans = min(ans,res);

  res=0;
  sum+=2;
  rep(i,n){ res+=abs(a[i]-sum); }
  ans = min(ans,res);
  
  cout << ans << endl;
  return 0;
}

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

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

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

const int MOD = (int)1e9+7;

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

	if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3))	cout << "Bad" << endl;
	else	cout << "Good" << endl;

	return 0;
}


Measured memory_bytes: 256
#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& j: v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os <<j;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

vector<vi> g;
vi p;
vi h;
void dfs(int x, int prev) {
    p[x] = prev;
    h[x] = (prev == -1) ? 0 : h[prev] + 1;

    for (int y : g[x]) {
        if (y != prev) {
            dfs(y, x);
        }
    }
}

struct v {
    int a;
    int b;
    int c;
};

bool comp(const v& x, const v& y) {
    return x.c < y.c;
}

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    vi r(n, 0);
    vi g(n, 0);
    vi b(n, 0);
    for (int i=n-2; i>=0; i--) {
        r[i] = r[i+1];
        g[i] = g[i+1];
        b[i] = b[i+1];
        if (s[i+1] == 'R') {
            r[i]++;
        }
        if (s[i+1] == 'G') {
            g[i]++;
        }
        if (s[i+1] == 'B') {
            b[i]++;
        }
    }

    ll ans = 0;
    for (int i = 0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (s[i] != s[j]) {
                if (s[i] != 'R' && s[j] != 'R') {
                    ans += r[j];
                } else if (s[i] != 'G' && s[j] != 'G') {
                    ans += g[j];
                } else if (s[i] != 'B' && s[j] != 'B') {
                    ans += b[j];
                }
                if (j + j - i < n && s[j + j - i] != s[i] && s[j+j-i] != s[j]) {
                    ans--;
                }
            }
        }
    }
    cout << ans;
}

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

    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[100];
    int g = 0;
    int l = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] % 2 == 0) {
            g++;
            if(a[i] % 5 == 0 || a[i] % 3 == 0){
                l++;
            }
        }
    }
    if(l == g){
        cout << "APPROVED";
    } else{
        cout << "DENIED";
    }
    
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>


using namespace std;


int main()
{
	int r, c;
	int **sheet;

	cin >> r >> c;

	/* 初期化 */
	sheet = new int*[r + 1];
	for(int i = 0; i < r + 1; i++)
		sheet[i] = new int[c + 1];

	// 横合計
	for(int i = 0; i < r + 1; i++)
		sheet[i][c] = 0;
	// 縦合計
	for(int i = 0; i < c; i++)
		sheet[r][i] = 0;

	/* 入力 & 計算 */
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			cin >> sheet[i][j];
			sheet[i][c] += sheet[i][j];
			sheet[r][j] += sheet[i][j];
		}
	}
	for(int i = 0; i < c; i++)
		sheet[r][c] += sheet[r][i];

	/* 表示 */
	for(int i = 0; i < r + 1; i++){
		for(int j = 0; j < c + 1; j++){
			cout << sheet[i][j];
			if(j != c)
				cout << " ";
		}
		cout << endl;
	}

	return 0;
}


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

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		long A = scan.nextLong();
		long B = scan.nextLong();
		long tmp = (N / (A + B));
		long rem = N - tmp * (A + B);
		long ans = tmp * A + Math.min(A, rem);
		System.out.println(ans);
	}
}


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

int n,x,l;
int ans =0;

int main(){
    cin >> n;
    pair<int,int> rob[n];
    rep(i,n){
        cin >> x >> l;
        rob[i].first = x +l; // ロボの範囲の終了地点
        rob[i].second = x -l; // ロボの範囲の開始地点
    }
    sort(rob, rob+n); //終了地点が小さい順に並べる
    int t = -100000000; //今見ている地点
    rep(i,n){
        if(rob[i].second >= t){
            t = rob[i].first;
            ans +=1;
        }
    }

    cout << ans <<endl;
}

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

void chmax(string &a, string b) {
  if (a == "-")
    a = b;
  else if (a.size() < b.size())
    a = b;
  else if (a.size() == b.size()) {
    if (a < b) a = b;
  }
}

long long num[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[11000];

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

  for (int i = 0; i < 11000; ++i) dp[i] = "-";
  dp[0] = "";
  for (int i = 0; i <= N; ++i) {
    if (dp[i] == "-") continue;
    for (auto a : A) {
      string b = dp[i] + (char)('0' + a);
      chmax(dp[i + num[a - 1]], b);
    }
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 54848
#include <stdio.h>

int main(void)
{
	int x,y;
	int n;
	
	while (1){
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0){
			break;
		}
		
		n = 0;
		while (y != 0){
			if (x < y){
				x += y;
				y = x - y;
				x -= y;
			}
			
			x %= y;
			x += y;
			y = x - y;
			x -= y;
			
			n++;
			if (y == 0){
				break;
			}
		}
		
		printf("%d %d\n", x, n);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int n;
	int a[2][105];
	cin>>n;
	for(int i = 0;i < n; i++){
		cin>>a[0][i];
	}
	for(int i = 0;i < n; i++){
		cin>>a[1][i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		int t = 0;
		for(int j = 0; j <= i; j++){
			t+=a[0][j];
		}
		for(int j = i; j < n; j++){
			t+=a[1][j];
		}
		ans=max(ans,t);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> x(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }
    
    ll ans = 1e15;
    
    for (int i = 1; i <= 100; i++) {
        ll tmp = 0;
        for (int j = 0; j < n; j++) {
            tmp += (i-x[j])*(i-x[j]);
        }
        ans = min(ans,tmp);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 int main()
{
 int m, f, r;
 while(1)
{
 scanf("%d %d %d ", &m, &f, &r);
 if(m==-1&&f==-1&&r==-1)break;
 if(m==-1||f==-1)
{
 printf("F\n");
 }
else if(m+f>=80)
{
 printf("A\n");
 }
else if(m+f>=65)
{
 printf("B\n");
 }
else if(m+f>=50)
{
 printf("C\n");
 }
else if(m+f>=30)
{
 if(r>=50)
{
 printf("C\n");
 }
else
{
 printf("D\n");
 }
 }
else
{
 printf("F\n");
 }
 }
 return 0;
 }
 


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using ull = unsigned long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;
unsigned gcd(unsigned a, unsigned b) {
    if(a < b) return gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g;
    g = gcd(a, b);
    return a*b/g;
}

int main() {
    ull N,M;
    cin >> N >> M;
    vector<ull> a(N);
    ull G = 0;
    ll judge = -1;

    for(ull i = 0; i < N; i++){
        cin >> a[i];
        ll tmpJ = -1;
        ll tmpa = a[i];
        for(int j = 0;  j < 40; j++){
            if(tmpa % 2 == 1){
                tmpJ = j;
                break;
            }
            tmpa /= 2;
        }
        if(i == 0){
            judge = tmpJ;
        }else{
            if(tmpJ != judge){
                cout << 0 << endl;
                return 0;
            }
        }
        a[i] /= 2;
    }
    G = a[0];
    if(G > M){
        cout << 0 << endl;
        return 0;
    }
    for (int i = 1; i < N; ++i) {
        G = lcm(G,a[i]);
        if(G > M){
            cout << 0 << endl;
            return 0;
        }
    }
    if((M / G) % 2 == 1){
        cout << (M / G + 1) / 2 << endl;
    } else{
        cout << (M / G) / 2 << endl;
    }
    //cout << G << endl;


}


Measured memory_bytes: 1152
n = int(input())

S = [input() for i in range(n)]

from collections import Counter
c = Counter(S)
# print(c)
A = [[c[i], i] for i in c.keys()]
A.sort(reverse=True)
ANS = []
m = A[0][0]
i = 0
while i < len(A) and A[i][0] == m:
    ANS.append(A[i][1])
    i += 1
ANS.sort()
for i in range(len(ANS)):
    print(ANS[i])

Measured memory_bytes: 120144
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
const int N=1e2+5;
int main()
{
    int n=D();
    int k=D();
    set<int>st;
    for(int i=0; i<k; ++i)st.insert(D());
    while(n)
    {
        int x=n;

        bool f= false;
        while(x)
        {
            if(st.count(x%10))
            {
                f=true;
                break;
            }
            x/=10;
        }
        if(f)
        {
            n++;
            continue;
        }
        cout<<n<<endl;
        return 0;
    }

}


Measured memory_bytes: 256
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);

		String line = sc.nextLine();
		while (line.equals("0 0 0 0 0 0") == false) {
			String[] nico = line.split(" ");

			int[] a = new int[3];
			int[] m = new int[3];
			int[] xyz = new int[3];
			int[] r = new int[3];

			for (int i = 0; i < a.length; i++) {
				a[i] = Integer.parseInt(nico[i * 2]);
				m[i] = Integer.parseInt(nico[i * 2 + 1]);
				xyz[i] = 1;
				r[i] = 0;
			}
			
			int count = 0;
			
			boolean flag = false;
			while (flag == false) {
				flag = true;
				count++;
	
				for (int i = 0; i < xyz.length; i++) {
					if (r[i] == 0) xyz[i] = (a[i] * xyz[i]) % m[i];

					if (xyz[i] == 1) {
						if (r[i] == 0) {
							r[i] = count;
						}
					} else {
						flag = false;
					}
				}
			}

			count = 1;
			flag = false;
			
			long p = r[0];
			long q = r[1];
			
			for (int i = 0; i < 2; i++) {
				if (p < q) {
					long tmp = p;
					p = q;
					q = tmp;
				}
				
				long np = p;
				long nq = q;
				while (nq != 0) {
					long tmp = np % nq;
					np = nq;
					nq = tmp;
				}
				
				p = p * q / np;
				q = r[2];
			}
			System.out.println(p);

			line = sc.nextLine();
		}
	}
}

Measured memory_bytes: 28108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=310,mod=1e9+7;
int n,a[N<<1],t[N<<1],c[N<<1],cnt,CNT;
void pls(int &x,int y){x+=y;x>=mod?x-=mod:0;}
int dp[N<<1][N][N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=2*n;i++)scanf("%d",&a[i]);
	
	for (int i=1;i<=2*n;i+=2) 
	if (a[i]!=-1&&a[i+1]!=-1) t[a[i]]=t[a[i+1]]=2;
	else if (a[i]!=-1) t[a[i]]=1;
	else if (a[i+1]!=-1)t[a[i+1]]=1;
	else CNT++;
	for (int i=1;i<=2*n;i++) 
	if (t[i]==1) c[++cnt]=1;else if (!t[i]) c[++cnt]=0;
	dp[cnt][0][0]=1;
	for (int i=cnt;i;i--) 
		for (int j=0;j<=cnt&&j<=n;j++)
			for (int k=0;k<=cnt&&k<=n;k++) 
			if (c[i]==1)
			{
				pls(dp[i-1][j+1][k],dp[i][j][k]);
				if (k)pls(dp[i-1][j][k-1],dp[i][j][k]);
			} else
			{
				pls(dp[i-1][j][k+1],dp[i][j][k]);
				if (k)pls(dp[i-1][j][k-1],dp[i][j][k]);
				if (j)pls(dp[i-1][j-1][k],(ll)dp[i][j][k]*j%mod);
			}
	ll ans=dp[0][0][0];
	for (int i=1;i<=CNT;i++) ans=ans*i%mod;
	cout<<ans;
}

Measured memory_bytes: 225536
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int dp[52][52];
int isolate[52];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int a, b;
  vii v(m);
  fi(0, m) {
    cin >> a >> b;
    dp[a][b] = 1;
    dp[b][a] = 1;
    v[i].first = a;
    v[i].second = b;
  }
  for(auto& x: v) {
    a = x.first;
    b = x.second;
    dp[a][b] = 0;
    dp[b][a] = 0;
    vi arr(n + 1);
    queue<int> q;
    q.push(1);
    arr[1] = 1;
    int cnt = 1;
    while(!q.empty()) {
      int y = q.front();
      q.pop();
      for(int j = 1; j <= n; j++) {
        if(arr[j] == 0 && dp[y][j]) {
          q.push(j);
          arr[j] = 1;
          cnt++;
        }
      }
    }
    dp[a][b] = 1;
    dp[b][a] = 1;
    //printf("a: %d, b: %d, cnt: %d\n", a, b, cnt);
    if(cnt != n) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
while 1:
  try:
    c = [0]*101
    while 1:
      a, b = map(int, raw_input().split())
      if a==0==b:break
      c[a] += 1
      c[b] += 1
    c = map(lambda x: x%2, c)
    if c[1] and c[2] and sum(c[3:])==0:print"OK"
    else:print"NG"
  except:break

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A,B,C;
    cin >> A >> B;
    if(A + B == "12" || B + A == "12"){
        cout << "3" << endl;
    }
    else if(A + B == "23" || B + A == "23"){
        cout << "1" << endl;
    }
    else {
        cout << "2" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int[][] A = new int[3][3];
	for(int i=0;i<3;i++){
	    for(int j=0;j<3;j++){
		A[i][j] = stdIn.nextInt();
	    }
	}
	int N = stdIn.nextInt();
	for(int k=0;k<N;k++){
	    int b = stdIn.nextInt();
	    for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
		    if(b==A[i][j]){
			A[i][j]=0;
		    }
		}
	    }
	}
	
	boolean flag=false;
	for(int i=0;i<3;i++){
	    if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
		flag=true;
	    }
	    if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
		flag=true;
	    }
	}
	if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
	    flag=true;
	}	
	if(A[2][0]==0&&A[1][1]==0&&A[0][2]==0){
	    flag=true;
	}
	if(flag==true){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}

Measured memory_bytes: 21972