akhauriyash/Code-Regression huggingface dataset:
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back

using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;


int main()
{
	migmig ;
	char c ; 
	cin>>c ; 
	c+= 1 ; 
	cout<<c ; 
}
//////
////////
///////////




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

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

int main(void) {
	ll a, b, ans;
	cin >> a >> b;
	ans = a * b / gcd(a, b);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N, M, P = map(int, readline().split())

EDGES = []
TO = [[] for _ in range(N + 1)]
RTO = [[] for _ in range(N + 1)]

for _ in range(M):
    a, b, c = map(int, readline().split())
    EDGES.append((a, b, c))
    TO[a].append(b)
    RTO[b].append(a)

# 1から到達可能な点
REACH_FROM_1 = [False] * (N+1)
q = [1]
while q:
    u = q.pop()
    if REACH_FROM_1[u]:
        continue
    REACH_FROM_1[u] = True
    for v in TO[u]:
        q.append(v)

# Nから到達可能な点
REACH_TO_N = [False] * (N + 1)
q = [N]
while q:
    u = q.pop()
    if REACH_TO_N[u]:
        continue
    REACH_TO_N[u] = True
    for v in RTO[u]:
        q.append(v)

STATE = [REACH_FROM_1[i] & REACH_TO_N[i] for i in range(N + 1)]


INF = 10 ** 12
POINT = [INF] * (N + 1)

POINT[1] = 0

for i in range(N):
    update = False
    for j in range(M):
        a, b, c = EDGES[j]
        if not STATE[a]:
            continue
        pt = - (c - P)
        if POINT[a] != INF and POINT[a] + pt < POINT[b]:
            POINT[b] = POINT[a] + pt
            update = True

            if i == N-1:
                print(-1)
                exit()

    if not update:
        break

# print(POINT)
pt = -POINT[N]

ans = pt if pt > 0 else 0
print(ans)


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

int main(){
    int n = 3000;
    int tmp;
    int x;
    int y;
    for(int i = 0; i < n; i++){
        cin >> x;
        cin >> y;

        if(x == 0 and y == 0){
            break;
        }

        if (y < x){
            tmp = x;
            x = y;
            y = tmp;
        }

        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int maxn = 1e5 +10;

int num1;
int num2;
int num4;


int main()
{
    int n,x;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&x);
        if( x%4 == 0)
            num4++;
        else if( x%2 == 0)
            num2++;
        else
            num1++;
    }
//    cout<<num1<<" "<<num2<<" "<<num4<<endl;
    if(num2)
        num1++;
    if(num1 > num4 + 1)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;


    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()

dp=[[0 for _ in range(len(t)+1)] for _ in range(len(s))]

ans=[]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i][j-1],dp[i-1][j])

x_index=len(t)-1
y_index=len(s)-1

if  dp[y_index][x_index]==0:
    print()
    exit()

while True:
    if t[x_index]==s[y_index]:
        ans.append(t[x_index])
        if dp[y_index][x_index]==1:
            break
        else:
            x_index-=1
            y_index-=1
            continue

    else:
        if dp[y_index][x_index]==dp[y_index][x_index-1]:
            x_index-=1
        else:
            y_index-=1


X=reversed(ans)
print(''.join(X))


Measured memory_bytes: 152976
import java.util.*;
 
public class Main{
    public static void main(String args[])throws Exception{
        Scanner stdin = new Scanner(System.in);
 
        String S = stdin.next();
 
        if(S.equals("SUN")){
            System.out.print("7");
        }
        else if(S.equals("MON")){
            System.out.print("6");
        }
        else if(S.equals("TUE")){
            System.out.print("5");
        }
        else if(S.equals("WED")){
            System.out.print("4");
        }
        else if(S.equals("THU")){
            System.out.print("3");
        }
        else if(S.equals("FRI")){
            System.out.print("2");
        }
        else if(S.equals("SAT")){
            System.out.print("1");
        }
    }
}

Measured memory_bytes: 23508
# -*- coding:utf-8 -*-

def add_roop(pre_result, pro_s):
    result = 0

    for i in range(len(pro_s)):
        if i == 0 :
            result = pre_result + int(pro_s)
        else:
            result =  result + add_roop(pre_result + int(pro_s[:i]), pro_s[i:])

    return result

if __name__ == "__main__":
    #
    s = raw_input()
    print add_roop(0, s)


Measured memory_bytes: 2568
a,b,k=map(int, input().split())

if k%2==0:
  l=k//2
  for i in range(l):
    if a%2==0:
      x = a//2
      a = x
      b += x
      if b%2==0:
        x = b//2
        b = x
        a += x
      else:
        x = (b-1)//2
        b = x
        a += x
    else:
       x=(a-1)//2
       a = x
       b += x
       if b%2==0:
        x = b//2
        b = x
        a += x
       else:
        x = (b-1)//2
        b = x
        a += x
