akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, M;
   cin >> N >> M;
   string A[N];
   string B[M];
   for (int i = 0; i < N; i++) cin >> A[i];
   for (int i = 0; i < M; i++) cin >> B[i];

   for (int i = 0; i < N - M + 1; i++) {
      for (int j = 0; j < N - M + 1; j++) {
         bool flg = true;
         for (int k = 0; k < M; k++) {
            string tmp = A[j + k].substr(i, M);
            // cout << k << " " << tmp << endl;
            if (tmp != B[k]) {
               flg = false;
               continue;
            }
         }
         if (flg) {
            cout << "Yes" << endl;
            return 0;
         }
      }
   }
   cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2005;
int T,n,m,a[maxn<<1][maxn<<1],now;
int b[maxn<<1][maxn<<1],c[maxn<<1][maxn<<1],d[maxn<<1][maxn<<1];
bool vis[maxn][maxn];
inline int read(){
    int res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
inline bool check(int ux,int uy,int fx,int fy){
    if(ux==fx&&uy==fy) return false;
    if(ux<1||ux>n||uy<1||uy>m) return false;
    if(vis[ux][uy]||a[ux][uy]==0) return false;
    return true;
}
inline void dfs(int ux,int uy,int fx,int fy){
    vis[ux][uy]=true;
    if(fx&&fy) b[ux+fx][uy+fy]=1;
    if(check(ux+1,uy,fx,fy)) dfs(ux+1,uy,ux,uy);
    if(check(ux-1,uy,fx,fy)) dfs(ux-1,uy,ux,uy);
    if(check(ux,uy+1,fx,fy)) dfs(ux,uy+1,ux,uy);
    if(check(ux,uy-1,fx,fy)) dfs(ux,uy-1,ux,uy);
}
int main(){
    n=read(),m=read(),T=read();
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            char ch=getchar();
            while(ch!='0'&&ch!='1') ch=getchar();
            a[i][j]=ch-'0';
        }
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if(a[i][j]==1){
                if(!vis[i][j]) dfs(i,j,0,0);
                c[i<<1][j<<1]=1;
            }
        }
    }
    for (int i=1;i<=(n<<1);i++){
        for (int j=1;j<=(m<<1);j++){
            b[i][j]+=b[i][j-1];
            c[i][j]+=c[i][j-1];
        }
    }
    for (int i=1;i<=(n<<1);i++){
        for (int j=1;j<=(m<<1);j++){
            b[i][j]+=b[i-1][j];
            c[i][j]+=c[i-1][j];
        }
    }
    while(T--){
        int fx=read(),fy=read(),tx=read(),ty=read(),ans=0;
        ans+=c[tx<<1][ty<<1]-c[tx<<1][(fy<<1)-1]-c[(fx<<1)-1][ty<<1]+c[(fx<<1)-1][(fy<<1)-1];
        ans-=b[tx<<1][ty<<1]-b[tx<<1][(fy<<1)-1]-b[(fx<<1)-1][ty<<1]+b[(fx<<1)-1][(fy<<1)-1];
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 158708
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

//constexpr auto MAX = 100100;

int main()
{
	int ans = 0;
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= a; i++)
	{
		for (int j = 0; j <= b; j++)
		{
			for (int k = 0; k <= c; k++)
			{
				if ((500 * i + 100 * j + 50 * k) == x) ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int N;
int L,Q;
int X[100010];
int dp[100010][20];

int eva(int a,int b)
{
    if(a == b)return 0;
    if(dp[a - 1][0] >= b)return 1;
    int res;
    res = lower_bound(dp[a - 1],dp[a - 1] + 20,b) - dp[a - 1] - 1;
    return (1 << res) + eva(dp[a - 1][res],b);
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",&X[i]);
    scanf("%d%d",&L,&Q);
    for(int i = 0; i < N; i++)dp[i][0] = upper_bound(X,X + N,X[i] + L) - X;
    //for(int i = 0; i < N; i++)printf("%d ",dp[i][0]);printf("\n");

    for(int i = N - 1; i >= 0; i--)
    {
        for(int j = 1; j < 20; j++)
        {
            dp[i][j] = dp[dp[i][j - 1] - 1][j - 1];
        }
    }
    for(int i = 0; i < Q; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        if(a > b)swap(a,b);
        printf("%d\n",eva(a,b));
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 3;
int a[N], f[N], n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	f[0] = 0;
	f[1] = 0;
	f[2] = abs(a[2] - a[1]);
	for (int i = 3; i <= n; ++i)
		f[i] = min(f[i - 2] + abs(a[i - 2] - a[i]), f[i - 1] + abs(a[i - 1] - a[i]));
	printf("%d", f[n]);
	return 0;
}


Measured memory_bytes: 1024
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (true) {
				Double d = Double.parseDouble(br.readLine());
				if (Math.signum(d)<0) break;
				Integer i = d.intValue();
				d -= i;
				int face[] = new int[8];
				int shade[] = new int[4];

				for (int j=0;j<8;j++) {
					if (i%2==0) face[7-j] = 0;
					else face[7-j] = 1;
					i >>= 1;
				}
				if (i>0) {
					System.out.println("NA");
					continue;
				}

				Double dd;
				for (int j=0;j<4;j++) {
					dd = d*2;
					if (dd<1.0) shade[j] = 0;
					else shade[j] = 1;
					d = dd-dd.intValue();
				}
				if (d>0.0) {
					System.out.println("NA");
					continue;
				}

				for (int j=0;j<8;j++) {
					System.out.print(face[j]);
				}
				System.out.print(".");
				for (int j=0;j<4;j++) {
					System.out.print(shade[j]);
				}
				System.out.println();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 27368
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;
bool c(string s)
{
	string te=s;
	reverse(te.begin(), te.end());
	return te==s;
}
void solve()
{
	string s;
	cin>>s;
	ll n=s.length();
	if(c(s) && c(s.substr(0,(n-1)/2)) && c(s.substr((n+3)/2-1)))
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<ll, ll> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 100 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    long double mul = 1.0;
    long double plu = 0.0;
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        mul *= (long double)a[i];
    }
    rep(i, n) {
        plu += mul / (long double)a[i];
    }
    long double ans = mul / plu;
    cout << setprecision(16) << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    int[][] x = new int[N][N]; 
    int[][] y = new int[N][N]; 
    for(int i=0;i<N;i++){
      A[i] = sc.nextInt();
      for(int j=0;j<A[i];j++){
        x[i][j] = sc.nextInt();
        y[i][j] = sc.nextInt();
      }
    }
    int ans = 0;
    for(int i=0;i<Math.pow(2,N);i++){
      int count = 0;
      boolean check = true;
      for(int j=0;j<N;j++){
        if((1&i>>j)==1){
          count++;
          for(int k=0;k<A[j];k++){
            if(y[j][k]==1){
              if(!((1&i>>(x[j][k]-1))==1)){
                check = false;
              }
            }else{
              if(!((1&i>>(x[j][k]-1))==0)){
                check = false;
              }
            }
          }
        }
      }
      if(check){
        ans = Math.max(ans,count);
      }
    }  
      System.out.println(ans);
  }
}

Measured memory_bytes: 37540
#include<iostream>
using namespace std;
int jou(int a) {
  int k = 1;
  for (int i = 0; i < a; i ++) k *= 4;
  return k;
}
int ze(int a) {
  if (a < 0) return -a;
  else return a;
}
int main () {
  int N;
  cin >> N;
  int A, B, C;
  cin >> A >> B >> C;
  int leng[8];
  int ans = 1000000;
  for (int i = 0; i < N; i ++) cin >> leng[i];
  int kai = jou(N);
  for (int i = 0; i < kai; i ++) {
    int k = i;
    int al, bl, cl;
    al = bl = cl = 0;
    int mp = 0;
    int siyo = 0;
    for (int o = 0; o < N; o ++) {
      int j = k % 4;
      switch(j) {
        case 0: siyo ++; break;
        case 1: al += leng[o]; break;
        case 2: bl += leng[o]; break;
        case 3: cl += leng[o]; break;
      }
      k /= 4;
    }
    if (!al || !bl || !cl) continue;
    mp += ze(A - al);
    mp += ze(B - bl);
    mp += ze(C - cl);
    mp += (N - siyo - 3) * 10;
    if (mp < ans) ans = mp;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
ls = []
for i in range(3):
    a = list(map(int,input().split()))
    ls.append(a)
lb = []
n = int(input())
for i in range(n):
    b = int(input())
    lb.append(b)
    
for i in range(n):
    for j in range(3):
        for k in range(3):
            if lb[i] == ls[j][k]:
                ls[j][k] = "#"
if ls[0][0] == "#" and ls[1][0] == "#" and ls[2][0] == "#":
    print("Yes")
elif ls[0][1] == "#" and ls[1][1] == "#" and ls[2][1] == "#":
    print("Yes")
elif ls[0][2] == "#" and ls[1][2] == "#" and ls[2][2] == "#":
    print("Yes")
elif ls[0][0] == "#" and ls[0][1] == "#" and ls[0][2] == "#":
    print("Yes")
elif ls[1][0] == "#" and ls[1][1] == "#" and ls[1][2] == "#":
    print("Yes")
elif ls[2][0] == "#" and ls[2][1] == "#" and ls[2][2] == "#":
    print("Yes")
elif ls[0][0] == "#" and ls[1][1] == "#" and ls[2][2] == "#":
    print("Yes")
elif ls[0][2] == "#" and ls[1][1] == "#" and ls[2][0] == "#":
    print("Yes")
else:
    print("No")


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

int main() {
    ll N,K;
    cin >> N >> K;
    vector<pair<ll,ll>> res;
    rep(i,N) {
        ll a,b; cin >> a >> b;
        res.push_back(make_pair(a,b));
    }
    sort(res.begin(),res.end());
    ll ans;
    ll sum = 0;
    ll i = 0;
    while(i < N && K > sum) {
        sum += res.at(i).second;
        i++;
    }
    ans = res.at(i-1).first;
    cout << ans << endl;
}

Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <map>
using namespace std;
#define ll long long
struct Trie{
    Trie* child[26];
    bool end;
    int num[26];
    int wordEnd;
    int numContain;
};
Trie* getNew(){
    Trie* x = new Trie;
    for(int i=0;i<26;i++)
        x->child[i] = nullptr;
    x->end = false;
    for(int i=0;i<26;i++)
        x->num[i] = 0;
    x->wordEnd = 0;
    x->numContain = 0;
    return x;
}
void insert(Trie *head, string s){
    Trie *curr = head;
    for(int i=0;i<s.length();i++){
        if(curr->child[s[i]-'a']==nullptr)
            curr->child[s[i]-'a'] = getNew();
        curr = curr->child[s[i]-'a'];
        curr->numContain++;
    }
    curr->num[s[s.length()-1]-'a']++;
    curr->wordEnd++;
    curr->end = true;
}
void prop(Trie *head,int c){
    Trie *curr = head;
    for(int i=0;i<26;i++){
        if(curr->child[i]!=nullptr){
            prop(curr->child[i],i);
            for(int j=0;j<26;j++)
                curr->num[j]+=(curr->child[i])->num[j];
        }
    }
    if(c!=-1)
        curr->num[c]= curr->numContain;
}
int search(Trie *head, string s){
    Trie *curr = head;
    for(int i=0;i<s.length()-1;i++){
        if(curr->child[s[i]-'a']==nullptr){
            return 0;
        }
        curr = curr->child[s[i]-'a'];
        
    }
    int ans = 0;
    for(int i=0;i<26;i++){
        if(curr->child[i]!=nullptr)
            ans+=(curr->child[i])->num[s[s.length()-1]-'a'];
    }
    return ans;
    
}
int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++){
        string x; cin >> x;
        string y;
        for(int j=0;j<x.length();j++)
            y+=x[x.length()-j-1];
        s[i] = y;
    }
    Trie *root = getNew();
    for(int i=0;i<n;i++){
        insert(root,s[i]);
    }
    prop(root,-1);
    ll ans = 0;
    for(int i=0; i<n;i++){
        ans+=(ll)search(root,s[i]);
    }
    ans-=n;
    cout << ans << endl;

}



Measured memory_bytes: 389528
import collections
n = int(input())
one = collections.deque([1])
two = collections.deque([])
three = collections.deque([])
graph = [[] for _ in range(n)]

for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
    if i % 3 == 0: two.append(i + 2)
    elif i % 3 == 1: three.append(i + 2)
    else: one.append(i + 2)

que = collections.deque([0])
num = [0] * n
dist = [-1] * n
parity = [0] * 2
dist[0] = 0
flag = True
while len(que) != 0:
    i = que.popleft()
    parity[dist[i] % 2] += 1
    for j in graph[i]:
        if dist[j] != -1: continue
        dist[j] = dist[i] + 1
        que.append(j)

if parity[0] <= n // 3 or parity[1] <= n // 3:
    rem = 0 if parity[0] < parity[1] else 1
    for i, v in enumerate(dist):
        if v % 2 == rem:
            num[i] = str(three.popleft())
        else:
            if len(one) != 0: num[i] = str(one.popleft())
            elif len(two) != 0: num[i] = str(two.popleft())
            else: num[i] = str(three.popleft())
else:
    for i, v in enumerate(dist):
        if v % 2 == 0:
            if len(one) != 0: num[i] = str(one.popleft())
            elif len(three) != 0: num[i] = str(three.popleft())
            else:
                flag = False
                break
        else:
            if len(two) != 0: num[i] = str(two.popleft())
            elif len(three) != 0: num[i] = str(three.popleft())
            else:
                flag = False
                break

print(' '.join(num))


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

int main() {
 int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(r <= x && r <= y && x <= W-r && y <= H-r){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()


using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;
using ii = pair<int,ll>;

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




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

const double EPS = 1e-9;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int N = 2e6 + 5;
const ll CONSTANT = 9e18 + 7;

int a[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;

    for(int i = 0; i < n; ++i)cin >> a[i];
    map<int,int> mp;
    bool isCoPrime = true;
    int gcd = 0;
    for(int i = 0; i < n; ++i){
        gcd = __gcd(gcd,a[i]);
        //error(gcd);
        for(int j = 2; j*j <= a[i]; ++j){
            bool in = false;
            while(a[i] % j == 0){
                a[i] /= j;
                in = true;
            }
            if(in){
                    if(mp.count(j) > 0){
                        isCoPrime = false;
                    }
                    mp[j] = 1;
            }
        }
        if(a[i] > 1){

            if(mp.count(a[i]))
                isCoPrime = false;

            mp[a[i]] = 1;


        }
    }
    if(isCoPrime){
        cout << "pairwise coprime\n";
    }else{
        if(gcd == 1){
            cout << "setwise coprime\n";
        }else{
            cout << "not coprime\n";
        }
    }
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;

static const int M = 1046527;  //?´???°????????¶
static const int Q = 1901;
static const int MAX_OP_LEN = 7; //?????????????????????
static const int MAX_STR_LEN = 13; //?????????????????????

char H[M][MAX_STR_LEN];
int c_collision = 0;

int convert_str(char *str);
int h(int key);
int g(int key);
void linerProving_insert(int num, char* str); //?????¢??°??????
int linerProving_find(int num, char* str); //?????¢??°??????
void doubleHashing_insert(int num, char* str); //?????????????????\???
int doubleHashing_find(int num, char* str); //?????????????????\???

int main(){
	int n, num;
	char op[MAX_OP_LEN], word[MAX_STR_LEN];

	//???????????\????????????????????????
	memset(H, '\0', sizeof(H));

	cin >> n;
	while (n > 0) {
		scanf("%s%s", op, word);

		num = convert_str(word);

		if (op[0] == 'i') {
			doubleHashing_insert(num, word);
//			cout << "collision = " << c_collision << endl;
		}
		else {
			if (doubleHashing_find(num, word))
				printf("yes\n");
			else
				printf("no\n");
		}
		n--;
	}

//	cout << "collision = " << c_collision << endl;
	return 0;
}

int convert_str(char *str) {
	int num, p;
	//??????????????°????????????
	num = 0;
	p = 1;
	for (int i = 0; str[i] != '\0' && i < MAX_STR_LEN; i++) {
		switch (str[i]) {
		case 'A' :
			num += 1 * p;
			break;
		case 'C' :
			num += 2 * p;
			break;
		case 'G' :
			num += 3 * p;
			break;
		case 'T' :
			num += 4 * p;
			break;
		}
		p *= 5;
	}
	return num;
}

int h(int key) {
	return key % M;
}

int g(int key) {
	return Q - (h(key) % Q) + 1;
}

//?????????????????\???
void doubleHashing_insert(int num, char* str){
	int idx, j;

	for (j = 0; j < M; j++) {
		idx = (h(num) + j * g(num)) % M;

		//?????§?????????????????????????????°???????????????????????????
		if ( strncmp(str, H[idx], MAX_STR_LEN) == 0 )
			return;
		else if (strlen(H[idx]) == 0)
			break;
//		c_collision++;
	}
	strcpy(H[idx], str);
}

//?????????????????\???
int doubleHashing_find(int num, char* str){
	int idx, j;

	for (j = 0; j < M; j++) {
		idx = (h(num) + j * g(num)) % M;

		// printf("idx = %d\n", idx);
		// cout << str << endl;
		// cout << H[idx] << endl;
		if ( strncmp(str, H[idx], MAX_STR_LEN) == 0 )
			return 1;
		else if (strlen(H[idx]) == 0)
			return 0;
	}
	return 0;
}

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

using namespace std;

int main(void) {
  
  long long N, M;
  cin >> N >> M;
  vector<long long> H(N);
  for (long long i=0; i<N; i++) {
    cin >> H.at(i);
  }

  vector<set<long long>> nxt(N, set<long long> {});

  for (long long i=0; i<M; i++) {
    long long A, B;
    cin >> A >> B;
    nxt.at(A-1).insert(B-1);
    nxt.at(B-1).insert(A-1);
  }

  long long count = 0;
  for (long long i=0; i<N; i++) {
    bool good = true;
    for (auto j : nxt.at(i)) {
      if (H.at(j) >= H.at(i)) {
        good = false;
        break;
      }   
    }
    if (good == true) {
      count++;
    }
  }

  cout << count << endl;

}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout<<(b%a?b-a:a+b)<<"\n";
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class BlackAndWhite
    {
        public static int Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if(input == "0") { break; }

                var board = new char[3, 3];
                for(int i = 0; i < 3; i++)
                {
                    if (i > 0) { input = Console.ReadLine(); }
                    for(int j = 0; j < 3; j++) { board[i, j] = input[j]; }
                }

                // ?¨?
                string winner = "NA";
                for (int i = 0; i < 3; i++)
                {
                    char chk = board[i, 0];
                    if (chk == 'w' || chk == 'b')
                    {
                        if (board[i, 1] == chk && board[i, 2] == chk) { winner = chk.ToString(); }
                    }
                }
                // ???
                if (winner == "NA")
                {
                    for(int i = 0; i < 3; i++)
                    {
                        char chk = board[0, i];
                        if (chk == 'w' || chk == 'b')
                        {
                            if (board[1, i] == chk && board[2, i] == chk) { winner = chk.ToString(); }
                        }
                    }
                }
                // ??????
                if (winner == "NA")
                {
                    char chk = board[1, 1];
                    if (chk == 'w' || chk == 'b')
                    {
                        if (board[0, 0] == chk && board[2, 2] == chk) { winner = chk.ToString(); }
                        if (board[0, 2] == chk && board[2, 0] == chk) { winner = chk.ToString(); }
                    }
                }

                Console.WriteLine(winner);
            }
            return 0;
        }
    }
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<int> A(M), B(M);
        vector<vector<int>> E(N);
        rep(i, M) {
            int a, b; cin >> a >> b;
            a--; b--;
            E[a].push_back(b);
            E[b].push_back(a);
        }
        repeat(i, 1, N - 1) {
            bool s = false, e = false;
            for(int a : E[i]) {
                if(a == 0) s = true;
                if (a == N - 1) e = true;                
            }
            if(s and e) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        cout << "IMPOSSIBLE" << endl;
       
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 13552
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  ll n;  cin >> n;
  ll ans=1;
  n++;
  vector<ll> fact(n, 0);
  rep(i, 2, n){
    int tmp = i;
    rep(j, 2, i+1){
      while(tmp%j==0) {
        fact[j]++;
        tmp/=j;
      }
    }
  }
  rep(i, 0, n){
    if(fact[i]!=0){
      ans*=(fact[i]+1);
      ans%=MAX;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
coin = int(input())
siawase = 0
if coin >= 500:
    siawase = siawase + int(coin / 500) * 1000
    amari = coin % 500
    siawase = siawase + int(amari / 5) *5
elif coin >= 5:
    siawase = siawase + int(coin / 5) * 5
    
print(int(siawase))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	string s;
	cin >> s;
	if (s[s.length() - 1] == 's') {
		s += "es";
	} else {
		s += 's';
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 3648
import sys
N = int(input())
H = list(map(int, input().split()))
ans = []
count = 0
if N == 1:
    print(0)
    sys.exit()
for i in range(N-1):
    if H[i] < H[i+1]:
        count = 0
    else:
        count += 1
    ans.append(count)
print(max(ans))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll         long long
#define mod        1000000007
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define inf        1e18
#define ps(x,y)    fixed<<setprecision(y)<<x

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll k, n;
	cin >> k >> n;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	ll ans = LLONG_MIN;
	for (int i = 0; i < n; ++i)
	{	if (i == n - 1)
			ans = max(k - a[i] + a[0], ans);
		else
			ans = max(a[i + 1] - a[i], ans);
	}
	cout << k - ans;

}

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

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

    int ans = 0;

    vector<int> h(n);

    rep(0,n) cin >> h[i];

    int b = 0;

    rep(0,n){
        ans += max(0,h[i] - b);
        b = h[i];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 1e5+5;

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

template <class T> bool isPrime(T x) {
	for (T d = 2; d * d <= x; d++) { if (x % d == 0) return false; }
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	string ans, s, t;
	cin >> n;
	cin >> s >> t;
	for (int i = 0; i < n; ++i) {
		ans.push_back(s[i]); ans.push_back(t[i]);
	}

	cout << ans << '\n';
}
		

Measured memory_bytes: 3648
x1,x2,x3,x4,x5 = map(int,input().split())

if x1 == 0:
  print("1")
elif x2 == 0:
  print("2")
elif x3 == 0:
  print("3")
elif x4 == 0:
  print("4")
elif x5 == 0:
  print("5")

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

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    int ans=0;
    for (int i=0; i<n-1; i++) {
        for (int k=i+1; k<n; k++) {
            ans += d[i] * d[k];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

sum = 0

for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a == b == c:
                sum += gcd(a,b,c)
            elif a == b or b == c:
                sum += gcd(a,b,c) * 3
            else:
                sum += gcd(a,b,c) * 6
print(sum)


Measured memory_bytes: 75336
import java.util.*;
import java.io.*;

class Date implements Comparable<Date> {

    final int year;
    final int month;
    final int day;

    Date( final int year, final int month, final int day ) {
	this.year = year;
	this.month = month;
	this.day = day;
    }

    public int compareTo( Date d ) {
	if ( year != d.year ) {
	    return Double.compare( year, d.year );
	} else if ( month != d.month ) {
	    return Double.compare( month, d.month );
	} else {
	    return Double.compare( day, d.day );
	}
    }    
}

class Main {

    public static void main( String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final Date[] change = { new Date( 1868, 9, 8 ), new Date( 1912, 7, 30 ),
				new Date( 1926, 12,25 ), new Date( 1989, 1, 8 ) };
	
	final String[] name = { "pre-meiji", "meiji", "taisho", "showa", "heisei" };
	
	while ( stdin.hasNextInt() ) {
	    final int year = stdin.nextInt();
	    final int month = stdin.nextInt();
	    final int day = stdin.nextInt();
	    final Date date = new Date( year, month, day );

	    int index = 0;
	    while ( index < change.length && date.compareTo( change[ index ] ) >= 0 ) {
		index++;
	    }
	    
	    if ( index == 0 ) {
		System.out.println( "pre-meiji" );
	    } else {
		final int yearNengo = date.year - change[ index - 1 ].year + 1;
		System.out.printf( "%s %d %d %d\n", name[ index ], yearNengo, month, day );
	    }
	}	
    }
    
}

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

int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		int count = 0;
		for (int i = 1; i <= 1000; i++)
		{
			int sum = i;
			int j = i + 1;
			while (sum + j< n)
			{
				sum += j;
				j++;
			}
			if (sum + j == n)count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define sbit __builtin_popcountll
vector< pii > adj[51];
ll dp1[21],dp2[1<<21];

inline int dfs(int u,int p,int a,int q)
{
    if(u==a) return 1;
    for(int i=0;i<sz(adj[u]);i++){
        int v=adj[u][i].ff,x=adj[u][i].ss;
        if(v==p) continue;
        if(dfs(v,u,a,q)==1){
            dp1[q]|=(1LL<<x);
            return 1;
        }
    }
    return 0;
}

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a;
    while(b!=0){
        if(b&1) ans=(ans*temp);
        temp=(temp*temp);
        b=b>>1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v; cin>>u>>v;
        u--; v--;
        adj[u].pb({v,i});
        adj[v].pb({u,i});
    }
    int q; cin>>q;
    for(int i=0;i<q;i++){
        int u,v; cin>>u>>v;
        u--; v--;
        dfs(u,u,v,i);
    }
    ll ans=0;
    for(int i=1;i<(1<<q);i++){
        int x=log2(i);
        dp2[i]=dp1[x]|dp2[(1<<x)^i];
        int a=sbit(i),b=sbit(dp2[i]);
        ll temp=binex(2,n-1-b);
        if(a%2==0) ans-=temp;
        else ans+=temp;
    }
    ans=binex(2,n-1)-ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
using namespace std;

typedef long long LL;

int main(){
	const short SLIM = 20000;
	const LL LLIM = 1LL << 60;

	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<LL> psum(n + 1);
	for(int i = 1; i <= n; ++i){
		LL a;
		cin >> a;
		psum[i] = psum[i - 1] + a;
	}

	vector<vector<pair<LL,short>>> vals(n + 1);
	vector<vector<tuple<short,short,short>>> dp(n + 1);
	for(int i = 0; i <= n; ++i){
		auto &v = vals[i];
		v.reserve(n - i + 1);
		v.emplace_back(LLIM, -1);
		for(int j = i + 1; j <= n; ++j){
			v.emplace_back(psum[j] - psum[i], j);
		}
		sort(v.begin(), v.end());
		dp[i].assign(v.size(), make_tuple(-SLIM, -1, -1));
	}
	dp[0][0] = make_tuple(0, -1, -1);
	for(int i = 0; i <= n; ++i){
		int sz = vals[i].size();
		for(int j = 0; j < sz; ++j){
			if(j > 0){ dp[i][j] = max(dp[i][j], dp[i][j - 1]); }
			if(get<0>(dp[i][j]) < 0){ continue; }
			int k = vals[i][j].second;
			if(k >= 0){
				int l = upper_bound(vals[k].begin(), vals[k].end(), make_pair(vals[i][j].first, SLIM)) - vals[k].begin();
				tuple<short,short,short> tp(get<0>(dp[i][j]) + 1, i, j);
				dp[k][l] = max(dp[k][l], tp);
			}
		}
	}
	
	vector<int> ans;
	int pos = n, h = dp[n].size() - 1;
	while(true){
		auto t = dp[pos][h];
		pos = get<1>(t);
		h = get<2>(t);
		if(pos <= 0){ break; }
		ans.push_back(pos);
	}
	reverse(ans.begin(), ans.end());
	cout << (ans.size() + 1) << '\n';
	bool fst = true;
	for(int x : ans){
		if(!fst){ cout << ' '; }
		cout << x;
		fst = false;
	}
	cout << '\n';
}



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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    int a[n];
    ffor(i,0,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=0;
    ffor(i,2,n)
    {
        ffor(j,0,i-1)
        {
            ans+=i-(ub(a+j+1,a+i,a[i]-a[j])-a);
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

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

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

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

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

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

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

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

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

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

func main() {
	sc := NewScanner()
	R, G := sc.nextInt(), sc.nextInt()
	ans := 2*G - R
	fmt.Println(ans)
}


Measured memory_bytes: 640
h,w=map(int,input().split())
s=["."*(w+2)]+["."+input()+"." for _ in range(h)]+["."*(w+2)]
for i in range(1,h+2):
	for j in range(1,w+2):
		if s[i][j]=="#":
			if "#" not in (s[i-1][j],s[i+1][j],s[i][j-1],s[i][j+1]):
				print("No");exit()
			else:pass
		else:pass
print("Yes")

Measured memory_bytes: 3064
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 10000000071000000
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
	//////////////////////////////////
	stack []byte
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}

type zahyo struct {
	x int
	y int
}

func main() {
	s := gostring()
	check := true
	for i:= 2;i < len(s);i++{
		if s[i] == s[i-1] || s[i] == s[i-2] || s[i-1] == s[i-2] {
			fmt.Println(i-1,i+1)
			check = false
			break
		}
	}
	if s[0] == s[1] && check{
		fmt.Println(1,2)
	} else if check {
		fmt.Println(-1,-1)
	}
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

Measured memory_bytes: 1280
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

li perm(li n,li r){
  li ans=1;
  rep(i,r){
    (ans*=n-i)%=MOD;
  }
  return ans;
}

int main(){
  int n,m; cin >>n >>m;
  m-=n;
  vector<li> dpm(n+1,0);
  dpm[0]=1;
  dpm[1]=m;
  rep(i,n-1){
    li tmp=(dpm[i]+dpm[i+1])%MOD;
    (tmp*=i+1)%=MOD;
    (tmp+=m*dpm[i+1]%MOD)%=MOD;
    dpm[i+2]=tmp;
  }


  print(dpm[n]*perm(n+m,n)%MOD);
}


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

// 0 ~ A の xor を計算
long xorSum( long A )
{
    long ans = 0;
    // i bit目の 1 の個数を調べる
    for( int i = 0; i <= 40; ++i ){
        long period = (1L << (i+1));
        long num1 = (A+1)/period * period/2;  // 0 ~ A なので A+1 になることに注意
        num1 += max( 0L, (A+1)%period - period/2 );
        ans += ( num1%2 == 1 )? (1L << i): 0;
    }
    return ans;
}

// ( 2n ^ 2n+1 ) = 1 になることを用いた解法
long xorSum2( long A )
{
    long num1 = (A+1)/2;
    long ans = num1 % 2;
    if( A%2 == 0 ) ans ^= A;
    return ans;
}


int main()
{
    long A, B;
    cin >> A >> B;

    cout << ( xorSum2(A-1) ^ xorSum2(B) )  << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a;
  a.reserve(N);
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp - 1);
  }

  vector<bool> flag(N);
  int index = 0;
  int count = 0;
  while (true) {
    if (index == 1) {
      break;
    }
    if (flag[index]) {
      count = -1;
      break;
    }

    flag[index] = true;
    index = a[index];
    ++count;
  }

  cout << count << endl;
  return 0;
}


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

int main(){
  
  string a,b; 

  cin>>a>>b;

  int n,m;
  n = a.size();
  m = b.size();

  int cnt, ans=1000;

  rep(i, n-m+1){
    cnt =0;
    rep(j , m){
      if(a[i+j]!=b[j]) cnt++;
    }
    if(ans>cnt) ans = cnt;

  }
  cout<<ans;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;



void solve(){
    int n;
    cin>>n;
    n *= n;
    cout<<n;
}


int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_35_Marblue_And_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
int a,b,c;
int l[8];

int I_Love_35_Marblue_And_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	int ans=inf;
	cin>>n>>a>>b>>c;
	FOR(i,0,n)cin>>l[i];
	FOR(m1,1,(1<<n))FOR(m2,1,(1<<n))if((m1&m2)==0)FOR(m3,1,(1<<n))if((m1&m3)==0&&(m2&m3)==0){
		int x,y,z;
		x=y=z=0;
		FOR(i,0,n){
			if(m1&(1<<i))x+=l[i];
			if(m2&(1<<i))y+=l[i];
			if(m3&(1<<i))z+=l[i];
		}
		Umin(ans,__builtin_popcount(m1)*10+__builtin_popcount(m2)*10+__builtin_popcount(m3)*10-3*10+abs(a-x)+abs(y-b)+abs(z-c));
	}
	Tone(ans)
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


ll nextLong() { ll x; scanf("%lld", &x); return x;}


using D = long double;
const D PI = acos(-1.0);
const D EPS = 1e-10;
struct P {
  D x, y;
  P(D x=0, D y=0) : x(x), y(y) {}

  P& operator+=(const P& o) { x += o.x; y += o.y; return *this; }
  P& operator-=(const P& o) { x -= o.x; y -= o.y; return *this; }
  P& operator*=(const P& o) { return *this = {x*o.x - y*o.y, x*o.y + y*o.x}; }
  P& operator*=(const D& r) { x *= r; y *= r; return *this; }
  P& operator/=(const D& r) { x /= r; y /= r; return *this; }
  P operator-() const { return {-x, -y}; }

  D norm() const { return x*x + y*y; }
  D abs() const { return sqrt(norm()); }
  D arg() const { return atan2(y, x); }
  bool isZero() const { return std::abs(x) < EPS && std::abs(y) < EPS; }
  /** 象限 */
  int orth() const { return y >= 0 ? (x >= 0 ? 1 : 2) : (x < 0 ? 3 : 4); }
  static P polar(const D& rho, const D& theta = 0) { return {rho * cos(theta), rho * sin(theta)}; }
};
std::ostream &operator<<(std::ostream &os, P const &p) { return os << "(" << p.x << ", " << p.y << ")"; }
std::istream &operator>>(std::istream &is, P &p) { D a, b; is >> a >> b; p = P(a, b); return is; }
P operator+(const P& p, const P& q) { return P(p) += q; }
P operator-(const P& p, const P& q) { return P(p) -= q; }
P operator*(const P& p, const P& q) { return P(p) *= q; }
P operator*(const P& p, const D& r) { return P(p) *= r; }
P operator/(const P& p, const D& r) { return P(p) /= r; }
P operator*(const D& r, const P& p) { return P(p) *= r; }
P operator/(const D& r, const P& p) { return P(p) /= r; }
D crs(const P& a, const P& b){ return a.x*b.y - a.y*b.x; }
D dot(const P& a, const P& b){ return a.x*b.x + a.y*b.y; }
int signum(D x) {return x > EPS ? +1 : x < -EPS ? -1 : 0;}
// 辞書順ソート
bool operator<(const P& a, const P& b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}


int main2() {
  int X = nextLong();

  P p(0, 0);
  P v(1, 0);

  int ans = 0;
  for (;;) {
    // cout << p << endl;
    p = p + v;
    v = v * P::polar(1.0, X/180.0 * PI);
    ans++;
    if (p.norm() < EPS)
      break;
  }
  cout << ans << endl;
  return 0;
}

int main() {

  // for (int i = 1; i <= 179; i++)
    // main2(i);
  // return 0;

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3928