akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N;
vector<ll>A;

//ok 0 over 1 less -1
int ch(ll fl,bool v=false)
{
	vector<ll>res;
	res.push_back(fl);
	ll r=fl;
	for(int i=0;i<N;i++)
	{
		ll nl=(A[i]-r/2)*2;
		if(nl<0)return i%2?-1:1;
		res.push_back(nl);
		r=nl;
	}
	if(res[0]/2+res[N-1]/2>A[N-1])return 1;
	if(res[0]/2+res[N-1]/2<A[N-1])return -1;

	if(v)
	{
		for(int i=0;i<N;i++)
			cout<<res[i]<<(i==N-1?"\n":" ");
	}
	return 0;
}

int main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		ll p;
		cin>>p;
		A.push_back(p);
	}

	ll l=0;
	ll r=(A[0])*2+2;
	while(r-l>2)
	{
		ll m=(l+r)/2;
		if(m%2)m--;
		int a=ch(m);
		if(a==1)
			r=m;
		else if(a<=0)
			l=m;
	}
	ch(l,true);

	return 0;
}

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

namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long N = long.Parse(str[0]);
            long K = long.Parse(str[1]);
            string[] strA = Console.ReadLine().Split();
            long[] H = new long[N];
            long sum = 0;
            for (long i = 0; i < N; i++)
            {
                H[i] = long.Parse(strA[i]);
            }
            long ans = 0;
            Array.Sort(H);
            Array.Reverse(H);
            for(long i = 0; i < N; i++)
            {
                if(K > 0)
                {
                    K--;
                    continue;
                }
                ans += H[i];
            }
            Console.WriteLine(ans);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 33536
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();

		Deque<String> nameQueue = new ArrayDeque<String>();
		Deque<Integer> timeQueue = new ArrayDeque<Integer>();
		for (int i = 0; i < n; i++) {
			nameQueue.offer(sc.next());
			timeQueue.offer(sc.nextInt());
		}
		int nowTime = 0;

		while (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {
			String p = nameQueue.poll();
			int t = timeQueue.poll();
			if (t - q <= 0) {
				nowTime += t;
				System.out.println(p + " " + String.valueOf(nowTime));
			} else {
				nameQueue.offer(p);
				timeQueue.offer(t - q);
				nowTime += q;
			}
		}

		sc.close();
	}
}

Measured memory_bytes: 74492
S = str(input())
l = len(S)
m = 0
M = 0
for i in range(l):
  if S[i] =="A":
    m = i
    break
for i in range(l-1,-1,-1):
  if S[i] =="Z":
    M =i
    break
print(M-m+1)
  

Measured memory_bytes: 3516
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a[150];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n;
    cin>>n;
    int cnt=0,ans=1,maxx=0;
    for(int i=1;i<=n;i++)
    {
        int temp=i;
        while(temp%2!=1)
        {
            cnt++;
            temp/=2;
           // cout << cnt << endl;
        }
        if(cnt>maxx)
        {
            maxx=cnt;
            ans=i;
        }
        cnt=0;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,a,b;
    cin>>n;
    if(n==1)cout<<"Hello World"<<endl;
    else{
        cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, y;

    cin >> x >> y;

    if(y % 2 == 1)
        return cout << "No", 0;

    bool OK = 0;

    for(int i = 0; i <= x && 2 * i <= y && !OK; ++i)
        if((2 * i) + ((x - i) * 4) == y)
            OK = 1;

    cout << (OK ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;


int main(){
  int n,m;
  cin >>n >>m;
  vector <int> vec(m);
  vector <int> sa(m-1);
  for (int i=0;i<m;i++) cin >> vec.at(i);
  sort (vec.begin(),vec.end());
  
  for (int i=0;i<m-1;i++) sa.at(i)=vec.at(i+1)-vec.at(i);
  //saはm-2まで入ってる。
  sort(sa.begin(),sa.end());
  
  int t=m-n;
  if (t<=0) cout << 0 << endl;
  else{
  int ans=vec.at(m-1)-vec.at(0);
    int mi=0;
  for (int i=1;i<n;i++)  mi+=sa.at(m-1-i);
    cout << ans-mi << endl;
  }
       }
  

Measured memory_bytes: 1024
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            if (sc.nextInt() % 2 == 1) {
                so.println("first");
                return;
            }
        }
        so.println("second");
    }
}


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

