akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	map<pii,bool>m;
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int k;
		cin>>k;
		if(k>i){
			m[mp(i,k)]=1;
		}
		else{
			if(m[mp(k,i)])ans++;
		}
	}
	cout<<ans;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 9868
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n; cin >> n;
    char s_i;
    for (int i=0;i<n;i++){
        cin >> s_i;
        if (s_i=='Y') {
            cout << "Four" << endl;
            break;
        }
        else if (i==n-1) cout << "Three" << endl;
    } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    unordered_set<string>s;
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        s.insert(str);
    }
    cout<<s.size()<<endl;
    
    


    return 0;
}

Measured memory_bytes: 17644
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int N;
    cin >> N;
    cout << N * N*N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> A, vector<long long> B){
	ll now = 0;
	for (int i = N-1; i >= 0; i--) {
		now += (B[i]-(A[i]+now)%B[i])%B[i];
	}
	cout << now << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> B(N-1+1);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
	solve(N, A, B);
	return 0;
}



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

int main() {
    ll n = 0;
    for (int i = 1; i <= 5; i++) {
        n = n + pow(26L, i);
        // cout << n << endl;
    }
    // cout << "****" << endl;

    ll N;
    cin >> N;
    n = 0;
    ll pre = 0;
    int keta = 1;
    for (;;keta++) {
        n = pre + pow(26L, keta);
        if (n >= N) {
            N -= pre;
            N--;
            break;
        }
        pre = n;
    }

    string ans = "";
    rep(i, keta) {
        char ch = (N) % 26 + 'a';
        // if (N == 0) ch = 'a';
        ans = ch + ans;
        N /= 26;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> a;
    vector<string> b;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        a.push_back(s);
    }
    for (int i = 0; i < m; ++i) {
        string s;
        cin >> s;
        b.push_back(s);
    }
    for (int y = 0; y < n-m+1; ++y) {
        for (int x = 0; x < n-m+1; ++x) {
            bool found = true;
            for (int j = 0; j < m; ++j) {
                for (int i = 0; i < m; ++i) {
                    if (a[y+j][x+i] != b[j][i]) {
                        found = false;
                    }
                }
            }
            if (found) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    int n,cnt=0;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]%2!=0 && i%2!=0)cnt++; 
    }
    cout<<cnt;
}

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

using namespace std;

#define int long long

const int N = 2e5 + 100;

int a[N];
int n, cnt;

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	if (a[0] != 0)
		return cout << -1, 0;
	for (int i = 1; i < n; i++)
		if (a[i] > a[i - 1] + 1)
			return cout << -1, 0;
	for (int i = n - 1; i >= 0; i--)
		if (a[i] > a[i + 1] - 1)
			cnt += a[i];
	return cout << cnt, 0;	
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;

int dat[100005];
int minn[100005];

int main(){
	int in;
	cin>>in;
	rep(i,in,1){
		cin>>dat[i];
	}
	for(int i=in-1;i>=1;i--){
		if(i==in-1){
			minn[i]+=abs(dat[i]-dat[i+1]);
		}
		else{
			minn[i]+=min(abs(dat[i]-dat[i+1])+minn[i+1],abs(dat[i]-dat[i+2])+minn[i+2]);
		}
	}
	cout<<minn[1]<<endl;	
	return 0;
}

Measured memory_bytes: 1024
// 2020-08-02 14:53:59
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  LL n, d, c = 0;
  cin >> n >> d;
  vector<pair<LL, LL>> f (n);
  for (auto &it : f){
    cin >> it.first >> it.second;
    DD dd = sqrt(abs(pow(it.first, 2) + pow(it.second, 2)));
    c += (dd <= d) ? 1 : 0;
  }
  cout << c << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int ans=0;
	if(a==1&&b==1){
		cout<<"1000000"<<endl;
		return 0;
	}
	switch(a){
		case 1:ans+=300000;break;
		case 2:ans+=200000;break;
		case 3:ans+=100000;break;
	}
	switch(b){
		case 1:ans+=300000;break;
		case 2:ans+=200000;break;
		case 3:ans+=100000;break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n, q = gets.chomp.split(' ').map{|s| s.to_i}
text = gets.chomp

count = Array.new(n+1, 0)

for i in 0..n-1 do
  if (i != n) and (text[i] == 'A') and (text[i+1] == 'C') then
    count[i+1] = count[i]+1
  else
    count[i+1] = count[i]
  end
end
  
for i in 1..q do
  from, to = gets.chomp.split(' ').map{|s| s.to_i}
  print (count[to-1] - count[from-1])
  print "\n"
end


Measured memory_bytes: 3324
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string input;
	int count = 0;

	cin >> input;
	for(int i = 0; i < 3; ++i) {
		if (input[i] == '1') { ++count; }
	}
	cout << count << endl;

	return 0;
}


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

