akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k;
const int N = 100001;
struct Fenwick{
  vector<int> tree;
  Fenwick(){}
  Fenwick(int n){
    tree.resize(n + 100005);
  }
  int get(int in){
    in += 100000;
    in++;
    int res = 0;
    while(in){
      res += tree[in];
      in -= in & -in;
    }
    return res;
  }
  void add(int in, int v){
//    cout << in << ' ' << v << endl;
    in += 100000;
    in++;
    while(in < tree.size()){
      tree[in] += v;
      in += in & -in;
    }
  }

};
int a[N];
ll count_ge(int x){
  ll res = 0;
  int b[n + 1];
  b[0] = 0;
  for(int i = 0;i < n;i++){
    b[i + 1] = (a[i] >= x ? 1 : -1);
//    cout << b[i + 1] << endl;
  }
  for(int i = 1;i <= n;i++)
    b[i] += b[i - 1];
  Fenwick bt(n);
  bt.add(0, 1);
  for(int i = 1;i <= n;i++){
    res += bt.get(b[i]);
//    cout << bt.get(b[i]) << ' ' << b[i] << endl;
    bt.add(b[i], 1);
  }
  return res;
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n;
  for(int i = 0;i < n;i++)
    cin >> a[i];
  int lo = 0, hi = 1000000000;
//  cout << count_ge(30) << endl;
//  return 0;
  //largest number x such that c >= x, c >= (n) * (n + 1) / 4 + 1;
  while(lo < hi){
    int mid = (lo + hi + 1) / 2;
    if(count_ge(mid) >= (1LL * n * (n + 1) / 2 + 1) / 2){
      lo = mid;
    }else{
      hi = mid - 1;
    }
  }
  cout << lo;
  return 0;
}


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

 #define int long long
 using namespace std;

int a[100][100][100];

int n,m;
int yoko(int kai,int r){
	
	for(int i=0;i<r;i++){
		for(int j=0;j<m;j++)	{
			a[kai][2*r-1-i][j]+=a[kai][i][j];
			a[kai][i][j]=0;
		}
	}
	for(int i=r;i<2*n;i++)for(int j=0;j<m;j++){
		a[kai+1][i-r][j]=a[kai][i][j];
	}
	
}
int tate(int kai,int r){
	
	for(int j=0;j<r;j++){
		for(int i=0;i<n;i++)	{
			a[kai][i][2*r-j-1]+=a[kai][i][j];
			a[kai][i][j]=0;
		}
	}
	for(int j=r;j<2*m;j++)for(int i=0;i<n;i++){
		a[kai+1][i][j-r]=a[kai][i][j];
	}
	
}


void solve(){
int t,p;
	cin>>n>>m>>t>>p;
if(n==0) exit(0);
	
	for(int i=0;i<100;i++)for(int j=0;j<100;j++)for(int k=0;k<100;k++)a[i][j][k]=0;
	
	int ans=0;
	
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[0][i][j]=1;
	
	for(int i=0;i<t;i++){
		int y,yy;
		cin>>y>>yy;
		if(y==1){
			yoko(i,yy);
		}
		else tate(i,yy);
	}
	
	for(int i=0;i<p;i++){
		int y,yy;
		cin>>y>>yy;
		cout<<a[t][y][yy]<<endl;
	}

}

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

 
    	
    	for(int i=0;;i++){
    		solve();
    	
    	}
    	return 0;
    	
            }


Measured memory_bytes: 11036
#include <stdio.h>
int arraySum(int a[],int n);
int main(void){
    int n;
    scanf("%d",&n);
    int t[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&t[i]);
    }
    int m;
    scanf("%d",&m);
    int p[m],x[m];
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&p[i],&x[i]);
    }
    
    int sum = arraySum(t,n);
    for(int i=0;i<m;i++)
    {
        int tmp = p[i]-1;
        printf("%d\n",sum + x[i] - t[tmp]);
    }
    return 0;
}

int arraySum(int a[],int n){
    int sum = 0;
    for(int i=0;i<n;i++)
    {
        sum += a[i];
    }
    return sum;
}

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

using namespace std;

typedef long long ll;

ll lcm(ll a, ll b)
{
	return (a / __gcd(a, b)) * b;
}