using namespace std;

// 蟻本そのまま
int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if(b != 0) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }
    else {
        x = 1; y = 0;
    }
    return d;
}

int main() {
    int a, b;
    cin >> a >> b;

    int x, y;
    extgcd(a, b, x, y);

    cout << x << " " << y << "\n";

    return 0;
}



Measured memory_bytes: 3100
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int m = 0, f = 0, r = 0;

		int sum = 0;
		m = scane.nextInt();
		f = scane.nextInt();
		r = scane.nextInt();


		while ((m + f + r) != -3) {

			sum = m + f;

			if (m == -1 || f == -1){
				System.out.println("F");
			}

			if ((m != -1 && f != -1) &&sum >= 80) {
				System.out.println("A");
			} else if ((m != -1 && f != -1) &&sum < 80 && sum >= 65) {
				System.out.println("B");

			} else if ((m != -1 && f != -1) &&sum < 65 && sum >= 50) {
				System.out.println("C");
			} else if ((m != -1 && f != -1) &&sum < 50 && sum >= 30) {
				if (r >= 50) {
					System.out.println("C");
				}else {
					System.out.println("D");
				}

			}else if (sum <30) {
				System.out.println("F");
			}

			m = scane.nextInt();
			f = scane.nextInt();
			r = scane.nextInt();

		}



	}
}

Measured memory_bytes: 26156
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
using namespace std;

struct Data {
	int  num, pos, len;
};
typedef pair<int, int> P;

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

	int n;
	while(cin >> n, n) {
		map<int, Data> datamap; //[pos]->Data
		map<int, vector<Data> > nummap;  //[num]->vec<idx>
		priority_queue<P, vector<P>, greater<P> > q;
		q.push(P{ 0, int(1e9 + 1) });
		for(int i = 0; i < n; i++) {
			char op;
			cin >> op;
			if(op == 'W') {
				int num, len;
				cin >> num >> len;
				while(len > 0) {
					P p = q.top();
					q.pop();
					Data d{ num, p.first, len };
					if(p.second >= len) {
						if(p.second > len)
							q.push(P(p.first + len, p.second - len));
						len = 0;
					}
					else if(p.second < len) {
						d.len = p.second;
						len -= p.second;
					}
					datamap[d.pos] = d;
					nummap[num].push_back(d);
				}
			}
			else if(op == 'D') {
				int num;
				cin >> num;
				for(const Data& d : nummap[num]) {
					datamap.erase(d.pos);
					q.push(P(d.pos, d.len));
				}
				nummap[num].clear();
			}
			else {// 'R'
				int pos;
				cin >> pos;
				auto it = datamap.upper_bound(pos);
				if(it == datamap.end() && datamap.size() == 0) {
					cout << "-1" << endl;
					continue;
				}
				--it;
				Data d = it->second;
				if(d.pos <= pos && pos < d.pos + d.len) {
					cout << d.num << endl;
				}
				else {
					cout << "-1" << endl;
				}
			}
		}
		cout << endl;
	}
}

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

int main() {
    int fibo[1001], N = 1001;
    fibo[0] = 1;
    fibo[1] = 2;
    for(int i=2;i<N;i++){
        fibo[i] = (fibo[i-1] + fibo[i-2]) % N;
    }
    int v, d;
    while(cin >> v >> d){
        vector<int> ls;
        for(int i=1;i<=v;i++) ls.push_back(fibo[i]);
        sort(ls.begin(), ls.end());
        int cnt = 1;
        for(int i=0;i<v-1;i++){
            if(ls[i+1]-ls[i] >= d) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}



Measured memory_bytes: 3140
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int d=sc.nextInt();
            int x=0;
            for(int i=0;i<600/d;i++){
                x+=i*i*d*d*d;
            }
            System.out.println(x);
        }
    }
}


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