int main() {
  
  string s;
  cin >> s;
  
  if (s.at(0)=='S') cout << "Cloudy" << endl;
  else if (s.at(0)=='C') cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}

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

typedef pair<int,int> P;

int N, ans[100005];
vector<P> G[100005];

void dfs(int x, int px){
  
  for(P g : G[x] ){
    
    int nx = g.first;
    int cost = g.second;
    
    if( nx == px ) continue;
    
    if( cost % 2 == 0 ) ans[nx] = ans[x];
    else ans[nx] = !ans[x];
    
    dfs( nx, x );
    
  }
  
}

signed main(){
  
  cin>>N;
  
  for(int i=0;i<N-1;i++){
    int u, v, w;
    cin>>u>>v>>w;
    G[u-1].push_back(P(v-1,w));
    G[v-1].push_back(P(u-1,w));
  }
  
  ans[0] = 0;
  
  dfs( 0, 0 );
  
  for(int i=0;i<N;i++) cout<<ans[i]<<endl;
  
  return 0;
}


Measured memory_bytes: 10240
import Foundation


func readInt() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}


func main() {
    let line = readInt()
    let N = line[0]
    let M = line[1]

    var graph = (0...N).map { _ in [Int]() }
    for _ in (1...M) {
        let ab = readInt()
        let a = ab[0]
        let b = ab[1]
        graph[a].append(b)
        graph[b].append(a)
    }

    var ans = [Int](repeating: -1, count: N + 1)
    var q = ArraySlice<Int>()
    q.append(1)
    while let u = q.popFirst() {
        for v in graph[u] {
            guard ans[v] == -1 else { continue }
            ans[v] = u
            q.append(v)
        }
    }

    if ans[2...].contains(-1) {
        print("No")
        return
    }

    print("Yes")
    for i in ans[2...] {
        print(i)
    }

}

main()

Measured memory_bytes: 24164
#include<iostream>
#include<cmath>
using namespace std;
long long X, Y, Z, R, A, B, C;
long long T[3][1300], dp[4][4000];
int main() {
	cin >> X >> Y >> Z >> A >> B >> C >> R; dp[0][0] = 1;
	for (int i = 0; i < X; i++) { T[0][abs(i - A) % R]++; }
	for (int i = 0; i < Y; i++) { T[1][abs(i - B) % R]++; }
	for (int i = 0; i < Z; i++) { T[2][abs(i - C) % R]++; }
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < R; j++) {
			for (int k = 0; k < R; k++)dp[i + 1][(j + k) % R] += dp[i][j] * T[i][k];
		}
	}
	for (int i = 0; i < R; i++) { if (i)cout << ' '; cout << dp[3][i]; }
	cout << endl;
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

void Minkowski_distance(int n, int p, int X[100], int Y[100]){
  double md;

  if ( p == 0 ){
    int max = 0;
    for (int i = 0; i < n; i++) {
      max = (max < fabs(X[i] - Y[i])?(fabs(X[i]-Y[i])):max);
    }
    md = max;
  }
  else {
    double p_power_sum = 0;
    for (int i = 0; i < n; i++) {
      p_power_sum += pow(fabs(X[i]-Y[i]), p);
    }
    md = pow(p_power_sum, 1.0/p);
  }
  printf("%.8f\n", md);
}