int main()
{
	int n;	cin >> n;
	vector <int> v(n);
	vector <int> occ(2e6);
	for (int &x : v)
		cin >> x, occ[x]++;
	
	sort(v.begin(), v.end());
	// for (int x : v)
	// 	cout << x << " ";
	// cout << "\n";
	if (occ[1] > 1)
	{
		cout << 0 << "\n";
		return 0;
	}
	if (occ[1] == 1)
	{
		cout << 1 << "\n";
		return 0;
	}
	
	int cont = 0;
	for (int k = 0; k < n; k++)
	{
		if (occ[v[k]] > 1)
			continue;
		
		int sw = 1;
		for (int i = 2; i * i <= v[k]; i++)
		{
			if (v[k] % i == 0)
			{
				if (occ[i] > 0)
				{
					sw = false; 
					break;
				}
				int r = v[k] / i;
				if (r <= v[k] && v[k] % r == 0 && occ[r] > 0)
				{
					sw = false;
					break;
				}
			}
		}
		// if (sw)
		// 	cout << v[k] << "\n";
		cont += (sw == 1);
	}
	cout << cont << "\n";


}


// 10
// 33 18 45 28 8 19 89 86 2 4


// 2 4 8 18 19 28 33 45 86 89 
// 2  19 33 45 89