int main() {
  int N;
  string ans = "No";
  cin >> N;
  
  if (1 <= N && N <= 4) ans = "Yes";
  if (5 <= N) {
    if (N%9 == 0 && N/9 < 10) ans = "Yes";
    if (N%8 == 0 && N/8 < 10) ans = "Yes";
    if (N%7 == 0 && N/7 < 10) ans = "Yes";
    if (N%6 == 0 && N/6 < 10) ans = "Yes";
    if (N%5 == 0 && N/5 < 10) ans = "Yes";
  }
  
  cout << ans << endl;;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll memo[1005][1005];
const ll m=1e9+7;
string grid[1005];
int main()
{
    int r,c;
    cin>>r>>c;
    for(int i=0;i<r;i++)
    {
        cin>>grid[i];
    }
    memo[0][1]=1;
    memo[1][0]=0;
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            if(grid[i-1][j-1]=='.')
            {
                memo[i][j]=(memo[i-1][j]%m+memo[i][j-1]%m)%m;
            }
        }
    }
    
    // for(int i=1;i<=r;i++)
    // {
    //     for(int j=1;j<=c;j++)
    //     {
    //         cout<<memo[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    
    printf("%lld\n",memo[r][c]%m);
}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main()
{
	int n;
	while(cin >> n)
	{
		bool* num=new bool[n+1];
		num[0]=num[1]=true; for(int i=2;i<=n;i++) num[i]=false;
		int ans=0;
		for(int i=2;i<n;i++)
		{
			if(num[i]==false)
			{
				for(int j=i*2;j<=n;j+=i) num[j]=true;
			}
		}
		for(int j=2;j<=n;j++) if(num[j]==false) ans++;
		cout << ans << '\n' ;
		delete[] num;
	}
}

Measured memory_bytes: 2244
#include <stdio.h>
int main(void)
{
	int s, a[10000], i, j;
	
	scanf("%d",&s);
	
	a[0]=s;
	for(i=1;i<10000000;i++){
	    if((a[i-1]%2)==0) a[i]=a[i-1]/2;
	    else a[i]=3*a[i-1]+1;
	    for(j=0;j<i;j++){
	        if(a[i]==a[j]){
	            printf("%d\n",i+1);
	            return 0;
	        }
	    }
	}
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) 
{
	char a[10],b[10];
    char c[20];
    int i, d;
    int e=0;
    
    scanf("%s %s", &a,&b);
	sprintf(c,"%s%s\n",a,b);
  
  d = atoi(c);
  
  for (i=0 ; i<=1000 ; i++ ) 
  	{
  	if (i*i==d)  	
  	e=i;
  	}
  	
  	if (e!=0)
  	printf("Yes");
  	else printf("No");
  
	return 0;
	
	
}




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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

vector<vector<int32>> adj;
vector<int32> a;

vector<int32> dp;
vector<int32> ans;

void dfs(int32 v, int32 p = -1){
  int32 idx,pre;
  idx = lower_bound(ALL(dp), a[v]) - dp.begin();
  pre = dp[idx];
  dp[idx] = a[v];
  ans[v] = lower_bound(ALL(dp), INF) - dp.begin();
  for(auto u : adj[v]){
    if(u == p)continue;
    dfs(u,v);
  }
  dp[idx] = pre;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  a.resize(n);
  REP(i,n)cin >> a[i];
  adj.resize(n);
  REP(i,n-1){
    int32 u,v;
    cin >> u >> v;
    u--;v--;
    adj[u].pb(v);
    adj[v].pb(u);
  }
  dp.resize(n+1,INF);
  ans.resize(n);
  dfs(0);
  for(auto x : ans){
    ANS(x);
  }
  return 0;
}

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

using namespace std;

long long f(long long a, long long b, long long x) {
	return floor(a*x/b) - a*floor(x/b);
} 

int main() {
	long long a,b,n;
	cin>>a>>b>>n;
	
	cout<<f(a, b, min(b-1, n))<<endl;
	
	return 0;
}

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

int main()
{
  long long n,sum=0;

  cin >> n;

  for(int i=1; i<=n; i++){
    if(i%3!=0 && i%5!=0){
      sum+=i;
    }
  }

  cout << sum << endl;

  return 0;
}

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

struct combination {
    ll mod;
    vector<ll> fac, finv, inv;

