akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	ll A, B, X;
	ll ans = 0;
	ll cnt = 0;
	scanf("%lld%lld%lld", &A, &B, &X);

	cnt = B / X - A / X;
	if (A%X == 0) {
		cnt ++;
	}
	ans = cnt;
	printf("%lld\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;
        vector<pair<ll, ll> > p(N);
        rep(i, 0, N) {
                cin >> p[i].first >> p[i].second;
        }
        sort(all(p));
        ll ans = 0;
        rep(i, 0, N) {
                if (p[i].second < M) {
                        M -= p[i].second;
                        ans += p[i].second * p[i].first;
                } else {
                        ans += M * p[i].first;
                        break;
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int arr[200005],pre[200005];
int main()
{
	int n;
	scanf("%d",&n);
	pre[0]=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
		pre[i]=pre[i-1];
		if (arr[i])
		pre[i]=i;
	}
	long long ans=0;
	for (int i=1;i<=n;i++)
	{
		int cur=i,a=0,b=0;
		while (cur)
		{
			a+=arr[cur];
			b^=arr[cur];
			if (a!=b)
			break;
			cur=pre[cur-1];
		}
		ans+=i-cur;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1792
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	string sInput;
	cin >> sInput;
	if (sInput.length() < 4){
		cout << "No\n";
		goto endapp;
	}
	if (sInput.substr(0, 4) == "YAKI")
		cout << "Yes\n";
	else
		cout << "No\n";
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vc<ll> p(M);
    vc<string> s(M);
    rep(i, M) {
        cin >> p[i] >> s[i];
        p[i]--;
    }
    vc<bool> isok(N, false);
    vc<ll> cnt(N, 0);
    rep(i, M) {
        if (s[i] == "WA" && isok[p[i]] == false)
            cnt[p[i]]++;
        else if (s[i] == "AC")
            isok[p[i]] = true;
    }

    ll accnt = 0, pcnt = 0;
    rep(i, N) {
        if (isok[i]) accnt++;
        if (isok[i]) pcnt += cnt[i];
    }
    cout << accnt << " " << pcnt << endl;

    return 0;
}

Measured memory_bytes: 7296
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#include<map>
#include<list>
#include<cctype>
using namespace std;

int main()
{
	double n,x,t,ans;
	scanf("%lf%lf%lf",&n,&x,&t);
	ans=ceil(n/x)*t;
	printf("%0.lf\n",ans);
	return 0;
}


Measured memory_bytes: 3824
if __name__ == '__main__':
    x, y, a, b, c = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort(reverse=True)
    q = list(map(int, input().split()))
    q.sort(reverse=True)
    r = list(map(int, input().split()))
    r.sort(reverse=True)
    t = p[:x] + q[:y] + r[:(x + y)]
    t.sort(reverse=True)
    print(sum(t[:(x + y)]))


Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int sum = 700;
    string s; cin >> s;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') sum += 100;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 105;
const double pi = acos(-1);

int n, m, b[N << 1];
double a[N << 1];
pii p[N];

inline double Fix(double x) {
  if (x < 0) {
    x += 2 * pi;
  }
  if (x >= 2 * pi) {
    x -= 2 * pi;
  }
  return x;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 1; i <= n; ++i) {
    Read(p[i].X), Read(p[i].Y);
  }
  for (int i = 1; i <= n; ++i) {
    m = 0;
    for (int j = 1; j <= n; ++j) {
      if (i == j) {
        continue;
      }
      double l = atan2(p[j].Y - p[i].Y, p[j].X - p[i].X) - pi / 2, r = l + pi;
      l = Fix(l), r = Fix(r);
      a[++m] = l, a[++m] = r;
    }
    sort(a + 1, a + m + 1), m = unique(a + 1, a + m + 1) - a - 1;
    for (int j = 1; j <= m; ++j) {
      b[j] = 0;
    }
    for (int j = 1; j <= n; ++j) {
      if (i == j) {
        continue;
      }
      double l = atan2(p[j].Y - p[i].Y, p[j].X - p[i].X) - pi / 2, r = l + pi;
      l = Fix(l), r = Fix(r);
      int u = lower_bound(a + 1, a + m + 1, l) - a, v = lower_bound(a + 1, a + m + 1, r) - a;
      for (int x = u; x != v; b[x] = 1, x = x % m + 1);
    }
    double len = 0;
    for (int j = 1; j <= m; ++j) {
      if (!b[j]) {
        if (j == m) {
          len += Fix(a[1] - a[m]);
        } else {
          len += Fix(a[j + 1] - a[j]);
        }
      }
    }
    printf("%lf\n", len / pi / 2);
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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

int main()
{
    int n,a;
    scanf("%d",&n);
    a=n%1000;
    if(a==0)
        printf("0");
    else
        printf("%d",1000-a);
    return 0;
}


Measured memory_bytes: 1732
// https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();
void solve2();

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, K;
  cin >> N >> K;

  VL as(N);
  rep(i, N) cin >> as[i];

  rep(i, N - K) {
    string res = as[i + K] > as[i] ? "Yes" : "No";
    cout << res << "\n";
  }
}

void solve2() {
  ll N, K;
  cin >> N >> K;

  V<ld> as(N);

  rep(i, N) {
    ll a;
    cin >> a;
    as[i] = log(a);
  }

  V<ld> acc(N + 1);
  rep(i, N) acc[i + 1] = acc[i] + as[i];

  rep(i, N - K) {
    ld next = acc[i + 1 + K] - acc[i + 1];
    ld prev = acc[i + K] - acc[i];
    string res = next > prev + 1e-10 ? "Yes" : "No";
    cout << res << "\n";
  }
}


Measured memory_bytes: 9792
/*
ID: wangjun30
LANG: C++14
TASK:
*/
#include<iostream>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=100;i>=1;i--)
		if(a%i==0 && b%i==0){
			k--;
			if(!k){
				cout<<i;
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string S;
	cin >> S;
	int X = 0;
	int Y = 0;
	for (int i = 0; i < N; i++) {
		if ('A' <= S[i] && S[i] <= 'M') {
			X++;
		}
		else if ('N' <= S[i] && S[i] <= 'Z') {
			X--;
		}
		else if ('a' <= S[i] && S[i] <= 'm') {
			Y++;
		}
		else if ('n' <= S[i] && S[i] <= 'z') {
			Y--;
		}
	}
	string res;
	if (X > 0) {
		for (int i = 0; i < X; i++) {
			res.push_back('A');
		}
	}
	else {
		for (int i = 0; i < -X; i++) {
			res.push_back('N');
		}
	}
	if (Y > 0) {
		for (int i = 0; i < Y; i++) {
			res.push_back('a');
		}
	}
	else {
		for (int i = 0; i < -Y; i++) {
			res.push_back('n');
		}
	}
	cout << res.size() << endl;
	cout << res << endl;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, sum = 0, q;
	cin >> n;
	
	vector<ll> a(n);
	unordered_map<int, int> um;
	for ( ll &i : a){
		cin >> i;
		sum += i;
		um[i]++;
	}
	
	ll b, c, um_b;
	cin >> q;
	while (q--){
		cin >> b >> c;
		um_b = um[b];
		um[c] += um_b;
		um[b] = 0;
		sum += (c * um_b) - (b * um_b);
		cout << sum << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 7732
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    ll sum=0;
    ll ans=0;
    REP(i, 0, n){
        if(a[i]==0){
            ans+=sum/2;
            sum=0;
        }
        sum+=a[i];
    }
    ans+=sum/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;
	int n, flag, goal, d, startX;

	void run() {
		for (;;) {
			n = sc.nextInt();
			if (n == 0) {
				return;
			}
			startX = (sc.nextInt() - 1) * 2;
			goal = sc.nextInt();
			d = sc.nextInt();
			int[][] field = new int[d][n * 2 - 1];
			flag = 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < d; j++) {
					field[j][i * 2] = 1;
				}
			}
			for (int i = 0; i < d; i++) {
				char[] input = sc.next().toCharArray();
				for (int j = 0; j < input.length; j++) {
					field[i][1 + j * 2] = Integer.valueOf(input[j] - '0');
				}
			}
			int nowX = startX;
			for (int nowY = 0; nowY < d; nowY++) {
				if (nowX - 2 >= 0 && field[nowY][nowX - 1] == 1) {
					nowX = nowX - 2;
				} else if (nowX + 2 <= n * 2 - 2 && field[nowY][nowX + 1] == 1) {
					nowX = nowX + 2;
				}
			}
			if ((nowX / 2 + 1) == goal) {
				flag = 0;
			} else {
				label:
				for (int i = 0; i < d; i++) {
					for (int j = 0; j < n * 2 - 1; j++) {
						if (flag == 2) {
							break label;
						}
						if (field[i][j] == 0) {
							if ((j - 2 < 0 || j - 2 > 0 && field[i][j - 2] != 1)
									&& (j + 2 > n * 2 - 2 || j + 2 < n * 2 - 2
											&& field[i][j + 2] != 1)) {
								check(field, j, i);
							}
						}
					}
				}
			}
			if (flag != 2) {
				System.out.println(flag);
			}
		}
	}

	void check(int field[][], int connectX, int connectY) {
		field[connectY][connectX] = 1;
		int nowX = startX;
		for (int nowY = 0; nowY < d; nowY++) {
			if (nowX - 2 >= 0 && field[nowY][nowX - 1] == 1) {
				nowX = nowX - 2;
			} else if (nowX + 2 <= n * 2 - 2 && field[nowY][nowX + 1] == 1) {
				nowX = nowX + 2;
			}
		}
		field[connectY][connectX] = 0;
		if (nowX / 2 + 1 == goal) {
			flag = 2;
			System.out.println((connectY + 1) + " " + (connectX / 2 + 1));
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j] + " ");
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 17256
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
vector<char> s;
char s1,s2,s3;
cin >>s1>>s2>>s3;
s.push_back(s1);

s.push_back(s2);

s.push_back(s3);
sort(s.begin(),s.end());
if(s.at(0)=='A'&&s.at(1)=='B'||s.at(1)=='A'&&s.at(2)=='B')cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
using namespace std;

inline static long long subsum(const int lef, const int rig, const vector<long long> &s) {
    return s[rig] - s[lef - 1];
}

long long solution(const vector<int> &a) {
    int n = a.size();
    vector<long long> s(n + 1, 0LL);
    for (int i = 0; i < n; ++i) {
        s[i + 1] = s[i] + a[i] * 1LL;
    }
    long long foo = 0x3f3f3f3f3f3f3f3fLL;
    int lef = 1;
    int rig = 3;
    for (int mid = 2; mid <= n; ++mid) {
        while(lef + 1 < mid && abs(subsum(1, lef, s) - subsum(lef + 1, mid, s)) >=  abs(subsum(1, lef + 1, s) - subsum(lef + 2, mid, s)))
            lef++;
        while(rig + 1 < n && abs(subsum(mid + 1, rig, s) - subsum(rig + 1, n , s)) >= abs(subsum(mid + 1, rig + 1, s) - subsum(rig + 2, n, s)))
            rig++;
        foo = min(
            max(max(max(subsum(1, lef, s), subsum(lef + 1, mid, s)), subsum(mid + 1, rig, s)), subsum(rig + 1, n, s))
                - min(min(min(subsum(1, lef, s), subsum(lef + 1, mid, s)), subsum(mid + 1, rig, s)), subsum(rig + 1, n, s))
        , foo);
    }
    return foo;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    printf("%lld\n", solution(a));
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("firesafe.in", "r", stdin);
//	freopen("firesafe.out", "w", stdout);
	int n;
	cin >> n;
	set <int> st;
	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		st.insert(x);
	}
	cout << (st.size() == n ? "YES" : "NO");
	return 0;
}

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

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

  int maxi=0;

  for(int i=0;i < n;i++){
    set<char>st1;
    set<char>st2;
    for(char m = 'a';m <= 'z';m++){
      bool flag = true;
      for(int j=0;j <= i;j++){
	if(s[j] == m){
	  st1.insert(s[j]);
	  flag = false;
	}
      }
      if(flag) continue;
      for(int j=i+1;j < s.size();j++){
	if(s[j] == m) st2.insert(s[j]);
      }
    }
    maxi = max(min((int)st1.size(),(int)st2.size()),maxi);
  }
  cout << maxi << endl;
  return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    for(int i = 0; i < n; i++) p[i]--;
    long long ans = -1e18;
    for(int si = 0; si < n; si++) {
        int x = si;
        long long sum = 0;
        vector<int> s;
        while(1) {
            x = p[x];
            sum += c[x];
            s.push_back(c[x]);
            if(x == si) break;
        }
        long long t = 0;
        int l = (int)s.size();
        for(int i = 0; i < l; i++) {
            t += s[i];
            long long now = t;
            if(i + 1 > k) break;
            if(sum > 0) {
                long long e = (k - i - 1) / l;
                now += sum * e;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> check(N, -1);
    rep(i, M) {
        ll s, c;
        cin >> s >> c;
        s--;
        if (check[s] != -1 && check[s] != c) {
            cout << -1 << '\n';
            return;
        }else {
            check[s] = c;
        }
    }

    rep(i, 1000) {
        string s = to_string(i);
        if (s.size() == N) {
            bool ok = true;
            rep(j, N) {
                if (check[j] != -1) {
                    if (check[j] != (s[j] - '0')) {
                        ok = false;
                    }
                }
            }
            if (ok) {
                cout << s << '\n';
                return;
            }
        }
    }
    cout << -1 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"math"
	"os"
	"strings"
	"strconv"
)
var inputReader *bufio.Reader
var input int
var err error
func main(){
	inputReader = bufio.NewReader(os.Stdin)
	var input string
	var temp int
	var counter int
	input, err = inputReader.ReadString('\n')
	input = strings.Replace(input, "\n", "", -1)
	temp,err=strconv.Atoi(input)
	counter=temp
	var seller, buyer,pri,diff int
	seller =0
	diff =math.MinInt64
	buyer =math.MaxInt64
	for i:=0 ;i < counter ;i++ {
		input, err = inputReader.ReadString('\n')
		input = strings.Replace(input, "\n", "", -1)
		temp,err=strconv.Atoi(input)
		if i!=0 && diff< temp-pri {
			diff = temp - pri
		}
		if temp < buyer && i < counter-1 {
			buyer = temp
			seller = 0
			pri= temp
			continue
		}
		if temp > seller {
			seller = temp
		}
		if seller !=0 && diff< seller-buyer {
			diff= seller - buyer
		}
		pri= temp
	}
	fmt.Println(diff)
}


Measured memory_bytes: 5956
#include <iostream>
#include <vector>

int main() {
  int N;
  int A;
  int B;
  int C;
  int M;

  std::vector<int> s;
  std::vector<int> t;

  int tmp;
  int count = 0;

  std::cin >> N >> M >> C;
  for (int k = 0; k < M; k++) {
    std::cin >> B;
    s.push_back(B);
  }

  for (int i = 0; i < N; i++) {
    int sum = 0;
    for (int j = 0; j < M; j++) {
      // std::cin >> A >> B;
      // tmp = A * B;
      std::cin >> A;
      sum = sum + A * s[j];
    }

    if (sum + C > 0) {
      count = count + 1;
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    ll x,y;
    cin >> x >> y;
    ll ans = 0;
    while(x <= y){
        x*=2;
        ans++;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int Max(int, int);

int main(void){
    int a, b, c, d;
    
    while(scanf("%d %d", &a, &b) != EOF){
        c = Max(a,b);
        d = a / c * b;
        
        printf("%d %d\n", c, d);
    }
    return 0;
}

int Max(int a,int b){
    int rem;
    
    if(a == 0 || b == 0) return 0;
    
    while((rem = a % b) != 0){
        a = b;
        b = rem;
    }
    return b;
}



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

int main(void){
    string n;
    cin >> n;
    if(n[0]=='9'||n[1]=='9')cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll Mod = 1000000007;
int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  for(int i = 0; i < n / 2; i++){
    swap(s[i] , s[n - i - 1]);
  }
  if(s == t){
    cout << "YES";
  }else{
    cout << "NO";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

int func(vector<char> &v, int len) {

  int cnt = 0;

  for(int i=0; i<len-1; ++i) {
    if(v[i]!=v[i+1]) {
      ++cnt;
      ++i;
    }
  }

  return cnt;
}

int main() {

  int n;
  vector<char> vc(100001);

  cin >> n;
  rep(i, n) cin >> vc[i];

  int cnt1, cnt2 = 0;

  cnt1 = func(vc, n);

  reverse(vc.begin(), vc.begin()+n);

  cnt2 = func(vc, n);

  cout << max(cnt1, cnt2) << endl;

  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int prime[55556] = {};

int main(){
    int i, j, n;
    vector<int> res;
    cin >> n;
    for(i=2; i<55556; i++){
        if(prime[i] == 0){
            if(i%5 == 1){
                res.push_back(i);
            }
            j = 2;
            while(i*j<55556){
                prime[i*j] = 1;
                j++;
            }
        }
    }
    for(i=0; i<n; i++){
        cout << res[i] << ' ';
    }
    return 0;
}

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

using namespace std;

int main (){
	
  int n;
  int cnt=0;
  int j=0;
  int max_cnt=0;
  cin>>n;
  
  
  vector <long> h(n);
  
  for(int i=0; i<n;i++){
  	cin>>h.at(i);
  }
  
  
  for(int i = 0;i< n-1 ; i++){
  	if(h.at(i) >= h.at(i+1)){
    	for( j = i; j < n-1;j++){
    		if(h.at(j)>=h.at(j+1)){
        	cnt++;
        	}
          	else{
            break;
            }
    	}
      	if(max_cnt<cnt){
      	max_cnt = cnt;
      	}
      	cnt=0;
      	i=j;
    }
  }
  	cout<<max_cnt<<endl;
	
  	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int a,b; cin >> a >> b;
  cout << (a*b%2==0?"Even":"Odd") << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int n,l;
string s[105];
bool cmp(string a,string b)
{
	return a<b;
}
int main()
{
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	cin>>s[i];
	sort(s+1,s+1+n,cmp);
	for(int i=1;i<=n;i++)
	cout<<s[i];
	cout<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int i;
    for (i = 0; i < n; ++i) {
        if (x < a[i]) break;
        x -= a[i];
    }

    if (i == n && x > 0) cout << n - 1 << endl;
    else cout << i << endl;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b) = (line[0], line[1]);

    println!("{}", cmp::max(cmp::max(a+b, a-b), a*b));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main () {
      ios_base::sync_with_stdio(false);
   
   long long int n,sum=0,sum1=0;cin>>n;
   string s[n],l;
   long long int a[n];
   for (long long int i=0;i<n;i++) {cin>>s[i]>>a[i];sum+=a[i];}
   cin>>l;
   for (long long int i=0;i<n;i++) {
       sum1+=a[i];
       if (s[i]==l) {
           break;
       } 
   }
   cout<<sum-sum1<<endl;
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
          
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    unordered_map<string, int> ht;
    
    int N; cin >> N;
    vector<string> vS(N);
    for(int i=0; i<N; ++i){ cin >> vS[i]; }
    
    string s_prev="";
    for(int i=0; i<N; ++i){
        string s=vS[i];
        if(i!=0 && s[0] != s_prev[s_prev.size()-1]){ cout << "No" << endl; return 0; }
        
        auto itr = ht.find( s );
        if(itr!=ht.end()){ cout << "No" << endl; return 0; }
        ht.insert({s, 1});
        s_prev = s;
    }
    cout << "Yes" << endl;
    
    return 0;
}


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

int main() {
	int a=0;
	int b=0;
	int c=0;

	for(int i = 0; i < 7; i++) {
		cin >> a;
		cin >> b;

		c = a - b;

		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans = abs(abs(y) - abs(x));

  if (x > 0 && y < 0) {
    ans += 1;
  } else if (x == -y) {
    ans = 1;
  } else if (x < 0 && y < 0 && x > y) {
    ans += 2;
  } else if (x > 0 && y > 0 && x > y) {
    ans = min(ans + 2, x + y + 1);
  } else if (x < 0 && y > 0) {
    ans += 1;
  } else if (x == 0 && y < 0) {
    ans += 1;
  } else if (x > 0 && y == 0) {
    ans += 1;
  } 

  
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main()
{
    long double n; cin >> n;
    int X = n / 1.08;
    for (int i = X - 10; i < X + 10; i++) if (int(i*1.08) == n) return cout << i << "\n", 0;
    cout << ":(\n";

    return 0;
}


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

using namespace std;
using ll = long long;
const int mod = 1e9 +7;
const int maxn = 10010;

char k[maxn];

int main()
{
    scanf("%s", k);
    int d;
    scanf("%d", &d);
    int n = strlen(k);
    vector<vector<ll>> dp(d, vector<ll>(2));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++){
        vector<vector<ll>> new_dp(d, vector<ll>(2));
        for (int sum = 0; sum < d; sum++){
            vector<bool> v = {0, 1};
            for (bool smaller : v){
                for (int digit = 0; digit < 10; digit++){
                    if (digit > k[i] - '0' && !smaller){
                        break;
                    }
                    new_dp[(sum + digit) % d][smaller || (digit < k[i] - '0')] =
                            (new_dp[(sum + digit) % d][smaller || (digit < k[i] - '0')] + dp[sum][smaller]) % mod;
                }
            }
        }
        dp = new_dp;
    }
    ll ans = (dp[0][0] + dp[0][1]) % mod;
    ans = (ans - 1 + mod) % mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define xx first
#define yy second
 
#define pii pair <int, int >
#define pll pair < ll, ll >
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define vp vector < pii >
 
#define inf  100000000
 
#define f(i, c, n) for(int i = c; i < n; i++)
#define fe(i, c, n) for(int i = c; i <= n; i++)
#define fr(i, n, c) for(int i = n - 1; i >= c; i--)
 
#define be(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())
#define S " "
#define N "\n"

//cout << "Case " << ++cs << ": " <<
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FILE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);


void solve() {
	int a, b;
	cin >> a >> b;
	int mx = a + b;
	mx = max(mx, a * b);
	mx = max(mx, a - b);
	cout << mx <<N;
}

int main() {
    // FILE;
    fast;
    // int t; cin >> t; while(t--)
    solve();
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define L long int
#define LL long long int
#define Pi pair<int,int>
#define Pl pair<L,L>
#define vi vector<int>
#define Vi vector<vector<int>>
#define vl vector<long int>
#define Vl vector<vector<long int>>
#define vp vector<Pi>
#define mod 1000000007
using namespace std;
int main(){
	char A;
	cin>>A;
	if(A>=65 && A<=91)
		cout<<"A\n";
	else
		cout<<"a\n";
	return 0;
}


Measured memory_bytes: 3548
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 222222

ll a[MAX], b[MAX], c[MAX];

int main(void) {
  map<ll, ll> mp;
  cin >> n;
  FOR(i, 1, n+1) {
	cin >> a[i];
	b[i] = b[i - 1] + a[i];
	if (b[i] == 0) ans++;
	sum += a[i];
  }
  if (sum == 0) ans--;
  FOR(i, 1, n + 1) {
	c[i] = sum - b[i - 1];
	if (c[i] == 0) ans++;
  }
  FOR(i, 3, n + 1) {
	mp[b[i - 2]]++;
	ans += mp[sum - c[i]];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 17664
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/20/20 20:14:01
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int gcd(int a, int b) {
  return a%b==0 ? b : gcd(b, a%b);
}

int lcm(int a, int b) {
  return a/gcd(a,b)*b;
}

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

  int x; cin>>x;
  cout << lcm(x, 360)/x << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


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

int main() {
    ios_base::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll c=gcd(360,x);
    cout << 360/c << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
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 () {
  while(true) {
    string s = stin();
    if (s == "-") break;
    int m = in();
    rep(i,m) {
      int h = in();
      string tmp = s.substr(0,h);
      s.erase(0,h);
      s += tmp;
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    ll ans = 0;
    rep(i, (1<<s.size()-1)) {
        ll cur = s[0] - '0';
        rep(j, s.size()-1) {
            if(i & (1<<j)) {
                ans += cur;
                cur = 0;
            }
            else cur *= 10;
            cur += s[j+1] - '0';
            //cout << i << ' ' << j << ' ' << cur  << ' ' << ans << endl;
        }
        ans += cur;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();

		int halfResult = Math.min(P + Q, Q + R);
		int result = Math.min(halfResult, R + P);
		System.out.println(result);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int p,q,r;
    int ans;
    cin >> p >> q >> r;
    ans = min(q+r,p+r);
    ans = min(ans,q+p);
    cout <<  ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
const int LIMIT = pow(10, 7);
int main (void) {
    int N;
    int A, B;

    cin >> N >> A >> B;

    int cnt = 0;
    while (true) {
        if (cnt == LIMIT) {
            break;
        }

        if (A == 1 && A + 1 == B) {
            cout << "Borys" << endl;
            return 0;
        } else if (A + 1 != B) {
            A++;
        } else {
            A--;
        }

        if (B == N && B - 1 == A) {
            cout << "Alice" << endl;
            return 0;
        } else if (B - 1 != A) {
            B--;
        } else {
            B++;
        }

        cnt++;
    }

    cout << "Draw" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n, p[50010], i, j, ans, rem;
  
  while(scanf("%d", &n), n){
    for(i=0; i<n; i++){
      scanf("%d", &p[i]);
    }

    ans=1000000;
    for(i=0; i<n-1; i++){
      for(j=i+1; j<n; j++){
	rem=p[i]-p[j];
	if(rem<0) rem*=(-1);

	if(rem<ans) ans=rem;
      }
    }

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

Measured memory_bytes: 1760
#!/usr/bin/env python3
import sys
from collections import deque

def solve(N: int, a: "List[int]", b: "List[int]"):
    h = [[] for _ in range(N+1)]    

    for i in range(N-1):
        h[a[i]].append(b[i])
        h[b[i]].append(a[i])

    queue = deque([1])

    ## 頂点iの親を格納
    parents = [0]*(N+1)
    order = []

    while queue:
        q = queue.pop()
        order.append(q)

        for child in h[q]:
            if child == parents[q]:
                continue

            parents[child] = q
            queue.append(child)

    ## 頂点i と親nodeの間のcolor
    color = [0]*(N+1)

    for o in order:
        ng_color = color[o]
        cur_color = 1

        for node in h[o]:
            if node == parents[o]:
                continue

            if cur_color == ng_color:
                cur_color += 1
            
            color[node] = cur_color
            cur_color += 1


    answer = []
    append = answer.append
    for i in range(N-1):
        if parents[a[i]] == b[i]:
            append(color[a[i]])
        else:
            append(color[b[i]])

    print(max(answer))
    print(*answer, sep="\n")

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()


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

a=[int(input()) for _ in range(n)]

flag=0
for aa in a:
    if aa%2==1:
        flag=1

if flag==0:
    print("second")
else:
    print("first")

###1個
#111
#奇数ならfirst 偶数ならsecond

###２個
#111
#111
#奇数奇数ならfirst
#11
#11
#偶数偶数ならsecond
#



Measured memory_bytes: 80272