Measured memory_bytes: 11968
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll ans = 0;
    rep(ri, 2) {
        ll sum = 0;
        if (ri) {
            if (!(n&1)) {
                rep(i, n / 2) {
                    if (i == n / 2 - 1) {
                        sum += a[i];
                    }
                    else {
                        sum += a[i] * 2;
                    }
                }
                rep(i, n / 2) {
                    if (i == 0) {
                        sum -= a[i+n/2];
                    }
                    else {
                        sum -= a[i+n/2] * 2;
                    }
                }
            }
            else {
                rep(i, n / 2 + 1) {
                    if (i == n / 2 || i == n / 2 - 1) {
                        sum += a[i];
                    }
                    else {
                        sum += a[i] * 2;
                    }
                }
                rep(i, n / 2) {
                    sum -= a[i+n/2+1] * 2;
                }
                //cout << sum << endl;
            }
        }
        else {
            if (!(n&1)) {
                rep(i, n / 2) {
                    if (i == n / 2 - 1) {
                        sum += a[i];
                    }
                    else {
                        sum += a[i] * 2;
                    }
                }
                rep(i, n / 2) {
                    if (i == 0) {
                        sum -= a[i+n/2];
                    }
                    else {
                        sum -= a[i+n/2] * 2;
                    }
                }
            }
            else {
                rep(i, n / 2) {
                    sum += a[i] * 2;
                }
                rep(i, n / 2 + 1) {
                    if (i == 0 || i == 1) {
                        sum -= a[i+n/2];
                    }
                    else {
                        sum -= a[i+n/2] * 2;
                    }
                }
                //cout << sum << endl;
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  for (int &a : x)
    cin >> a;

  sort(x.begin(), x.end());

  int total = 0, sq_total = 0;
  for (int &a : x)
  {
    total += a;
    sq_total += a * a;
  }

  int hp = n * x.at(0) * x.at(0) + sq_total - 2 * x.at(0) * total;
  int min = hp;
  for (int p = x.at(0); p < x.at(n - 1); p++)
  {
    hp = n * p * p + sq_total - 2 * p * total;
    if (hp < min)
      min = hp;
  }
  cout << min << endl;
}

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

int data[111111];
int seq[222222];

int max(int a,int b);

int main(void)
{
  int n,k,t,i,p,ret=0;

  while(1){

    scanf("%d %d",&n,&k);
    if(!n && !k)break;

    memset(data,0,sizeof(data));
    memset(seq,0,sizeof(seq));

    for(i = 0; i < k; i++){
      scanf("%d",&t);
      data[t]++;
    }

    p = 0;
    for(i = 1; i <= n; i++){
      if(data[i]){
	seq[p]++;
      } else {
	p+=2;
      }
    }
    p++;

    if(data[0]){
      for(i=0;i<p;i++){
	ret=max(ret,seq[i]+seq[i+2]+1);
      }
    } else {
      for(i=0;i<p;i++){
	ret=max(ret,seq[i]);
      }
    }

    printf("%d\n",ret);
    }

  return 0;
}

int max(int a,int b)
{
  if(a > b){
    return a;
  }
  return b;
}

Measured memory_bytes: 1908
def main():
  import sys
  input=sys.stdin.buffer.readline
  h,w=map(int,input().split())
  b,q=b'.'*w,range(w)
  for i in range(h):
    s=input()
    a=[]
    a_add=a.append
    for x,y,z,c in zip(b,b'.'+s,s,q):
      if x==46>z:c+=1
      if y==46>z:i+=1
      if i>c:i=c
      a_add(i)
    b,q=s,a
  print(i)
main()

Measured memory_bytes: 3064
#include<stdio.h>

#define MAX 300
#define MIN 1

int main()
{
	int i, j, H, W;
	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
			break;
		else if (MIN <= H, W&&H, W <= MAX)
		{
			for (i = 1; i <= H; i++){
				for (j = 1; j <= W; j++){
					putchar('#');
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto& i: a) {
        cin >> i;
    }
    sort(rall(a));
    ll ans = a[0];
    int cnt = 2, j = 1;
    for (int i = 2; i < n; ++i) {
        if (!cnt) {
            cnt = 2;
            ++j;
        }
        ans += a[j];
        --cnt;
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 3992
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    
    string s;
    cin>>s;
    ll sum=0,i;
    for(i=0;i<s.length();i++) sum += s[i]-'0';
    if(sum%9) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 1; i < n+1; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  int m,d;
  cin >> m>>d;
  int cnt=0;
  rep(i,m){
    rep(j,d){
      if(j%10>=2 && j/10 >=2 && (j%10)*(j/10) == i)cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
x_min=min(x)
x_max=max(x)
x_len=len(x)
ans=n*(100**2)
for i in range(x_min,x_max+1):
    buf=0
    for j in range(x_len):
        buf+=(x[j]-i)**2
    if buf<ans:
        ans=buf
print(ans)

Measured memory_bytes: 3064
n,m,q=map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
    a[i]-=1
    b[i]-=1
def score(A):
    tmp=0
    for ai,bi,ci,di in zip(a,b,c,d):
        if A[bi]-A[ai] == ci:
            tmp+=di
    return tmp


def dfs(A):
    if len(A) == n:
        return score(A)
    res=0
    last=A[-1] if len(A)>0 else 0
    for v in range(last,m):
        A.append(v)
        res=max(res,dfs(A))
        A.pop()
    return res

print(dfs([]))


Measured memory_bytes: 9216
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(C>=A && C<=B){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23380
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector> 
#include<cstdlib>
#include<algorithm>
#define N 10^9+5
using namespace std;
int main()
{
	long long a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	a=abs(a);
	long long t1=a/c,t2=a%c;
	long long  p=abs(t2-c);
	if(t1>b) printf("%lld",a-b*c);
	else
	{
		b=b-t1;
		if(b%2==0) printf("%lld",t2);
		else printf("%lld",p); 
	}
	return 0;
}

Measured memory_bytes: 3208
#include<iostream>
using namespace std;
inline int abs(int x){
	return max(x,-x);
}
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;++i)
		cin>>a[i];
	int maxv=0;
	for(int i=0;i<n;++i)
		maxv=max(maxv,a[i]);
	int mint=0x7fffffff;
	for(int x=1;x<=maxv;++x){
		int sum=0;
		for(int i=0;i<n;++i)
			sum=sum+abs(a[i]-x)*abs(a[i]-x);
		mint=min(mint,sum);
	}
	cout<<mint<<endl;
	return 0;
}

Measured memory_bytes: 256
int main()
{
	int N;
	scanf("%d", & N);
	int N_ = N;
	char S[100000];
	for (int i = 0; i <= N-1; i++) {
		scanf("%s", &S[i]);
	}
	for (int j = 0; j <= N-2; j++) {
		if (S[j] == S[j + 1]) {
			N_ = N_ - 1;
		}
	}
	printf("%d", N_);
}

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

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long a[N];

    for(int i = 0; i < N; i ++){
        scanf("%lld", &a[i]);
    }

    mergeSort(a, 0, N);

    long long A = 0, B = 0;

    if(N % 2 == 0){
        for(int i = N-1; i >= 0; i -= 2){
            A += a[i];
            B += a[i-1];
        }
        printf("%lld\n", A - B);
    }else{
        for(int i = N-1; i >= 1; i -= 2){
            A += a[i];
            B += a[i-1];
        }
        A += a[0];
        printf("%lld\n", A - B);
    }

    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int max=0;
    int cnt=0;
    for(int i=0;i<s.length();i++){
        if('A'==s[i]||'C'==s[i]||'G'==s[i]||'T'==s[i]){
            cnt++;
        }
        if(!('A'==s[i]||'C'==s[i]||'G'==s[i]||'T'==s[i])||i==s.length()-1){
            if(max<cnt){
                max=cnt;
                cnt=0;
            }
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
// #include <immintrin.h>
// #include <emmintrin.h>

#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define vi vector<int>
#define vpii vector<pii>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define aal(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=2e6+5,MOD=1004535809;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)res=res*a%_MOD;
  }
  return res;
}
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
  return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
  return min(a, Smin(args...));
}
template <typename T>
#define errorl(args...) {  \
  string _s = #args;   \
  replace(_s.begin(), _s.end(), ',', ' ');  \
  stringstream _ss(_s);  \
  istream_iterator<string> _it(_ss);  \
  errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}
#define error(args...) {  \
  string _s = #args;  \
  replace(_s.begin(), _s.end(), ',', ' ');  \
  stringstream _ss(_s);  \
  istream_iterator<string> _it(_ss);  \
  err(_it, args);  \
  cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}

void Solve(){
  int x;
  cin>>x;
  int k=360/__gcd(360,x);
  cout<<k<<endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}


Measured memory_bytes: 3652
from collections import deque

N = int(input())
d_list = [[] for _ in range(N+1)]
for _ in range(N-1):
  a, b, c = map(int, input().split())
  d_list[a].append((b, a, c))
  d_list[b].append((a, b, c))
que = deque([])
for v in d_list[1]:
  que.append(v)
ans = [-1] * (N+1)
ans[1] = 0
while len(que) > 0:
  v = que.popleft()
  ans[v[0]] = (ans[v[1]]+v[2])%2
  for n in d_list[v[0]]:
    if ans[n[0]] == -1:
      que.append(n)
for a in ans[1:]:
  print(a)

Measured memory_bytes: 41496
import collections

k = int(input())
Q = collections.deque([int(i) for i in range(1, 10)])
chk = False
for i in range(k):
    x = Q.popleft()
    if i + len(Q) > k:
        chk = True
    if chk:
        continue
    else:
        if x%10:
            Q.append(10*x + x%10 - 1)
        Q.append(10*x + x%10)
        if x%10 != 9:
            Q.append(10*x + x%10 + 1)
print(x)


Measured memory_bytes: 11912
#include "iostream"
#include "vector"

int main(void) {
	long int h;
	int n;
	std::cin >> h;
	std::cin >> n;
	std::vector<int> a(n);
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	long int sum = 0;
	for (int i = 0; i < n; ++i)
		sum += a[i];

	if (sum >= h)
		std::cout << "Yes";
	else
		std::cout << "No";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 1000000007
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

ll mult(ll a, ll b)
{
	a%=MOD; b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}

ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

ll inverse(ll a)
{
	return pw(a,MOD-2);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll a[n];
	ll cnt[60]; mset(cnt,0);
	
	forn(i,0,n) cin>>a[i];
	
	forn(i,0,n){
		forn(j,0,60){
			if(a[i]&(1LL<<j)) cnt[j]++;
		}
	}
	
	ll ans=0;
	forn(i,0,60){
		ans+=mult(mult(cnt[i],n-cnt[i]),1LL<<i);
		ans%=MOD;
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 2560
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, k; cin >> n >> k;

	vector<LL> x(n);
	vector<LL> y(n);

	vector<LL> xb(n);
	vector<LL> yb(n);


	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];

		xb[i] = x[i];
		yb[i] = y[i];
	}

	sort(xb.begin(), xb.end());
	sort(yb.begin(), yb.end());

	LL ans = (xb[n-1]-xb[0])*(yb[n - 1] - yb[0]);

	for (int x1 = 0; x1 < n; x1++) {
		for (int x2 = x1+1; x2 < n; x2++) {

			for (int y1 = 0; y1 < n; y1++) {
				for (int y2 = y1+1; y2 < n; y2++) {

					LL xl = xb[x1];
					LL xr = xb[x2];

					LL ys = yb[y1];
					LL yu = yb[y2];

					LL cnt = 0;

					for (int i = 0; i < n; i++) {
						if (xl <= x[i] && x[i] <= xr) {
							if (yu >= y[i] && y[i] >= ys) {
								cnt++;
							}
						}
					}

					if (cnt >= k) {
						LL area = (LL)(xr - xl)*(LL)(yu - ys);

						ans = min(ans, area);
					}
				}

			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

func main() {
	ans := []string{}

	for {
		var x, y int

		fmt.Scanf("%d %d", &x, &y)
		if x == 0 && y == 0 {
			break
		}
		if x < y {
			ans = append(ans, strconv.Itoa(x) + " " + strconv.Itoa(y))
		} else {
			ans = append(ans, strconv.Itoa(y) + " " + strconv.Itoa(x))
		}
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}



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

int main() {

	long int n;
	cin >> n;
	int* a = new int[n];
	long int min, max, sum;
	min = 1000000;
	max = -1000000;
	sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (min > a[i])
			min = a[i];
		if (max < a[i])
			max = a[i];
	
		sum = sum + a[i];
	}
	cout << min << " " << max << " " << sum << "\n";
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  rep(i, N) cin >> X.at(i) >> Y.at(i);
  double sum=0;
  rep(i, N){
    rep(j, N){
      sum=sum+sqrt((X.at(i)-X.at(j))*(X.at(i)-X.at(j))+(Y.at(i)-Y.at(j))*(Y.at(i)-Y.at(j)));
    }
  }
  cout << setprecision(10) << sum/N << endl;
}

Measured memory_bytes: 256
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.trim();
    var N = input;
    if (N == 'ABC') {
        console.log('ARC');
        
    } else {
        console.log('ABC');
        
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7  ;

int a[MAXN] ;

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
    int n ;
    cin >> n ;
    n *= 2;
    for(int i = 0 ; i < n ; i ++ )
        cin >> a[i] ;
    int ans = 0 ;
    sort(a,a+n);
    for(int i = 0 ; i < n ; i += 2 )
        ans += a[i] ;
    cout<<ans;


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

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

  if(a>x){
    cout << "NO" << endl;
    return 0;
  }else{
    if( a+b < x){
      cout << "NO" << endl;
      return 0;
    }else{
      cout << "YES" << endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for (size_t i = 0; i < n; i++)
    {
        if (s[i] != 'x')  s[i] = 'x'; 
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    //感想
    //何回もコレクション内を巡回しすぎ。。。
    val first = a.max
    val second = if (a.count(_ != first) == 0) first else a.filter(_ != first).max
    val multiMaxFlg = a.count(_ == first) > 1
    val pw = new java.io.PrintWriter(System.out)
    for (i <- 0 until n) {
      if (a(i) == first) {
        if (multiMaxFlg) {
          pw.println(first)
        } else {
          pw.println(second)
        }
      } else {
        pw.println(first)
      }
    }
    pw.flush()
  }
}


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

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c == 'E') {
      b = s[0];
      s[0] = s[3];
      s[3] = s[5];
      s[5] = s[2];
      s[2] = b;
    }
    if(c == 'W'){
      b = s[0];
      s[0] = s[2];
      s[2] = s[5];
      s[5] = s[3];
      s[3] = b;
    }

    if(c == 'N'){
      b = s[0];
      s[0] = s[1];
      s[1] = s[5];
      s[5] = s[4];
      s[4] = b;
    }
    if(c == 'S'){
      b = s[0];
      s[0] = s[4];
      s[4] = s[5];
      s[5] = s[1];
      s[1] = b;
    }
  }
  int top() {return s[0];}

};

#define N 5
char dir[] = {'N','E','S','W'};
int dy[]={-1,0,1,0}; // N,E,S,W
int dx[]={0,1,0,-1};

int mp[N][N];
int used[N][N];
Dice dice;

int ans = 1;

bool check(){
  int cnt[7]={};
  for(int i=0;i<6;i++) cnt[dice.s[i]]++;
  for(int i=1;i<=6;i++) if(cnt[i] !=1) return 0;

  int res = 1;
  res &= dice.s[0]+dice.s[5] == 7;
  res &= dice.s[1]+dice.s[4] == 7;
  res &= dice.s[2]+dice.s[3] == 7;
  return res;
}


void dfs(int y,int x,int py,int px){
  
  if(used[y][x]++ || dice.s[5] != 0) ans = 0;
  if(ans == 0) return;
  dice.s[5] = mp[y][x];
  
  for(int i=0;i<4;i++){
    int nx = x+dx[i],ny = y+dy[i];
    if(nx<0||ny<0 ||nx>=N ||ny>=N || mp[ny][nx] == 0)continue;
    if(nx == px && ny == py) continue;
    dice.roll(dir[i]);
    dfs(ny,nx,y,x);
    dice.roll(dir[(i+2)%4]);
  }
}


signed main(){

  int q;
  cin>>q;
  while(q--){

    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) cin>>mp[i][j];

    ans = 1;
    memset(used,0,sizeof(used));
    for(int i=0;i<6;i++) dice.s[i] = 0;
    
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
	if(mp[i][j] > 0) dfs(i,j,-1,-1),i = N,j = N;

    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) if(mp[i][j]!=0 && used[i][j] == 0) ans = 0;
	  

    ans &= check();
    cout<<(ans? "true":"false")<<endl;
    
    
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll mini = LONG_LONG_MAX;
    cin >> N;
    for(ll i = 1;i * i <= N;i++) {
        ll another = N / i;
        if(i * another != N) continue;
        mini = min(mini, i - 1 + another - 1);
    }
    if(mini == LONG_LONG_MAX) cout << -1 << endl;
    else cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[int(i) for i in input().split()]
if len(set(l))==1:
    print(0)
    exit()
m=max(l)
ans=0 
denomaxi=0 
for  i in l: 
    if i*(m-i)>denomaxi:
        ans=i 
        denomaxi=i*(m-i)
print(m,ans)

Measured memory_bytes: 15564
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a*b + " " + 2 * (a+b));
    sc.close();
  }
}



Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N, L;
  cin >> N >> L;

  int taste = 0;
  int eat_apple = L;
  
  for (int i=0; i<N; i++)
    taste += L+i;
  
  for (int i=0; i<N; i++){
    if( abs(eat_apple) > abs(L+i) ){
      eat_apple = L+i;
    }
    
  }

  cout << taste - eat_apple << endl;
  
}

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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int t[2400];

int toMin(int time){
	return time / 100 * 60 + time % 100;
}

int main(void){
	int n,p,q;

	while(cin>>n>>p>>q && (n||p||q)){
		p = toMin(p);
		q = toMin(q);
		memset(t,0,sizeof(t));

		rep(i,n){
			int m; cin>>m;
			int before = p;

			rep(j,m){
				int ts,te; cin>>ts>>te;
				ts = toMin(ts);
				te = toMin(te);
				if(before <= ts){
					REP(k,before,ts) t[k] = 1;
					before = te;
				}
			}
			if(before <= q){
				REP(j,before,q) t[j] = 1;
			}
		}

		int ans = 0;
		int count = 0;
		REP(i,p,q+1){
			if(t[i]){
				count++;
			}
			else{
				ans = max(ans,count);
				count = 0;
			}
		}
		ans = max(ans,count);
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
import itertools

number = []
for i in range(6):
    number.append(int(input()))

flag = 0

for i,j in itertools.combinations(number[0:5],2):
    if abs(i-j) > number[5]:
        flag = 1
        break

if flag == 0:
    print("Yay!")
else:
    print(":(")

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

int main(){
	int n = 0;
    vector<long long> sequence;
    cin >> n;
    long long res = 0;
    for(int i = 0; i < n; i++){
        long long x = 0;
        cin >> x;
        while(x % 2 == 0){
            x /= 2;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    mod = 998244353
    n, s = map(int, input().split())
    a = list(map(int, input().split()))

    dp = [0] * (s + 1)

    for i, x in enumerate(a):
        if x >= s:
            if x == s:
                dp[s] += (i + 1) * (n - i)
                dp[s] %= mod
            continue

        dp[s] += dp[s-x] * (n - i)
        dp[s] %= mod

        for j in range(s-x-1, 0, -1):
            dp[j+x] += dp[j]
            dp[j+x] %= mod

        dp[x] += i + 1
        dp[x] %= mod

    print(dp[s])

main()

Measured memory_bytes: 69196
N=int(input())
List=list(map(int,input().split()))
nList=[e for e in List if e % 2 == 0]
tmp = []
while nList:
  f = nList.pop()
  if f % 3 != 0 and f % 5 != 0:
    tmp.append(f)
if not tmp:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

struct edge{
  ll to, cost;
};

int main()
{
  ll N;
  cin >> N;
  vector<vector<ll>> A(N-1,vector<ll>(3));
  vector<vector<edge>> vec(N,vector<edge> ());
  REP(i, N-1){
    REP(j, 3){
      cin >> A.at(i).at(j);
    }
    A.at(i).at(0)--;
    A.at(i).at(1)--;
    edge e1 = {A.at(i).at(1),A.at(i).at(2)};
    edge e2 = {A.at(i).at(0),A.at(i).at(2)};
    vec.at(A.at(i).at(0)).push_back(e1);
    vec.at(A.at(i).at(1)).push_back(e2);
  }
  
  ll Q,K;
  cin >> Q >> K;
  K--;

  queue<ll> que;
  vector<ll> dist(N,-1);
  que.push(K);
  dist[K]=0;
  while(!que.empty()){
    ll v = que.front();
    que.pop();
    for(auto e:vec.at(v)){
      ll nv = e.to;
      ll ncost = e.cost;
      if(dist[nv]!=-1) continue;

      dist[nv]=dist[v]+ncost;
      que.push(nv);
    }
  }

  vector<ll> ans(Q);
  REP(i,Q){
    ll x,y;
    cin >> x >> y;
    x--;
    y--;
    ans.at(i)=dist[x]+dist[y];
  }

  REP(i,Q){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 18180
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(' ').map { it.toInt() }
    var k = 1
    val used = mutableSetOf<Int>()

    while (true) {
        val ak = a * k
        val rem = ak % b
        if (rem == c) {
            println("YES")
            return
        }
        if (used.contains(rem)) {
            break
        } else {
            used.add(rem)
        }
        k++
    }
    println("NO")
}

Measured memory_bytes: 36448
using System;

namespace AtCoder_Kaijou
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] av = Console.ReadLine().Split(' ');
            string[] bw = Console.ReadLine().Split(' ');
            int t = int.Parse(Console.ReadLine());

            long a = int.Parse(av[0]);
            long v = int.Parse(av[1]);
            long b = int.Parse(bw[0]);
            long w = int.Parse(bw[1]);
            long AT = a;
            long BT = b;

            //T秒後のAの位置 AT
            if (a < b)
            {
                AT = a + v * t;
                BT = b + w * t;

                if (AT >= BT)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                AT = a - v * t;
                BT = b - w * t;

                if (AT <= BT)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }

            }

        }
    }


Measured memory_bytes: 27460
#include <iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
	cin >> H >> W;
	if(H==0 && W==0) return 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(i>0 && i<H-1 && j>0 && j<W-1) cout << ".";
			else cout << "#";
		}
		cout << endl;
	}
	cout << endl;
	}
}

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

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

    int ans = 0;
    
    if ( a < b ) {
        for ( int i = 0; i < b; ++i){
            ans = 10 * ans + a;
        }
    } else {
        for ( int i = 0; i < a; ++i){
            ans = 10 * ans + b;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
  cin >> s;
  int min,i,temp,k;
  min=753;
  
  for(i=0;i<s.size()-2;++i)
  {
  temp=int(s.at(i)-'0')*100+int(s.at(i+1)-'0')*10+int(s.at(i+2)-'0');
  if(temp<753) k=753-temp;
  else k=temp-753;
  if(k<min) min=k;
  }

   cout << min;
  
return 0;}

Measured memory_bytes: 3624
H, W, K = map(int, input().split())
X = []
for i in range(H):
  x = list(input())
  X.append(x)
 
def HandV():
  ans = 0
  for h in range(2**H): 
    for w in range(2**W):
      cnt=0
      for i in range(H):
        for j in range(W):
          if (h>>i)&1==0 and (w>>j)&1==0:
            if X[i][j]=='#':
              cnt+=1
      if cnt==K:
        ans+=1
  print(ans)
HandV()

Measured memory_bytes: 9176
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
long long a, b, c, d;
inline long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x%y); }
int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
		if (a < b || d < b)
		{
			puts("No");
			continue;
		}
		if (c + 1 >= b)
		{
			puts("Yes");
			continue;
		}
		long long g = gcd(b, d);
		long long x = a - b;
		long long y = a - c - 1;
		if (x / g - y / g >= 0)	puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n,m;
    cin>>n>>m;
    ll k=m/n;
    ll ans=1;
    for(ll i=1;i<=min(k,(ll)sqrt(m));i++){
        if(m%i==0){
            if(m/i<=k){
                ans=max(ans,m/i);
            }else{
                ans=max(ans,i);
            }
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans[10050] = {0};
    for (int x = 1; x < 105; x++) {
        for (int y = 1; y < 105; y++) {
            for (int z = 1; z < 105; z++) {
                int value = x * x + y * y + z * z + x * y + y * z + z * x;
                if (value < 10050) {
                    ++ans[value];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i + 1] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3640
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)   for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    string s;
    cin >> s;
    int n =s.length();
    rep(i,0,n-1){ 
    	if(s[i]=='?') s[i]='D';
    }
    cout<<s<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 3784
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic={}
for i in range(len(a)):
    dic.setdefault(a[i],0)
    dic[a[i]]+=1
answer=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    dic.setdefault(b,0)
    dic.setdefault(c,0)
    dic[c]+=dic[b]
    answer=answer+dic[b]*c-dic[b]*b
    dic[b] = 0
    print(answer)

Measured memory_bytes: 23776
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int N, Q;
	string S;
	
	cin >> N >> Q;
	cin >> S;

	vector<int> l(Q), r(Q);
	for (int i = 0; i < Q; i++)
	{
		cin >> l[i] >> r[i];
	}


	vector<int> sum(N + 1, 0);
	
	//ACが出る可能性があるのは2文字目から(0-indexedで1から)
	for (int i = 0; i < N - 1; i++)
	{
		sum[i + 1] = sum[i];
		if (S[i] == 'A' && S[i + 1] == 'C') {
			sum[i + 1]++;
		}
	}
	for (int i = 0; i < Q; i++)
	{
      int ans=sum[r[i]-1]-sum[l[i]-1];
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;

int main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    if((a+b)%2==0){
      printf("%lld\n",(a+b)/2);
    }
    else{
        printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int D;
	std::cin >> D;

	switch ( D )
	{
	case 25:
		std::cout << "Christmas" << std::endl;
		break;

	case 24:
		std::cout << "Christmas Eve" << std::endl;
		break;

	case 23:
		std::cout << "Christmas Eve Eve" << std::endl;
		break;

	case 22:
		std::cout << "Christmas Eve Eve Eve" << std::endl;
		break;
	default:
		break;
	}

	return ( 0 );
}


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

int main(){
    lint n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2){
        cout << "No";
        return 0;
    }
    for(int i=0; i<n/2; i++){
        if(s[i] != s[i+n/2]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

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

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
P = raw_input().split()

ans = P[0]
for i in range(1, N):
    if ans + P[i] == 'TF':
        ans = 'F'
    else:
        ans = 'T'

print ans


Measured memory_bytes: 8804
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	string s; cin >> s;
	if (s[0] == 'A') {
		int count = 0;
		int count2 = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'C') {
				count++;
			}
			if(s[i]<=90){
				count2++;

			}
		}
		if (count == 1 && count2 == 2) {
			int a = s.find('C');
			if (a >= 2 && s.size() - 2 >= a) {
				cout << "AC" << endl;
			}
			else {
				cout << "WA" << endl;
			}
		}
		else {
			cout << "WA" << endl;
		}
	}
	else {
		cout << "WA" << endl;
	}

}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

// const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let x: u64 = read().unwrap();
    let y: u64 = read().unwrap();

    let mut ans = 0;

    let mut tmp = x;
    while tmp <= y {
        tmp *= 2;
        ans += 1;
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
#define mo 1000000007
int c[maxn],f[maxn],Pow[maxn];
int main(){
	int n,ans=0;scanf("%d",&n);
	Pow[0]=1;for(int i=0;i<n;i++)scanf("%d",c+i),Pow[i+1]=Pow[i]*2%mo,f[i+1]=(f[i]*4ll+2ll*Pow[i]*Pow[i])%mo;
	sort(c,c+n);
	for(int i=0;i<n;i++){
		(ans+=2ll*c[i]*(f[n-i-1]+1ll*Pow[n-i-1]*Pow[n-i-1]%mo)%mo*Pow[i]%mo*Pow[i]%mo)%=mo;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int num(int n){
  int k=0;
  while(n%2==0){
    n/=2;
    k++;
  }
  return k;
}

int main(){
  int n;cin>>n;
  int mx=0,ans;
  while(n){
    if(mx<num(n)){
      mx=num(n);
      ans=n;
    }
    n--;
  }
  cout<<max(ans,1);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    unsigned int X;
    unsigned long long h=0;
    cin>>X;
    while(X>=500)
    {
        X-=500;
        h+=1000;
    }

    while(X>=5)
    {
        X-=5;
        h+=5;
    }
    cout<<h;
}


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

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

int main(){
int A,B;
cin>>A>>B;
string S;
cin>>S;
rep(i,A){
  if(S[i]<'0'||S[i]>'9'){
    cout<<"No"<<endl;
    return 0;
  }
}
if(S[A]!='-'){
  cout<<"No"<<endl;
  return 0;
}
for(int i=A+1;i<A+B+1;i++){
if(S[i]<'0'||S[i]>'9'){
    cout<<"No"<<endl;
    return 0;
  }

}

cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]

cnt = Counter(a)
double = 0
double_id = []
for key in cnt.keys():
    double += cnt[key] - 1
    if cnt[key] > 1 and key not in double_id:
        double_id.append(key)
if double == 0:
    print(len(cnt))
elif double % 2 == 1:
    print(len(cnt)-1)
elif double % 2 == 0:
    # if len(double_id) == 2:
    #     if abs(double_id[1] - double_id[0]) == 1:
    #         print(len(cnt)-1)
    #         exit()
    print(len(cnt))

Measured memory_bytes: 18656