    combination(int n, ll m) : fac(n), finv(n), inv(n) {
        mod = m;
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < n; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }

    ll C(int n, int k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll mod = 1e9 + 7;
    combination com(700000, mod);
    int c = (x + y) / 3;
    int b = abs(x - y);
    int a = c / 2 - b / 2;
    cout << com.C(c, a) << endl;

    return 0;
}

Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    char a; cin >> a;
    if('a' <= a and a <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int x;
	cin >> x;
	if (x >= 30)puts("Yes");
	else puts("No");*/


	/*ll n, d;
	cin >> n >> d;
	int ans = 0;
	ll x, y;
	rep(i, n) {
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= d)ans++;
	}
	cout << ans;*/


	/*int k;
	cin >> k;
	if (k % 2 == 0)puts("-1");
	else {
		int a = 7;
		int ans = 1;
		while (a % k != 0) {
			a = a * 10 + 7;
			a = a % k;
			ans++;
		}
		cout << ans;
	}*/


	int n;
	cin >> n;
	string s;
	cin >> s;
	int wnum = 0;
	rep(i, n) {
		if (s[i] == 'W')wnum++;
	}
	rep(i, n) {
		if (s[i] == 'W' && i > n - 1 - wnum)wnum--;
	}
	cout << wnum;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    string target;
    cin >> target;
    if ((target[2] == target[3]) && (target[4] == target[5])) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
comb = [0] * (N+1)
comb[K-1] = 1
for i in range(K-1, N):
    comb[i+1] = comb[i] * (i+1) * pow(i-K+2, -1, mod) % mod
# print(comb)
A.sort()
mi = sum(a*comb[i]%mod for a, i in zip(reversed(A[:N-K+1]), range(K-1, N)))
ma = sum(a*comb[i]%mod for a, i in zip((A[K-1:]), range(K-1, N)))
# print(mi%mod, ma%mod)
print((ma-mi)%mod)

Measured memory_bytes: 20112
S = list(input())
ans = []
def f(i,tmp,carry):
  s = int(S[i])
  if i == len(S)-1:
    ans.append(tmp+carry+s)
  else:
    #＋にする場合
    f(i+1,tmp+carry+s,0)
    #なにも入れない場合
    f(i+1,tmp,(carry+s)*10)
f(0,0,0)
print(sum(ans))

Measured memory_bytes: 3060
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)
length = len(cnt)
if length == 1:
    key = list(cnt.keys())[0]
    if key == key ^ key:
        print("Yes")
    else:
        print("No")
elif length == 2:
    val = []
    for key in cnt.keys():
        val.append(key)
    if cnt[0] == n // 3 and n % 3 == 0:
        print("Yes")
    else:
        print("No")
elif length == 3:
    val = []
    for key in cnt.keys():
        val.append(key)
    if (val[0] ^ val[1] != val[2]) or (val[1] ^ val[2] != val[0]) or (val[2] ^ val[0] != val[1]):
        print("No")
        exit()
    if n % 3 != 0:
        print("No")
        exit()
    if (cnt[val[0]] != n // 3) or (cnt[val[1]] != n // 3) or (cnt[val[2]] != n // 3):
        print("No")
        exit()
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14468
import java.util.Scanner;
import java.lang.Math;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
Scanner kb=new Scanner(System.in);
double r=kb.nextDouble();
System.out.printf("%f %f\n",r*r*Math.PI,2*Math.PI*r);
	}

}

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