else:
  l=(k-1)//2
  for i in range(l):
    if a%2==0:
      x = a//2
      a = x
      b += x
      if b%2==0:
        x = b//2
        b = x
        a += x
      else:
        x = (b-1)//2
        b = x
        a += x
    else:
       x=(a-1)//2
       a = x
       b += x
       if b%2==0:
        x = b//2
        b = x
        a += x
       else:
        x = (b-1)//2
        b = x
        a += x
  if a%2==0:
      x = a//2
      a = x
      b += x
  else:
       x=(a-1)//2
       a = x
       b += x

print(a,b,sep=' ')

Measured memory_bytes: 3064
import math

def main():
    a, b, h, m = (int(i) for i in input().split())

    rad = 2.0 * math.pi * ((h / 12) + (m / 60 / 12) - (m / 60))

    # coordinates of the hour hand endpoint, in centimeters
    hx, hy = math.cos(rad) * a, math.sin(rad) * a
    mx, my = b, 0 

    # euclidean distance between (hx, hy) and (mx, my)
    d = math.sqrt((hx - mx)**2 + (hy - my)**2)
    print(d)


main()


Measured memory_bytes: 9332
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0
int alpha[256],check[256],least[256];
int used[10];
vector<char> nonzero;
vector<pair<int,char> > piece;

#if DEB
stack<pair<int,int> > spi;
#endif


bool ok(char n){
	rep(i,nonzero.size())if( nonzero[i]==n )return false;
	return true;
}

int solve(int cnt, int sum){
	if( cnt>piece.size() )return 0;
	if( cnt==piece.size() ){
#if DEB		
		if( sum==0 ){
			stack<pair<int,int> > tmp = spi;
			while( !tmp.empty() ){
				printf("%c:%d\n",(char)tmp.top().first, tmp.top().second);
				tmp.pop();
			}
			puts("------------------");
		}
#endif		
		return sum==0;
	}
	int minn=9,maxn=0;
	rep(num,10)if( !used[num] ){
		minn = min(minn, num);
		maxn = max(maxn, num);
	}
	int lower=0, upper=0;
	for(int i=cnt; i<piece.size(); i++){
		if( piece[i].first>0 ){
			upper += piece[i].first * maxn;
			lower += piece[i].first * minn;
		}else{
			upper += piece[i].first * minn;
			lower += piece[i].first * maxn;
		}
	}
	if( sum+upper<0 || 0<sum+lower ) return 0;
	//printf("lower, upper = %d, %d\n",lower,upper);

	
	int ret = 0;
	rep(num,10)if( !used[num] ){
		if( num==0 ){
			if( !ok(piece[cnt].second) )continue;
		}
		used[num] = 1;
#if DEB		
		spi.push(mp(piece[cnt].second,num));
#endif		
		ret += solve(cnt+1, sum+piece[cnt].first*num);

#if DEB		
		spi.pop();
#endif
		
		used[num] = 0;
	}
	return ret;
}