int main() {
  int n;
  int X[100]={0}, Y[100]={0};

  cin >> n;
  for (int i = 0; i < n; i++) cin >> X[i];
  for (int i = 0; i < n; i++) cin >> Y[i];

  Minkowski_distance(n, 1, X, Y);
  Minkowski_distance(n, 2, X, Y);
  Minkowski_distance(n, 3, X, Y);
  Minkowski_distance(n, 0, X, Y);
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
using namespace std;
const int N=4000005;
const int MOD=998244353;
int n,m;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=4000000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	init();
	scanf("%d%d",&n,&m);
	long long ans=0;
	int num=(m+1)%2==1?m+1:m+2;
	for(int i=0;i<=n&&i<=m;i++)
	{
		if(i%2!=m%2) continue;
		int t=(3*m-i)/2;
		if(t<0) continue; 
		long long res=0;
		res=(res+C(t+n-1,n-1)*C(n,i)%MOD)%MOD;
		if(t-m>=0) res=(res-C(t-m+n-1,n-1)*C(n-1,i-1)%MOD*n%MOD+MOD)%MOD;
		if(t-(m+1)>=0) res=(res-C(t-(m+1)+n-1,n-1)*C(n-1,i)%MOD*n%MOD+MOD)%MOD;
		ans=(ans+res)%MOD;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 66276
import collections
n = int(input())
dd = collections.defaultdict(int)
for _ in range(n):
    dd[input()] += 1
ans = []
for key in dd.keys():
    ans.append((dd[key], key))
ans.sort(reverse=True)
ans2 = [ans[0][1]]
for i in range(1, len(ans)):
    if ans[i - 1][0] != ans[i][0]:
        break
    ans2.append(ans[i][1])
ans2.sort()
print(*ans2, sep='\n')

Measured memory_bytes: 48640
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long int
#define mod 1000000007
void dfs(int src,vector<int> adj[],int &here,bool visited[])
{
	if(visited[src])
	   return ;
	else
	{
		visited[src]=true;
		here++;
		for(int x:adj[src])
		   dfs(x,adj,here,visited);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str1,str2;
	cin>>str1>>str2;
	int n1=str1.size(),n2=str2.size();
	int answer=n1;
	int j;
	for(j=0;j<=n1-n2;j++)
	{
		int count=0;
		int i=0;
		int ptr=j;
		for(i=0;i<n2;i++)
		{
			if(str2[i]!=str1[ptr])
			   count++;
			ptr++;
		}
		answer=min(answer,count);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

template <class T>
T lcm(T a,T b){
	return a*(b/gcd(a,b));
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;
}

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

const int mod = 1e9 + 7;
template<typename T>
T add(T x) {
  return x;
}
template<typename T, typename... Ts>
T add(T x, Ts... y) {
  T res = x + add(y...);
  if (res >= mod)
    res -= mod;
  return res;
}
template<typename T, typename... Ts>
T sub(T x, Ts... y) {
  return add(x, mod - add(y...));
}
template<typename T, typename... Ts>
void udd(T &x, Ts... y) {
  x = add(x, y...);
}
template<typename T>
T mul(T x) {
  return x;
}
template<typename T, typename... Ts>
T mul(T x, Ts... y) {
  return (x * 1ll * mul(y...)) % mod;
}
template<typename T, typename... Ts>
void uul(T &x, Ts... y) {
  x = mul(x, y...);
}
int bin(int a, ll deg) {
  int r = 1;
  while (deg) {
    if (deg & 1)
      uul(r, a);
    deg >>= 1;
    uul(a, a);
  }
  return r;
}
int inv(int x) {
  assert(x);
  return bin(x, mod - 2);
}

const int maxn = 4005;
int d[maxn][maxn];
const int sh = maxn / 2;
int c[maxn][maxn];

signed main() {
#ifdef LOCAL
  assert(freopen("e.in", "r", stdin));
#endif
  c[0][0] = 1;
  for (int i = 0; i < maxn; ++i) {
    for (int j = 0; j < maxn; ++j) {
      if (i > 0) {
        udd(c[i][j], c[i - 1][j]);
      }
      if (j > 0) {
        udd(c[i][j], c[i][j - 1]);
      }
    }
  }
  int n;
  cin >> n;
  int res = 0;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    d[sh - a[i]][sh - b[i]]++;
    res = sub(res, c[a[i] * 2][b[i] * 2]);
  }
  for (int i = 0; i < maxn; ++i) {
    for (int j = 0; j < maxn; ++j) {
      if (i > 0) {
        udd(d[i][j], d[i - 1][j]);
      }
      if (j > 0) {
        udd(d[i][j], d[i][j - 1]);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    udd(res, d[sh + a[i]][sh + b[i]]);
  }
  uul(res, (mod + 1) / 2);
  cout << res << '\n';
}


Measured memory_bytes: 127104
q=str(input())
e=str(input())
a=len(q)
b=len(e)
c=""
if a==b:
  for i in range(a):
    c+=q[i]
    c+=e[i]
else:
  for i in range(b):
    c+=q[i]
    c+=e[i]
  c+=q[a-1]

print(c)

Measured memory_bytes: 8948
N=int(input())

AC=0
WA=0
TLE=0
RE=0


for i in range(N):
	word = input()
	if word =="AC":
		AC+=1
	if word =="WA":
		WA+=1
	if word =="TLE":
		TLE+=1
	if word =="RE":
		RE+=1
print("AC x " +str(AC))
print("WA x " +str(WA))
print("TLE x " +str(TLE))
print("RE x " +str(RE))

Measured memory_bytes: 9220
def BubbleSort(C,N):
    for i in range(N):
        j = N-1
        while True:
            if j == 0:
                break
            a,b = list(C[j]),list(C[j-1])
            if a[1] < b[1]:
                tmp = C[j-1]
                C[j-1] = C[j]
                C[j] = tmp
            j -= 1
    return C

def SelectionSort(D,N):
    for i in range(N):
        minj = i
        for j in range(i,N):
            a,b = list(D[j]),list(D[minj])
            if a[1] < b[1]:
                minj = j
        tmp = D[i]
        D[i] = D[minj]
        D[minj] = tmp
    return D

n = int(input())
d = input().split()
d2 = list(d)
d = BubbleSort(d,n)
for i in range(len(d)-1):
    print(d[i],end = ' ')
print(d[-1])
print('Stable')
d2 = SelectionSort(d2,n)
for i in range(len(d2)-1):
    print(d2[i],end = ' ')
print(d2[-1])
if d2 == d:
    print('Stable')
else:
    print('Not stable')

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;

  vector<tuple<string, ll, ll>> P;
  rep(i, N) {
    string s;
    ll p;
    cin >> s >> p;
    tuple<string, ll, ll> a = make_tuple(s, p, i + 1);
    P.pb(a);
  }

  sort(ALL(P), [](const auto& x, const auto& y) {
    if (get<0>(x) == get<0>(y)) {
      return get<1>(x) > get<1>(y);
    }
    return get<0>(x) < get<0>(y);
  });

  rep(i, N) {
    ll ii = get<2>(P[i]);
    COUT(ii);
  }
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);

    ll N, M;
    cin >> N >> M;

    vector<ll> P(N);
    vector<bool> ans(N, false);

    REP(i, N){
        ll p;
        cin >> p;
        p--;
        P[i] = p;
        if(i == p){
            ans[i] = true;
        }
    }

    // グラフ入力受取
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 頂点 s をスタートとした探索
    vector<int> dist(N, -1);
    queue<int> que;

    for (int v = 0; v < N; ++v) {
        if (dist[v] != -1) continue; // v が探索済みならスルー

        map<ll, ll> M;
        
        dist[v] = 0, que.push(v);
        while (!que.empty()) {
            int v = que.front(); que.pop();
            if(M.count(v)){
                M[v]++;
            }
            else{
                M[v] = 1;
            }
            if(M.count(P[v])){
                M[P[v]]++;
            }
            else{
                M[P[v]] = 1;
            }
            for (auto nv : G[v]) {
                if (dist[nv] == -1) {
                    dist[nv] = dist[v] + 1;
                    que.push(nv);
                }
            }
        }
        for(auto iter=M.begin(); iter!=M.end(); iter++){
            if(iter->second == 2){
                ans[iter->first] = true;
            }
        }
    }
    ll count = 0;
    REP(i, N){
        if(ans[i]) count++;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

bool countUp(vector<int> &A, int N, int M) {
    int m = -1;

    for (int i = N - 1; i >= 0; --i) {
        A.at(i)++;

        if (A.at(i) <= M) {
            m = A.at(i);
            break;
        }
    }

    for (int i = N - 1; i >= 0; --i) {
        if (A.at(i) == M + 1) {
            A.at(i) = m;
        } else {
            break;
        }
    }

    for (const int a : A) {
        if (a == -1) {
            return true;
        }
    }

    return false;
}

long long evaluate(const vector<int> &A, const vector<vector<int>> &C) {
    long long score = 0;

    for (const auto &c : C) {
        if (A.at(c.at(1) - 1) - A.at(c.at(0) - 1) == c.at(2)) {
            score += c.at(3);
        }
    }

    return score;
}

int main() {
    int N, M, Q;
    
    cin >> N >> M >> Q;

    vector<vector<int>> C(Q);

    for (int i = 0; i < Q; ++i) {
        int a, b, c, d;

        cin >> a >> b >> c >> d;

        C.at(i).push_back(a);
        C.at(i).push_back(b);
        C.at(i).push_back(c);
        C.at(i).push_back(d);
    }

    vector<int> A(N, 1);

    long long max = 0;
    
    do {
        long long score = evaluate(A, C);
        if (score > max) {
            max = score;
        }
    } while (!countUp(A, N, M));

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
N , M = map(int,input().split())
L = []
transit1 = set()
transit2 = set()
for _ in range(M):
    t = tuple(map(int,input().split()))
    L.append(t)
for x in L :
    if x[1] == N:
        transit1.add(x[0])
    if x[0] == 1:
        transit2.add(x[1])
if transit1 & transit2 == set():
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Measured memory_bytes: 37072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 200200;
int n;
char s[N];

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
		if (s[i] == '?')
			s[i] = 'D';
	printf("%s\n", s);

	return 0;
}


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

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

using namespace std;

int A[100];

int main() {
  int N, M;
  cin >> N >> M;
  int sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  sort(A, A + N);
  if (A[N - 1 - (M - 1)] * 4 * M >= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3648
import Control.Applicative

main :: IO()
main = do
    _ <- getLine
    as <- map read . words <$> getLine
    bs <- map read . words <$> getLine
    putStrLn $ calcAns as bs
        where
            calcAns as bs
                | s + s2 > 0 = "No"
                | otherwise = "Yes"
                where
                    cs = zipWith (-) as bs
                    s = sum cs
                    s2 = sum (filter (> 0) cs) + foldr (const (+1)) 0 (filter (\a -> a < 0 && odd a) cs)


Measured memory_bytes: 11644
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;

int main(){
  int a, b;
  while (cin >> a >> b) {
    cout << max(a + b, max(a - b, a * b)) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  ll n, d;
  cin >> n >> d;
  int ans = 0;
  REP(i, n) {
    long double x, y;
    cin >> x >> y;
    if ((x * x + y * y) <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), x = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		for (int i = 0; i < n; i++) {
			x -= a[i];
			if (x < 0) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(x == 0 ? n : n - 1);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1 << 30
#define LINF (ll)1 << 62
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n,m,R; cin >> n >> m >> R;
    vl r(R);
    rep(i,R){
        cin >> r[i], r[i]--;
    }
    sort(all(r));
    vector<vpl> G(n);
    vvl d(n,vl(n,INF));
    rep(i,m){
        ll a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].emplace_back(b,c);
        G[b].emplace_back(a,c);
        d[a][b] = c;
        d[b][a] = c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    ll ans = INF;
    do{
        ll dist = 0;
        rep(i,r.size()-1){
            dist += d[r[i]][r[i+1]];
        }
        ans = min(dist,ans);
    }while(next_permutation(all(r)));
    cout << ans << endl;
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

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 pair<long, long> PLL;
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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const LL INF = 1e18;


long dp[1002];
long w[1001],v[1001];


int main(){
	int maxw,N;
	int cnt=1;
	while(cin>>maxw){
		if(maxw==0)break;
		cin>>N;
		CLR(dp);
		char c;
		REP(i,N)cin>>v[i]>>c>>w[i];
		
		REP(i,N){
			for(int j=maxw;j>=0;j--){
				if(j+w[i]<=maxw){
					dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
				}
			}
		}
		cout<<"Case "<<cnt<<":"<<endl;
		cout<<dp[maxw]<<endl;
		long res=0;
		REP(i,maxw+1){
			if(dp[i]==dp[maxw]){
				res=i;break;
			}
		}
		cout<<res<<endl;
		cnt++;
	}
	return 0;
}
/*

*/

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

using namespace std;

int main()
{
    int N;
    int a[110];
    cin>>N;
    for(int i=0;i<N;i++) cin>>a[i];
        sort(a,a+N);
        reverse(a,a+N);
        int A=0,B=0;
        for(int i=0;i<N;i++){
    if(i%2==0){
       A+=a[i];
    }else{
        B+=a[i];
    }
        }
     cout<<A-B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n;
int main() {
	scanf("%d", &n);
	vector<int> ax(n), ay(n), bx(n), by(n), cx, cy;
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &ax[i], &ay[i], &bx[i], &by[i]);
		cx.push_back(ax[i]);
		cy.push_back(ay[i]);
		cx.push_back(bx[i]);
		cy.push_back(by[i]);
	}
	sort(cx.begin(), cx.end());
	cx.erase(unique(cx.begin(), cx.end()), cx.end());
	sort(cy.begin(), cy.end());
	cy.erase(unique(cy.begin(), cy.end()), cy.end());
	for (int i = 0; i < n; i++) {
		ax[i] = lower_bound(cx.begin(), cx.end(), ax[i]) - cx.begin();
		ay[i] = lower_bound(cy.begin(), cy.end(), ay[i]) - cy.begin();
		bx[i] = lower_bound(cx.begin(), cx.end(), bx[i]) - cx.begin();
		by[i] = lower_bound(cy.begin(), cy.end(), by[i]) - cy.begin();
	}
	vector<vector<int> > yi(cy.size()), yo(cy.size());
	for (int i = 0; i < n; i++) {
		yi[ay[i]].push_back(i);
		yo[by[i]].push_back(i);
	}
	vector<int> d(cx.size() - 1);
	long long ret = 0;
	for (int i = 0; i < cy.size(); i++) {
		if (i) {
			long long sum = 0;
			for (int j = 0; j < cx.size() - 1; j++) {
				if (d[j]) sum += cx[j + 1] - cx[j];
			}
			ret += sum * (cy[i] - cy[i - 1]);
		}
		for (int j : yi[i]) {
			for (int k = ax[j]; k < bx[j]; k++) d[k]++;
		}
		for (int j : yo[i]) {
			for (int k = ax[j]; k < bx[j]; k++) d[k]--;
		}
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 2852
name=[]
point=[]
SP=[]
nameset=[]
pp=[]
key=[]

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x == value]
    
    
n=int(input())
for i in range(n):
    s,p=input().split()
    name.append(s)
    point.append(p)
    SP.append(s)
    SP.append(p)

nameset=list(set(name))
nameset.sort()

for i in range(len(nameset)):
    tmp=func1(name,nameset[i])
    for j in range(len(tmp)):
        pp.append(point[tmp[j]])
    pp=[int(s) for s in pp]
    pp.sort(reverse=True)
    pp=[str(s) for s in pp]
    for k in range(len(pp)):
        key.append(func1(point,pp[k]))
    pp=[]
    
for i in range(n):
    print(key[i][0]+1)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){

  int i,max=0,x,sum=0;

  for(i=0;i<3;i++){
    scanf("%d",&x);
    sum+=x;
    if(max < x){
      max = x;
    }
  }
  //printf("%d\n",maxi);
  printf("%d\n",sum-max);

  return 0;
}



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

int main(){
  ll k,a,b; cin >>k >>a >>b;
  if(b-a<=2 || k<=a){
    cout << k+1 << endl;
    return 0;
  }
  ll ans = a;
  ll t = k-a+1;
  if(t%2!=0) ans++;
  cout << ans+t/2*(b-a) << endl;
  return 0; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){   
    string str;
    cin >> str;
    int ans = 0, big = 0;
    for(int i = 0; i < 3; i++){
    	if(str[i] == 'R'){
    		big++;
    	}
    	else{
    		ans = max(ans, big);
    		big = 0;
    	}
    }

    ans = max(ans, big);

    cout << ans;
}

Measured memory_bytes: 3620
N, K = map(int, input().split())
D = list(map(str, input().split()))

for i in range(N, 100000):
    j = str(i)
    more = False
    for k in D:
        if j.count(k) > 0:
            more = True
            break
    if not more:
        ans = i
        break

print(ans)

Measured memory_bytes: 41324
#include<bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
#define PI 3.141592653589793
int  A,B,C,D;
long long N;



  int main()
{
  long long T;
  long long a=360,b,x,r,ans;
  cin>>T;
  b=T;
  if(360%T==0)T=360/T;
  else{
  
    r = a % b;
    x = a*b;

    while(r!=0){
      a = b;
      b = r;
      r = a % b;
    }
    ans=x/b;
    ans/=T;
    T=ans;
  }
  cout<<T;
  return 0;
}



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

int main(){
  string S,T;
  cin >> S >> T;
  int counter=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      counter+=1;
    }
  }
  cout << counter <<endl;
}


Measured memory_bytes: 3916
n, k = map(int, input().split())
num_list=list(map(int,input().split()))
flag = False
num = n
while flag == False:
	str_num = str(num)
	flag = True
	for ban_num in num_list:
		if str(ban_num) in str_num:
			num = num + 1
			flag = False
			break
print(num)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int but1 = sc.nextInt();
		int but2 = sc.nextInt();
		
		int ans = 0;
		if(but1 >= but2) {
			ans += but1;
			but1--;
		} else {
			ans += but2;
			but2--;
		}
		if(but1 >= but2) {
			ans += but1;
			but1--;
		} else {
			ans += but2;
			but2--;
		}
		
		System.out.println(ans);
	}
	
}

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

int main() {
  int n,a;
  cin >> n;
  a = n/100;
  if(a*100+a*10+a >= n){
    cout << a*100+a*10+a << endl;
  }
  else{
    cout << (a+1)*100+(a+1)*10+(a+1) << endl;
  }
}

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

int main(){
    int a,b,c,x;
    int sum=0;
    cin >> a>> b>> c >>x;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<b+1;j++){
            for(int k=0;k<c+1;k++){
                if((500*i+100*j+50*k)==x){
                    sum++;
                }
            }
        }
    }
    cout << sum <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                           \
    do {                                                    \
        std::ostringstream os;                              \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";   \
        __print__(os, ", ", "\n", __VA_ARGS__);             \
        std::cerr << os.str();                              \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

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

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

using namespace std;

signed main() {
    string s;
    while (cin >> s) {
        ll n = s.size();
        ll ans = n * (n + 1) / 2;
        int cnt[26] = {};
        rep(i, n) {
            ++cnt[s[i] - 'a'];
        }
        rep(i, 26) {
            int x = cnt[i];
            ans -= x * (x + 1) / 2;
        }
        cout << ans + 1 << endl;
    }
}


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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<P> > v(N-1);
  vector<int> a(N-1);
  rep(i, N-1) {
    for (int j = 1; j <= N-i-1; j++) {
      v[i].pb(mp(j, j+i+1));
    }
    a[i] = v[i].size();
  }
  // rep(i, N-1)
  //   cout << a[i] << endl;
  for (int i = 1; i < N-1; i++) {
    rep(j, v[i].size()) {
      if (v[i][j]._1 <= X && v[i][j]._2 >= Y) {
        a[i-(Y-X-1)]++;
        a[i]--;
      }
      else if (abs(v[i][j]._1-X)+abs(v[i][j]._2-Y)<i) {
        a[abs(v[i][j]._1-X)+abs(v[i][j]._2-Y)]++;
        a[i]--;
      }
    }
  }
  rep(i, N-1)
    cout << a[i] << endl;
}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz = 2e5+5;
ll mod=1e9+7;

// ll ncr(ll n,ll k)
// {
//     ll res=0;
//     for(int i=0;i<k;i++)
//     {
//     }
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    t=1;
    // cin>>t;
    //sieve();
    // ll pw[1000006];
    // pw[0]=1;
    // for(int i=1;i<1000006;i++)
    // {
    //     pw[i] = (pw[i-1]%mod*2ll)%mod;
    // }
    // cout<<pw[2]<<endl;
    for(int cs=1;cs<=t;cs++)
    {
        
        ll n;
        cin>>n;
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
            ll x;
            cin>>x;
            ans += ((i&1)&&(x&1));
        }

        cout<<ans;
        
        
 
    }
    return 0;
} 

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool same(vector<int> &a, vector<int> &b){
	for(int i = 0; i < a.size(); i++)
		if(a[i] != b[i])
			return false;
	return true;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector<int> a(n), b(n);
	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
	
	
	int s1 = -1, s2 = -1;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++)
		v[i] = i + 1;
	
	int pos = -1;
	do{
		pos++;
		if(same(v, a))
			s1 = pos;
		if(same(v, b))
			s2 = pos;
		
		
	}while(next_permutation(v.begin(), v.end()));
	
	
	cout << abs(s1 - s2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 500000
void merge(int[],int,int,int);
void mergeSort(int[],int,int,int);
int count;
int main(){
  int a,A[N],i;
  count=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,a,0,a);
  for(i=0;i<a-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
}
void merge(int *A,int left,int mid,int right){
  int i,j,x;
  int inf=1000000000;
  int n1=mid-left;
  int n2=right-mid;
  int L[n1],R[n2];
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=R[n2]=inf;
  i=0;
  j=0;
  for(x=left;x<right;x++){
    count++;
    if(L[i]<=R[j]){
      A[x]=L[i];
      i=i+1;
    }
    else{
      A[x]=R[j];
      j=j+1;
    }
  }
}
void mergeSort(int *A,int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 5668