void solver() {
  int n;

  cin >> n;

  int as = 0;
  int dig = 1;
  for (int i = 0; i < n-1; i++) {
    dig *= 10;
  }
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    as += a * dig;
    dig /= 10;
  }

  int bs = 0;
  dig = 1;
  for (int i = 0; i < n-1; i++) {
    dig *= 10;
  }
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    bs += b * dig;
    dig /= 10;
  }

  int aIdx = 0;
  int bIdx = 0;
  int start = 1;
  int end = n;
  for (int i = 2; i <= n; i++) {
    start *= 10;
    start += i;
  }
  for (int i = n-1; i >= 1; i--) {
    end *= 10;
    end += i;
  }

  int idx = 0;
  vector<int> v(n);
  iota(v.begin(), v.end(), 1);
  do {
    int num = 0;
    for (int i = 0; i < v.size(); i++) {
      num *= 10;
      num += v[i];
    }
    idx++;
    if (as == num) {
      aIdx = idx;
    }
    if (bs == num) {
      bIdx = idx;
    }
    if (bIdx != 0 && aIdx != 0) break;
  } while( next_permutation(v.begin(), v.end()) );

  if (bIdx > aIdx) {
    cout << bIdx - aIdx << "\n";
  } else {
    cout << aIdx - bIdx << "\n";
  }
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  int N;
  cin >> N;
  int count = 0;
  vector<int> list = {1, 3, 5, 7, 9, 11, 13};
  for(int i=0; i<7-3; ++i){
    for(int j=i+1; j<7-2; ++j){
      for(int k=j+1; k<7-1; ++k){
        for(int l=k+1; l<7; ++l){
          if(list[i]*list[j]*list[k]*list[l] <= N) ++count;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
typedef long long ll;
ll N,M;

int main(){
    cin>>N>>M;                                                   
    if(N>M)
        swap(N,M);
    if(N==1&M==1)
        cout<<1<<"\n";
    else if(N==1&M>1)
        cout<<M-2<<"\n";
    else
        cout<<(N-2)*(M-2)<<"\n";
    return 0;    
        
     
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

def MI():return map(int,input().split())
def LI():return list(MI())

n,*p=map(int,open(0).read().split())

cnt=0
for a,b,c in zip(p[0:],p[1:],p[2:]):
    if a>b>c or a<b<c:
        cnt+=1
    
print(cnt)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/
int main()
{
    string a;
    cin>>a;
    a[3]='8';
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
vector<vector<ll>> ADJ;
vector<bool> visit;
ll dia=0;
ll dfs(ll u)
{
    visit[u]=true;
   ll mx=0;
   for(auto v:ADJ[u])
   {
       if(!visit[v])
       {
           ll z=dfs(v);
           dia=max({dia,mx+z+1,z+1});
            mx=max(mx,z);
       }
   } 
   return mx+1;
}
int main()
{
   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ADJ.resize(N+1);
    visit.resize(N+1,false);
    FORI(i,0,N-1)
    {
        READV(a);
        READV(b);
        ADJ[a].pb(b);
        ADJ[b].pb(a);
    }
    ll x=dfs(1);
    dia--;
    if (dia%3==1)
    {
        cout<<"Second"<<endl;
    }
    else
    {
        cout<<"First"<<endl;
    }
    
    
    
    

//-----------------------------------------------------------------------------------------------------------//


    
    return 0;
}

Measured memory_bytes: 20224
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!long;
    long r;
    foreach (i; 1..N+1) {
        r += i * (N-i+1);
    }
    foreach (_; 1..N) {
        auto uv = readln.split.to!(long[]);
        auto u = uv[0];
        auto v = uv[1];
        if (u > v) swap(u, v);
        r -= u * (N-v+1);
    }
    writeln(r);
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int a = Integer.parseInt(ss0[0]);
		int b = Integer.parseInt(ss0[1]);

		if ( a == 1) { a = 14; }
		if ( b == 1) { b = 14; }
		
		if (a==b) { System.out.println("Draw"); return; }
		if (a>b) { System.out.println("Alice"); return; }
		if (a<b) { System.out.println("Bob"); return; }


    }
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }

}



Measured memory_bytes: 23124
#include<stdio.h>

int main (void) {

  int N;
  int T[110];
  int M;
  int P[110];
  int X[110];
  scanf("%d",&N);
  int i,sum;
  for(i=0,sum=0;i<N;i++){
    scanf("%d",&T[i]);
    sum += T[i];
  }
  scanf("%d",&M);
  int ans[110];
  for(i=0;i<M;i++){
    scanf("%d %d",&P[i],&X[i]);
    ans[i] = sum - T[P[i]-1] + X[i];
  }

  for(i=0;i<M;i++){
    printf("%d\n",ans[i]);
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int answer = 0;
        if (x == 1) {
            answer += 300000;
        } else if (x == 2) {
            answer += 200000;
        } else if (x == 3) {
            answer += 100000;
        }
        
        if (y == 1) {
            answer += 300000;
        } else if (y == 2) {
            answer += 200000;
        } else if (y == 3) {
            answer += 100000;
        }
        
        if (x == 1 && y == 1) {
            answer += 400000;
        }
        
        System.out.println(answer);
    }
}


Measured memory_bytes: 22612
a,b = map(int,input().split())
l = list(map(int,input().split()))
l.sort()

m = []
for i in range(len(l)-1):
    m.append(l[i+1]-l[i])

m.sort()
ans = 0
for i in range(len(m)-a+1):
    ans += m[i]

print(ans)


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

constexpr int64_t INF = 1e18;
constexpr int D = 365;
constexpr int N = 26;
int c[N];
int s[D][N];
int last[N];
int t[D];

constexpr int64_t CYCLES_PER_SEC = 2800000000;
constexpr double TIMELIMIT = 1.95;
struct Timer {
	int64_t start;
	Timer() { reset(); }
	void reset() { start = getCycle(); }
	void plus(double a) { start -= (a * CYCLES_PER_SEC); }
	inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
	inline int64_t getCycle() {
		uint32_t low, high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((int64_t)low) | ((int64_t)high << 32);
	}
};
mt19937 mt{random_device{}()};
uniform_int_distribution<int> rnd_contest(0, N - 1);
// uniform_int_distribution<int> rnd_day(0, D - 1);
normal_distribution<> rnd_day(0, 1);

void input() {
	int _d; cin >> _d;
	for(int i = 0; i < N; ++i) {
		cin >> c[i];
		last[i] = -1;
	}
	for(int i = 0; i < D; ++i) {
		for(int j = 0; j < N; ++j) {
			cin >> s[i][j];
		}
	}
}

void greedy() {
	for(int i = 0; i < D; ++i) {
		int64_t loss = 0;
		for(int j = 0; j < N; ++j) {
			loss += c[j] * (i - last[j]);
		}
		int64_t maxi = -INF;
		int midx = 0;
		for(int j = 0; j < N; ++j) {
			int64_t los = loss - c[j] * (i - last[j]);
			if(s[i][j] - los > maxi) {
				maxi = s[i][j] - los;
				midx = j;
			}
		}
		last[midx] = i;
		t[i] = midx;
	}
}

int64_t calc() {
	for(int i = 0; i < N; ++i) {
		last[i] = -1;
	}
	int64_t ans = 0;
	for(int i = 0; i < D; ++i) {
		last[t[i]] = i;
		ans += s[i][t[i]];
		for(int j = 0; j < N; ++j) {
			int64_t loss = c[j] * (i - last[j]);
			ans -= loss;
		}
	}
	return ans;
}

void output() {
	for(int i = 0; i < D; ++i) {
		cout << t[i] + 1 << '\n';
	}
}

int main() {
	Timer timer;
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	input();
	greedy();
	int64_t score = calc();
	int cnt = 0, update = 0;
	while(timer.get() < TIMELIMIT) {
		int q = rnd_contest(mt);
		double pro = rnd_day(mt);
		if(pro < 0) continue;
		++cnt;
		int d = max<int>(1, D - pro / 2 * D);
		int pre = t[d];
		t[d] = q;
		int64_t nxt = calc();
		if(nxt > score) {
			score = nxt;
			++update;
		} else {
			t[d] = pre;
		}
	}
	// cerr << score << '\n';
	// cerr << cnt << " " << update << '\n';
	output();
	return 0;
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>  
using namespace std;
int main(){
	int n;
	unsigned long long a=2,b=1,c;
	scanf("%d",&n);
	if(n==1)printf("1\n");
	if(n==0)printf("0\n");
	if(n>=2){
	n--;
	while(n--){
		c=a+b;
		a=b;b=c;
	}
	cout<<c<<endl;
}
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

int main()
{
    int N, M;
    cin >> N >> M;
    int k[M];
    int s[M][N];
    REP(i, M)
    {
        int tk;
        cin >> tk;
        k[i] = tk;
        REP(j, tk)
        {
            int ts;
            cin >> ts;
            s[i][j] = ts;
        }
    }
    int p[M];
    REP(i, M)
    {
        int tp;
        cin >> tp;
        p[i] = tp;
    }

    int ret = 0;
    for (int i = 0; i < 1 << N; i++)
    {
        int cnt = 0;
        for (int m = 0; m < M; m++)
        {
            int sum = 0;
            for (int tk = 0; tk < k[m]; tk++)
            {
                if ((1 & i >> (s[m][tk] - 1)) == 1)
                {
                    sum++;
                }
            }
            if (sum % 2 == p[m])
                cnt++;
        }

        if (cnt == M)
            ret++;
    }

    cout << ret << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}




/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

/*int struct_ascending_compare(const void *p, const void *q) {
    return ((structname*)p)->member - ((strcutname*)q)->member;
}*/


char s[100005];
int locked[100005];


int main(void){
    scanf("%s", s);
    int len = strlen(s);
    locked[0] = 1;
    locked[len-1] = 1;
    for (int i = 1; i < len-1; i++){
        if (s[i-1] == s[i+1]) locked[i] = 1;
    }

    int cnt = 0;
    for (int i = 0; i < len; i++){
        if (locked[i])cnt++;
    }
    if (cnt == len){
        printf("Second\n");
        return 0;
    }
    if (s[0] == s[len-1]){
        if ((len-3) % 2){
            printf("First\n");
        }else{
            printf("Second\n");
        }
    }else{
        if (len % 2){
            printf("First\n");
        }else{
            printf("Second\n");
        }
    }


    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;
    cin >> n;
    int money=10000-n;
    while(money>=1000) money-=1000;
    cout << money << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 110;
const int MAXK = 510;

int n, m, c, b[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> c;
    FOR(i,1,m) cin >> b[i];
    int res = 0;
    FOR(i,1,n) {
        int sum = c;
        FOR(j,1,m) {
            int x;
            cin >> x;
            sum += b[j] * x;
        }
        if (sum > 0) res++;
    }
    cout << res;
    return 0;
}

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

Measured memory_bytes: 256
s = input()
n = len(s)

boundary = []
ans = [0] * n

for i in range(n-1):
    if s[i] == "L" and s[i+1] == "R":
        boundary.append(i)##RとLの境界を記録，ひとまとまりを出す

boundary.append(n-1)
#print(boundary)
l = 0
for r in boundary:
    ## s[l ~~ r]
    middle = 0
    cnt = [0, 0]
    for x in range(l, r+1):
        ##動きを忠実に再現
        cnt[x % 2] += 1
        ##境界点を見つけたら記録
        if x < r and s[x] == "R" and s[x+1] == "L":
            middle = x
            
            
    ans[middle] = cnt[middle % 2]
    ans[middle + 1] = cnt[1 - (middle % 2)]
    l = r+1

print(" ".join(map(str, ans)))
    

Measured memory_bytes: 18928
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>
using namespace std;



int main(){
    string old_name, new_name;
    
    cin >> old_name >> new_name;
    if ( ( new_name.length() - old_name.length() ) != 1) {
        cout << "No" << endl;
        return 0;
    }
    
    for (int i = 0; i < old_name.length(); i++) {
        if (old_name[i] != new_name[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int r=sc.nextInt();
            if(n==0 && r==0)break;
            int[] ans=new int[n];
            for(int i=0;i<n;i++)ans[i]=n-i;
            for(int i=0;i<r;i++){
                int p=sc.nextInt();
                int c=sc.nextInt();
                int[] swap=new int[p-1];
                for(int j=0;j<p-1;j++)swap[j]=ans[j];
                for(int j=0;j<c;j++)ans[j]=ans[p-1+j];
                for(int j=0;j<p-1;j++)ans[c+j]=swap[j];
            }
            System.out.println(ans[0]);
        }
        sc.close();
    }
}


Measured memory_bytes: 36776
#include<stdio.h>
int main(){
	char x[5];
	char result;
	scanf("%s", &x);
	result = x[1];
	switch(result){
		case 'B':
			printf("ARC");
			break;
		case 'R':
			printf("ABC");
			break;
}
	return 0;
}

Measured memory_bytes: 1732
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;

int main()
{
	scanf("%d", &n);
	printf("%d\n", 360/__gcd(n, 360));
	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(b,n*a);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin &x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
	rep(i, 2) {
      int c=0;
		for (pin &x : qab[1-i]) {
			int qc = (2 * x.first + x.second)%3;
          c^=(qc+1);
		}
		if (!c) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
using namespace std;
using LLI = long long int;


int main(int argc, char *argv[])
{
    int N;
    cin >> N;
    vector<int> p(N);
    for (int i=0; i<N; i++) {
        cin >> p[i];
    }

    int s = accumulate(p.cbegin(), p.cend(), 0);
    int m = *max_element(p.cbegin(), p.cend());

    int c = s - m / 2;

    cout << c;

    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    int ary[3] = {};

    ary[0] = n / 1000;
	n=n%1000;
    ary[1] = n / 100;
	n=n%100;
    ary[2] = n / 10;
	n=n%10;
    ary[3] = n;

	// check
    // for (int i = 0; i < 4; i++) {
    //     cout << ary[i] << endl;
    // }

    // 処理 出力
	if (ary[0]==ary[1]||ary[1]==ary[2]||ary[2]==ary[3]){
		cout << "Bad" << endl;
	}else{
		cout << "Good" << endl;
	}



    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

void output(int x1, int y1, int x2, int y2, int x3, int y3) {
  printf("%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3);
}

int const ten_9 = 1e9;

int main() {
  ll S; cin >> S;
  ll X1, X2, X3, Y1, Y2, Y3;
  X1 = ten_9, Y1 = 1;
  X3 = 0, Y3 = 0;
  if (0 <= S && S <= ten_9) {
    X2 = S, Y2 = 0;
  }
  else {
    // (S + X2) / 10^9 = Y2 (ただし (S + X2) % 10^9 == 0)
    X2 = ten_9 - S % ten_9, Y2 = (S + X2) / ten_9;
  }
  assert(abs(X1 * Y2 - X2 * Y1) == S);
  if (Y2 > ten_9) {
    output(0, 0, ten_9, 0, 0, ten_9);
  }
  else {
    output(X1, Y1, X2, Y2, X3, Y3);
  }
}


Measured memory_bytes: 256
import math
flr = int(input())
inp = input().split()
n = len(inp)
m = int(max(inp))
num = 1
l = []
for i in range(m):
	total = 0
	i = 0
	for i in range(n):
		N = int(inp[i])
		i += 1
		col = (N-num)**2
		#print(col)
		total += col
	l.append(total)
	num += 1
print(min(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< ll , ll > mp;
int main()
{
	ll x , y , z;
	cin >> x >> y >> z;
	ll k;
	cin >> k;
	ll a[] = { x , y , z};
	sort(a , a + 3);
	for(int i = 1 ; i <= k ; i++)
		a[2]  *= 2;
	cout << a[0] + a[1] + a[2] << endl;
	return 0;
} 



Measured memory_bytes: 256
S = input()
for op1 in [1, -1]:
    for op2 in [1, -1]:
        for op3 in [1, -1]:
            num = int(S[0]) + op1 * int(S[1]) + op2 * int(S[2]) + op3 * int(S[3])
            if num == 7:
                ans = S[0]
                ans += '+' if op1 == 1 else '-'
                ans += S[1]
                ans += '+' if op2 == 1 else '-'
                ans += S[2]
                ans += '+' if op3 == 1 else '-'
                ans += S[3]
                ans += '=7'
                print(ans)
                exit(0)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Created by Harry on 3/31/20.
 */
//https://atcoder.jp/contests/dp/tasks/dp_a
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] cost = new int[n];
        for(int i=0; i<n; i++){
            cost[i] = scanner.nextInt();
        }
        System.out.println(findMinCost(n, cost));
    }

    public static int findMinCost(int n, int[] cost){
        int prev2 = 0;
        int prev1 = Math.abs(cost[1]-cost[0]);
        for(int i=2; i<n; i++){
            int cur = Math.min(prev1+Math.abs(cost[i-1]-cost[i]), prev2+Math.abs(cost[i-2]-cost[i]));
            prev2 = prev1;
            prev1 = cur;
        }
        return prev1;
    }
}

Measured memory_bytes: 50772