int main(){
	int n,sz,k;
	char str[16];
	
	while(scanf("%d",&n),n){
		piece.clear();
		nonzero.clear();
		rep(i,256)alpha[i]=check[i]=least[i]=0;
		memset(used,0,sizeof(used));
		
		rep(i,n-1){
			scanf("%s",str);
			sz = strlen(str);
			k = 1;
			if( sz>1 ){
				least[str[0]] = 1;
			}
			rep(j,sz){
				alpha[str[sz-j-1]] += k;
				check[str[sz-j-1]] = 1;
				k *= 10;
			}
		}
		scanf("%s",str);
		sz = strlen(str);
		k = 1;
		if( sz>1 ){
			least[str[0]] = 1;
		}
		rep(j,sz){
			alpha[str[sz-j-1]] -= k;
			check[str[sz-j-1]] = 1;
			k *= 10;
		}

#if DEB		
		rep(i,256)if( alpha[i]!=0 ){
			printf("%c : %d\n",(unsigned char)i, alpha[i]);
		}
#endif
		rep(i,256)if( check[i]!=0 ){
			piece.push_back(mp(alpha[i],(char)i));
		}
		sort(all(piece));
		rep(i,256)if( least[i]!=0 ){
			nonzero.push_back((char)i);
		}

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

Measured memory_bytes: 932
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

long long N;
long long dp[100010];

const long long INF = 1LL << 60;

void chmin(long long &a, long long b)
{
  if(a>b)
    a=b;
}

int main()
{
  cin >>N;

  for(int i=0; i<=N; i++)
    dp[i] = INF;

  dp[0]=0;
  for(int i=0; i<N; i++)
    {
      chmin(dp[i+1], dp[i]+1);

      for(int j=0;i+pow(6,j)<=N;j++)
	{
	  chmin(dp[i+int(pow(6,j))], dp[i]+1);    
	}
      for(int j=0;i+pow(9,j)<=N;j++)
	{
	  chmin(dp[i+int(pow(9,j))], dp[i]+1);
	}
    }
  // for(int i=0; i<=N; i++)
    //    cout <<i<<"円:"<< dp[i] << endl;
  cout << dp[N] << endl;
  return 0;
}

  
  /*
  int ans=0;
  long long val=0;
  long long temp;
  while(N-val>6)
    {
      temp=1;
      if(val+temp*9<=N)
	{
	  ans++;
	  while(val+temp*9<=N)
	    temp *= 9;
	  val += temp;
	}
      cout << val << endl;
      
      temp=1;
      if(val+temp*6<=N)
	{
	  ans++;
	  while(val+temp*6<=N)
	    temp *= 6;
	  val+=temp;
	}
      cout << val <<  endl;
    }
    cout << ans+N-val << endl;
      
  */



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define MAX 100000

#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> hight;
	vector<vector<int>> adj(MAX);

	for (int i=0; i<n; i++) {
		int tmp_h;
		cin >> tmp_h;
		hight.push_back(tmp_h);
	}

	for (int i=0; i<m; i++) {
		int tmp_from, tmp_to;
		cin >> tmp_from >> tmp_to;
		tmp_from--;
		tmp_to--;
		adj[tmp_from].push_back(tmp_to);
		adj[tmp_to].push_back(tmp_from);
	}

	int count = 0;
	for (int i=0; i<n; i++) {
		bool best_view_flag = true;
		int target_height = hight[i];
		for (int j=0; j<(int)adj[i].size(); j++) {
			if (target_height <= hight[adj[i][j]]) {
				best_view_flag = false;
			}
		}
		if(best_view_flag) {
			count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 8756
import sys
k = int(input())
seven = 7
ans = -1
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    sys.exit()
for cnt in range(1, 10**6):
    if seven % k == 0:
        ans = cnt
        break
    seven *= 10
    seven = (seven + 7) % k
print(ans)

Measured memory_bytes: 63280
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);printf("%d\n",a+b+c-max(a,max(b,c)));
}

Measured memory_bytes: 128
import collections

n = int(input())
aList = list(map(int, input().split()))
num = collections.Counter(aList)
ans = 0
for x in range(10 ** 5):
    count = num[x - 1] + num[x] + num[x + 1]
    if ans < count:
        ans = count
print(ans)

Measured memory_bytes: 14564
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
int id[N];
bool vis[N]; 
vector<int>v[N];
int dfs(int x,int f)
{
	if(id[x]>2) return x;
	for(auto u:v[x])
	{
		if(u==f) continue;
		return dfs(u,x);
	}
	return x;
}
int main()
{
	int n;
	cin>>n;
	for(int i=1,x,y;i<n;i++)
	{
		cin>>x>>y;
		x++;
		y++;
		v[x].push_back(y);
		v[y].push_back(x);
		id[x]++;
		id[y]++; 
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	 if(id[i]==1) ans++,vis[dfs(i,0)]=1;
	for(int i=1;i<=n;i++)
	 if(vis[i]) ans--;
	if(ans==0) ans=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6656
#include<stdio.h>
int main()
{
    int X,A;
    scanf("%d%d",&X,&A);

    if(X<A){
            printf("0\n");
    }else if(X>A){
        printf("10\n");

    }else if(X==A){
        printf("10\n");
    }
    return 0;





}


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

namespace ITP2_8_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            Dictionary<string, List<int>> sd = new Dictionary<string, List<int>>();
            SortedSet<string> ss = new SortedSet<string>();
            for (int i = 0 ; i < n ; i++)
            {
                string[] line = ReadStAr();
                switch (int.Parse(line[0]))
                {
                    case 0:
                        if (sd.ContainsKey(line[1]))
                        {
                            sd[line[1]].Add(int.Parse(line[2]));
                        }
                        else
                        {
                            sd.Add(line[1], new List<int>());
                            sd[line[1]].Add(int.Parse(line[2]));
                            ss.Add(line[1]);
                        }
                        break;
                    case 1:
                        if (sd.ContainsKey(line[1]))
                        {
                            foreach (var item in sd[line[1]])
                            {
                                Console.WriteLine(item);
                            }
                        }
                        break;
                    case 2:
                        sd.Remove(line[1]);
                        ss.Remove(line[1]);
                        break;
                    case 3:
                        foreach (var item in ss.GetViewBetween(line[1], line[2]))
                        {
                            foreach (var item2 in sd[item])
                            {
                                Console.WriteLine("{0} {1}", item, item2);
                            }                        
                        }
                        break;
                }

            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 49500
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

void check()
{
	ll n;
	cin >> n;
	string ans = "";
	while(n>0) --n, ans += (char)(97+(n%26)), n/=26;
	reverse(ans.begin(),ans.end());
	cout << ans;
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A ;
  B = N % 500 ;
  
  if (A-B >=0 ) {
    cout << "Yes" << endl;
  }
  if (A-B <0 ) {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3552
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CStrawberryCakes {
public:

    vector<int> vec[303];
    set<int> row;

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w, k; cin >> h >> w >> k;
      vector<vector<int>> mat(h, vector<int>(w));
      int now = 1;
      rep(i, h) {
        rep(j, w) {
          char c; cin >> c;
          if (c == '#') {
            mat[i][j] = now;
            now++;
            vec[i].push_back(j);
            row.insert(i);
          }
        }
      }

      rep(i, h) {
        for(int j=0; j<w-1; j++) {
          if (mat[i][j] != 0 && mat[i][j+1] == 0) {
            mat[i][j+1] = mat[i][j];
          }
        }
        for(int j=w-1; j>0; j--) {
          if (mat[i][j] != 0 && mat[i][j-1] == 0) {
            mat[i][j-1] = mat[i][j];
          }
        }
      }

      rep(i, h) {
        if (i > 0 && row.find(i) == row.end()) {
          rep(j, w) mat[i][j] = mat[i-1][j];
        }
      }

      for(int i=h-1; i>=0; i--) {
        if (i < h-1 && row.find(i) == row.end()) {
          rep(j, w) mat[i][j] = mat[i+1][j];
        }
      }

      rep(i, h) {
        rep(j, w) {
          cout << mat[i][j] << ' ';
        }
        cout << '\n';
      }

    }
};

signed main() {
  CStrawberryCakes solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        for (long h = 1; h <= 3500; h++) {
            for (long k = 1; k <= 3500; k++) {
                if (4 * h * k - n * (h + k) == 0) {
                    continue;
                }
                if (n * h * k % (4 * h * k - n * (h + k)) != 0) {
                    continue;
                }
                long w = n * h * k / (4 * h * k - n * (h + k));
                if(w <= 0){
                    continue;
                }
                System.out.printf("%d %d %d%n", h, k, w);
                return;
            }
        }
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vl x1(N);
  vl x2(M);
  rep(i,N) cin>>x1[i];
  rep(i,M) cin>>x2[i];
  sort(all(x1));
  sort(all(x2));
  if(x2[0]-x1[N-1]>0&&x1[N-1]<Y&&x2[0]>X){
    cout<<"No War"<<endl;
  }
  else{
    cout<<"War"<<endl;
  }
  
}


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

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr 
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

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

  
n = gcd(A,B)
if(n == 1): ans = 1
else: ans = len(factorization(n))+1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    #define sz(a) (int)(a).size()
    #define debug(x) (cerr << #x << ": " << x << "\n")
     
    using namespace std;
     
    template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
    template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
    const int INF = 1e5+2;
    const long long hell = 998244353ll;
     
    void solve(){
    	int n;
    	cin >> n ;
    	vector<pair<int,int>>arr(n);
    	for(int i = 0 ; i < n ; i++ ){
    		cin >> arr[i].first;
    		arr[i].second = i+1;
    	} 	
    	sort(arr.begin(),arr.end());
    	for(int i = 0 ; i < n ; i++ ) cout << arr[i].second << " ";
    	cout<<endl;	
    }
    int main(){
        	
    	ios_base::sync_with_stdio(0);cin.tie(0);
    	  cout.precision(10);
    cout << fixed;	
    	int q=1;
    #ifdef LOCAL
      	cin>>q;
    #endif
      	while(q--){
      		solve();
      	}
    #ifdef LOCAL
       	cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
    #endif	
    	return 0;
    }

Measured memory_bytes: 1664
import heapq


def solve(k, a_list, b_list, c_list):
    # time (A log(A)), (B log(B)), (C log(C))
    a_list.sort(reverse=True)
    b_list.sort(reverse=True)
    c_list.sort(reverse=True)

    priority_queue = []
    heapq.heappush(priority_queue, [-(a_list[0] + b_list[0] + c_list[0]), 0, 0, 0])
    key_map = {(0, 0, 0)}

    ans = []
    # time (K log(K))
    for _ in range(k):
        sum_data, a_key, b_key, c_key = heapq.heappop(priority_queue)
        ans.append(str(-sum_data))

        if a_key + 1 < len(a_list) and (a_key+1, b_key, c_key) not in key_map:
            heapq.heappush(priority_queue, [-(a_list[a_key+1] + b_list[b_key] + c_list[c_key]), a_key+1, b_key, c_key])
            key_map.add((a_key+1, b_key, c_key))
        if b_key + 1 < len(b_list) and (a_key, b_key+1, c_key) not in key_map:
            heapq.heappush(priority_queue, [-(a_list[a_key] + b_list[b_key+1] + c_list[c_key]), a_key, b_key+1, c_key])
            key_map.add((a_key, b_key+1, c_key))
        if c_key + 1 < len(c_list) and (a_key, b_key, c_key+1) not in key_map:
            heapq.heappush(priority_queue, [-(a_list[a_key] + b_list[b_key] + c_list[c_key+1]), a_key, b_key, c_key+1])
            key_map.add((a_key, b_key, c_key+1))

    return ans


def main():
    x, y, z, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))

    ans = solve(k, a_list, b_list, c_list)
    print("\n".join(ans))


main()


Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   int a,b;
   string op;
   cin >> a >> op >> b;
   cout << (op == "+" ? a+b : a-b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
	int a, b;
	string s;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> s;
			if (s == "snuke") {
				cout << char('A' + j);
				cout << i + 1 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int n,q,p[maxn];
int find(int u)
{
	if(p[u]!=u) p[u]=find(p[u]);
	return p[u];
}
void read(int& ret)
{
	ret=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();
}
int main()
{
	read(n),read(q);
	for(int i=1;i<n;i++) p[i]=i;
	while(q--){
		int type,u,v;
		scanf("%d%d%d",&type,&u,&v);
		int root1=find(u),root2=find(v);
		if(!type) p[root2]=root1;
		else {
			if(root1!=root2) printf("0\n");
			else printf("1\n");
		}
	}
}

Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
ll dp[200003][3];
vector<int>v[200003];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
    }
    int s,t;
    cin>>s>>t;
    queue<pair<int,int> > q;
    memset(dp,0x7f,sizeof dp);
    dp[s][0] = 0;
    q.push({s,0});
    while(!q.empty()){
        int x = q.front().first;
        int r = q.front().second;
        q.pop();
        for(int y:v[x]){
            if(dp[y][(r+1)%3]<dp[0][0])continue;
            dp[y][(r+1)%3] = min(dp[y][(r+1)%3],dp[x][r]+1);
            q.push({y,(r+1)%3});
        }
    }
    if(dp[t][0]==dp[0][0]){
        cout<<-1<<endl;
        return;
    }
    cout<<dp[t][0]/3<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int a,b,c,i=0,j;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	j=a;
	while((b-j)>=0){
		if((c%j)==0)i++;
		j++;
	}
	printf("%d\n",i);
	return EXIT_SUCCESS;
}

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

int main() {
    int64_t n;
    cin >> n;
    map<int64_t, int64_t> m;
    int64_t ans = 0;
    for(int i = 0; i < n; i++){
        int64_t a;
        cin >> a;
        m[a]++;
        ans += a;
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b, c;
        cin >> b >> c;
        ans -= b * m[b];
        ans += c * m[b];
        m[c] += m[b];
        m[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 9572
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(c>a&&c<b) cout << "Yes" << endl;
    else if(c<a&&c>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
}

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


void solve() {
  int N;
  scanf("%d", &N);

  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;

  rep(i, N) {
    string str;
    cin >> str;
    if (str == "AC") {
      ac++;
    } else if (str == "WA") {
      wa++;
    } else if (str == "TLE") {
      tle++;
    } else if (str == "RE") {
      re++;
    }
  }

  cout << "AC x "<< ac << endl;
  cout << "WA x "<< wa << endl;
  cout << "TLE x "<< tle << endl;
  cout << "RE x "<< re << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
  int a, b, cnt = 0, box;
  char suu[6];

  cin >> a >> b;

  for(int i = a; i <= b; i++){
    //string suu = to_string(i);
    box = i;
    for(int j =4; j >= 0; j--){
      suu[j] = box % 10;
      box /= 10;
    }

    if(suu[0] == suu[4] && suu[1] == suu[3])
      cnt++;
  }
  cout << cnt <<endl;

  return 0;
}


Measured memory_bytes: 256
//
//  2017-12-23-A.cpp
//  
//
//  Created by Shingo on 2017/12/23.
//

#include <iostream>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;
int main (){
    int N;
    ll p[1000][1000];
    ll f[1000];
    int count = 0;
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin >> p[i][j];
        }
    }
    for(int i=0;i<N;i++){
        sort(p[i],p[i]+3);
        f[i]=p[i][0]*1001001+p[i][1]*1001+p[i][2];
    }
    sort(f,f+N);
    for(int i=1;i<N;i++){
        if (f[i]==f[i-1]){
            count++;
        }
    }
    cout << count << endl;
    
    
    
    return 0;
}



Measured memory_bytes: 7172
fun main(args: Array<String>) = abc155c()
private inline fun printAnswer(function: StringBuilder.() -> StringBuilder) = print(StringBuilder().let(function))

fun abc155c() = printAnswer {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second

     map.filter { it.second == max }.map { it.first }.sorted().
         forEach { appendln(it) }

    return@printAnswer this
}


Measured memory_bytes: 112464
#include<stdio.h>
#include<queue>
#include<bitset>
using namespace std;

const int N = 8;
const int SHIFT_BITS = 3;

unsigned Swap3Bits(unsigned x, int b1, int b2)
{
	unsigned a,b,s;
	b1 *= SHIFT_BITS;
	b2 *= SHIFT_BITS;
	a = (x& (07<<b1));
	b = (x& (07<<b2));
	s = (a>>b1<<b2) | (b>>b2<<b1);
	return (x&~a&~b)|s;
}

int Ans(int initField)
{
	int ans, i;
	unsigned field;
	static bitset<16777216> bitHis;
	queue<unsigned> q;
	unsigned int NEXT_COUNT = 0xffffffff;

	ans = 0;
	bitHis.reset();
	q.push(initField);
	q.push(NEXT_COUNT);
	for(;;)
	{
		field = q.front();
		q.pop();
		if(field == NEXT_COUNT)
		{
			++ans;
			q.push(NEXT_COUNT);
			continue;
		}
		if(bitHis[field])
			continue;
		if(field == 001234567)
			break;
		bitHis[field] = true;

		int zi = 0;
		for(i = 0; i < N; ++i)
		{
			if( (field & (07<<i*SHIFT_BITS)) == 00)
			{
				zi = i;
				break;
			}
		}
		
		q.push( Swap3Bits(field, zi, (zi<4?zi+4:zi-4)) );
		if((zi&0x3) != 0x3)
			q.push( Swap3Bits(field, zi, zi+1) );
		if((zi&0x3) != 0x0)
			q.push( Swap3Bits(field, zi,zi-1) );
	}
	return ans;
}

int main(void)
{
	int a[N], i;

	for(;;)
	{
		unsigned field = 0;
		for(i = 0; i < N; ++i)
		{
			if(scanf("%d",&a[i])!=1) return 0;
			field |= (a[i] << ( (N-i-1)*SHIFT_BITS) );
		}
		printf("%d\n",Ans(field));
	}
	return 1;
}

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

typedef long long ll;
typedef long double ld;

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

    int N;
    cin >> N;

    int ans = N * 800;
    ans -= (N / 15) * 200;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int n;
    cin >> n;
    cout << n * 800 - (n / 15) * 200 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)


int main() {
  int n;
  string s;

  cin>>n>>s;
  //char z = 'Z';
  //cout<<int('A')<<endl;
  r(i,s.size()){
    if(int(s.at(i)+n)<=90)cout<<char(s.at(i)+n);
    else {
      cout<<char(int(s.at(i)+n)-91+65);
    }
  }
  cout<<endl;
return 0;
}


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

using namespace std;

int N,M;
vector<int> memo(100001,0);
const int mod=1000000007;

int fib(int x){
    if(x==0 || x==1) return 1;
    if(memo[x]!=0) return memo[x];
    return memo[x]=(fib(x-1)%mod+fib(x-2)%mod)%mod;
}

int main(){
    cin>>N>>M;
    int flag=0;
    long ans=1;
    vector<int> a(M+2);
    vector<int> b(M+1);

    for(int i=1;i<=M;i++){
        cin>>a[i];
    }
    a[0]=-1;
    a[M+1]=N+1;

    for(int i=0;i<=M;i++){
        b[i]=a[i+1]-a[i]-2;
        if(b[i]<0){
            flag=1;
            break;
        }
    }
   if(flag==1){
     printf("0");
     return 0;
   }
    for(int i=0;i<=M;i++){
        ans=((ans%mod)*fib(b[i]))%mod;
    }
    
 	if(flag!=1) printf("%ld",ans);

    return 0;
}

Measured memory_bytes: 3712
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def do_dp(N, Adj):
    univ = 2**(N-1) - 1
    dp = [[0]*(N-1) for i in range(univ + 1)]

    for u in range(N - 1):
        if Adj[0][u+1]:
            dp[1<<u][u] = 1

    for S in range(univ + 1):
        for v in range(N - 1):
            S2 = S & (univ ^ (1 << v))
            for u in range(N):
                if ((1 << u) & S2) and Adj[u+1][v+1]:
                    dp[S][v] += dp[S2][u]

    # debug(dp, locals())
    ans = sum(dp[univ][u] for u in range(N - 1))

    return ans

def solve():
    N, M = map(int, input().split())
    Adj = [[0]*N for i in range(N)]

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        Adj[a][b] = 1
        Adj[b][a] = 1

    ans = do_dp(N, Adj)

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



int main()
{
  lint n;
  cin >> n;
  map<string, lint> times;
  lint max = 0;
  REP(i,n){
    string tmp;
    cin >> tmp;
    times[tmp]++;
    if(times[tmp] > max) max = times[tmp];
  }

  auto itr = begin(times);
  while(itr != end(times)){
    if(itr->second == max) cout << itr->first << "\n";
    itr++;
  }
  return 0;
}


Measured memory_bytes: 25216
use strict;
use warnings;

my $in = <>;
chomp $in;
my ($n, $m) = split(/ /, $in);
my @list;
foreach(1..$n){
	$list[$_ - 1] = {hop => -1, color => 0, next => []};
}

foreach(1..$m){
	$in = <>;
	chomp $in;
	my @data = split(/ /, $in);
	push (@{$list[$data[0] - 1]->{next}}, $data[1] - 1);
	push (@{$list[$data[1] - 1]->{next}}, $data[0] - 1);
}

my $max = <>;
chomp $max;
my @q;
foreach (1..$max){
	$in = <>;
	chomp $in;
	push (@q, [split(/ /, $in)]);
}

for(my $i = $max - 1; $i >= 0; $i--){
	my @now = ($q[$i]->[0] - 1);
	foreach (0..$q[$i]->[1]){
		my @next;
		my $hop = $q[$i]->[1] - $_;
		foreach (@now){
			if ($list[$_]->{hop} < $hop){
				$list[$_]->{hop} = $hop;
				if ($list[$_]->{color} == 0){
					$list[$_]->{color} = $q[$i]->[2];
				}
				push(@next, @{$list[$_]->{next}});
			}
		}
		@now = @next;
	}
}

foreach(1..$n){
	print $list[$_-1]->{color}."\n";
}

exit;


Measured memory_bytes: 100352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
int a[100003]; 
int main() {
  int n;
  cin >> n;
  a[0] = 0;
  a[n+1] = 0;
  int sum = 0;
  rep(i,n) {cin >> a[i+1];}
  rep(i,n) {
    sum += abs(a[i+1] - a[i]);
  }
  sum += abs(a[n]);

  for (int i = 1; i <= n; i++)
  {
    if ((a[i-1]<a[i] && a[i]<a[i+1])||(a[i+1]<a[i]&&a[i]<a[i-1])) {
      cout << sum << endl;
    }
    else if(a[i-1]>a[i]&&a[i+1]>a[i]) {
      cout << sum-2*abs(min(a[i-1],a[i+1])-a[i]) << endl;
    } 
    else if(a[i]>a[i+1]&&a[i]>a[i-1]) {
      cout << sum-2*abs(a[i]-max(a[i-1],a[i+1])) << endl;
    } 
    else if (a[i]==a[i-1] || a[i]==a[i+1]) {
      cout << sum << endl;
    } 
  }
  
  return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
#define P 1000000007
#define M 100005

using namespace std;
int Po[M], Pf[M];
// 1LL は1の long long型

int Fast(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1ll*res*x%P;
		x=1ll*x*x%P;
		k>>=1; // ビット演算 半分切り下げ
	}
	return res;
}

int C(int n,int m){
	if(n<m)return 0;
	if(m==n||m==0)return 1;
	return 1ll*Po[n]*Pf[m]%P*Pf[n-m]%P;
}

bool mark[M];
int p,A[M];
int n;

inline void Add(int &a,int b){
	a+=b;
	if(a>P)a-=P;
	else if(a<0)a+=P;
}

int main(){
    cin >> n;
    Po[0] = 1;
    for(int i=1; i<=n+1; i++) Po[i] = 1ll * Po[i-1] * i % P;
    for(int i=0; i<=n+1; i++) Pf[i] = Fast(Po[i], P-2);
    for(int i=1,x; i<= n+1; i++){
        cin >> x;
        if(mark[x] == true) p = x;
        mark[x] = true;
        A[i] = x;
    }

    int l=1, r=n+1;
    while(A[l] != p) l++;
	while(A[r] != p) r--;
	for(int i=1; i<=n+1; i++){
		int ans=0;
		Add(ans, C(n+1, i));
		Add(ans, -C(n+1-r+l-1,i-1));
        cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}


template<unsigned int N> struct IsPrime {
	static const int size=(N>>5) + 1;
	unsigned int is_prime[size];
	constexpr IsPrime() : is_prime() {
		is_prime[0]=0x3;
		for(unsigned int i=2;i<N;i++)
		{
			if((is_prime[i>>5] & (1u<<(i&0x1f))) > 0)  continue;
			for(int j=i+i;j<N;j+=i)
				is_prime[j>>5]|=(1u<<(j&0x1f));
		}
	}
	constexpr bool operator[] (const int p) const
	{
		return (is_prime[p>>5] & (1u<<(p&0x1f))) == 0;
	}
};

template<int N> struct LikelyPrime {
	int sum[N+1];
	constexpr LikelyPrime(const IsPrime<N> pr) : sum() {
		for(int i=3;i<N;i++)
			sum[i+1]=sum[i]+((pr[i] && pr[(i+1)/2])?1:0 );
	}
	constexpr int operator[] (const int p) const
	{
		return sum[p];
	}
};

int main()
{
	constexpr IsPrime<100001> pr;
	constexpr LikelyPrime<100001> s(pr);
	int q=read<int>();
	REP(i,q)
	{
		int l,r;
		cin>>l>>r;
		print(s[r+1]-s[l]);
	}
}


Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	x, y := sc.nextInt(), sc.nextInt()
	a := []int{1, 3, 5, 7, 8, 10, 12}
	b := []int{4, 6, 9, 11}
	c := []int{2}
	ok := false
	if f(x, a) && f(y, a) {
		ok = true
	} else if f(x, b) && f(y, b) {
		ok = true
	} else if f(x, c) && f(y, c) {
		ok = true
	}

	if ok {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}

func f(n int, arr []int) bool {
	for _, v := range arr {
		if n == v {
			return true
		}
	}
	return false
}


Measured memory_bytes: 640
import math

def main():
    K=int(input())
    (A,B)=[int(x) for x in input().strip().split()]
    if A % K == 0:
        print('OK')
    elif math.ceil(A/K)*K <= B:
        print('OK')
    else:
        print('NG')
 
if __name__ == '__main__':
    main()
    

Measured memory_bytes: 9172
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

#define mod 1000000007

using namespace std;

int criba[1000000 + 1];

int main()
{
    int N, i, C;
    long long j, tuples;

    scanf("%d", &N);
    memset(criba, 0, 4 * (N + 1));
    for(i = 1; i <= N; ++i){
        j = i;
        while(j <= N){
            ++criba[j];
            j += i;
        }
    }

    tuples = 0;
    for(C = 1; C < N; ++C)
        tuples += criba[N - C];

    printf("%lld", tuples);

    return 0;
}


Measured memory_bytes: 5580
from collections import *

def factorize(n):
    fct = []
    
    for i in range(2, int(n**0.5)+1):
        c = 0
        
        while n%i==0:
            n //= i
            c += 1
        
        if c>0:
            fct.append((i, c))

    if n!=1:
        fct.append((n, 1))
    
    return fct

N = int(input())
cnt = defaultdict(int)

for i in range(1, N+1):
    fct = factorize(i)
    
    for p, c in fct:
        cnt[p] += c

c2, c4, c14, c24, c74 = 0, 0, 0, 0, 0

for v in cnt.values():
    if v>=2:
        c2 += 1
        
    if v>=4:
        c4 += 1
        
    if v>=14:
        c14 += 1
        
    if v>=24:
        c24 += 1
        
    if v>=74:
        c74 += 1

print(c74+c4*max(0, c4-1)//2*max(0, c2-2)+c24*max(0, c2-1)+c14*max(0, c4-1))

Measured memory_bytes: 65668
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<list>

using namespace std;

int st[10001];

int solve(int ai,int col,int n){
  int tamp=st[ai];
  int tmp=ai;
  st[ai]=col;
  int bi=ai;
  int temp=col;
  int count;

  int at,bt;

  do{
    at=ai;
    bt=bi;
    count=0;
    while(st[ai]==col){
      ai--;
      count++;
      if(ai<0)break;
    }
    while(st[bi]==col){
      bi++;
      count++;
      if(bi>=n) break;
    }
    col=st[ai];
    //cout << "count" << count << endl;
  }while(count>3);

  //  cout << ai << "&" << bi << endl;

  st[tmp]=tamp;

  return at+1 + (n-bt);
}

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

    if(n==0) break; //nªOÌÆ«I¹

    for(int i=0;i<n;i++)//üÍ
      cin >> st[i];

    int temp=st[0];//OñÌ
    int tco=0,tp=0;//tcoª¯¶¾Á½ñAtpªÁ¹éêÉÈé©àµêÈ¢êðêIÉÛ¶
    int j=0;//á¤Æ±
    int tmp[10001][2];//[Á¹éê][Ï¦éF]
    int m=0;//Á¹éêÌ

    //  cout <<"aa" << endl;

    for(int i=0;i<n;i++){
      //    cout << i << "..." << st[i] << endl;
      if(temp==st[i])
	tco++;//¯¶¾Á½çCNg
      else{//áÁ½ç
	if(!j){
	  tp=i;
	  j++;
	}
	else{
	  if(tco>2){
	    //  cout << "koko" << tp << " & " << temp << endl;
	    tmp[m][0]=tp;
	    tmp[m][1]=temp;
	    m++;
	  }
	  j=0;
	  i=tp;
	  tco=0;
	  temp=st[i];
	  i--;
	}
      }	
    }

    int ans=n,atmp;
    //   cout << "   " << endl;
    for(int i=0;i<m;i++){
      //cout << tmp[i][0] << "ÔÚ" << endl;
      //cout << tmp[i][1] << "F" << endl;
 
      atmp=solve(tmp[i][0],tmp[i][1],n);
      if(atmp < ans)
	ans=atmp;
    }
    cout << ans <<endl;
  }

}

Measured memory_bytes: 0
n = gets.to_i
a = gets.split.map(&:to_i)

pred = nil
count = 1

1.upto(n - 1) do |i|
  c = a[i - 1] <=> a[i]

  next if c == 0

  unless pred
    pred = c
    next
  end

  if pred != c
    count += 1
    pred = nil
  end
end

puts count

Measured memory_bytes: 20748
#!/usr/bin/env python
# coding: utf-8

# In[20]:


A = int(input())
B = int(input())
C = int(input())
X = int(input())


# In[22]:


ans = 0
for a in range(min(X//500+1, A+1)):
    for b in range(min((X-500*a)//100+1, B+1)):
        c = (X-500*a-100*b)//50
#         print(a,b,c)
        if c <= C:
            ans += 1
print(ans)


# In[ ]:






Measured memory_bytes: 3060