akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<sstream>
#include<cstdlib>
#include<cassert>
#define MAX 1000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
using namespace std;
typedef pair<int,int> P;
int h,w;
int G[MAX][MAX];
int A[MAX][2];// 0->r, 1->c
P B[MAX][2];
int C[MAX][2];
int D[MAX][2];
 
P Bsearch(int a,int b)
{
  int Size = (b == 0?h:w);
  for(int i=0;i<Size;i++)
    {
      if(b == 0)
    {
      if(G[i][a] == -inf)return P(a,i);
    }
      else
    {
      if(G[a][i] == -inf)return P(i,a);
    }
    }
}
 
int main()
{
  int blank = false;
  while(true)
    {
      cin >> h;
      if(!h)break;
      cin >> w;
      rep(i,MAX)rep(j,2)A[i][j] = C[i][j] = 0,B[i][j] = P(-inf,-inf);
 
      vector<P> ans;
      int hatena = 0;
      rep(i,h)
    {
      rep(j,w)
        {
          string input;
          cin >> input;
          if(input[0] == '?')
        {
          G[i][j] = -inf;   
          A[j][0]++;
          B[j][0] = P(j,i);
          A[i][1]++;
          B[i][1] = P(j,i);
          ans.push_back(P(j,i));
        }
          else
        {
          G[i][j] = (atoi)(input.c_str());
          C[j][0] += G[i][j];
          C[i][1] += G[i][j];
        }
        }
      cin >> D[i][1];
    }
      rep(i,w+1)
    cin >> D[i][0];
     

      bool Fin = true;
      bool found = false;
 
      while(true)
    {
      Fin = true;
      found = false;
      rep(i,w)
        {
          if(A[i][0] >= 1)Fin = false;
          if(A[i][0] == 1)
        {
          //cout << "erase! " << B[i][0].first << "," << B[i][0].second << endl;
          found = true; 
          int value = D[i][0]-C[i][0];
          P p = Bsearch(i,0);
           C[p.first][0]+=value;
          C[p.second][1]+=value;
           A[p.first][0]--;
          A[p.second][1]--;
          assert( G[p.second][p.first] == -inf);
          G[p.second][p.first] = value;
        }
        }
      rep(i,h)
        {
          if(A[i][1] >= 1)Fin = false;
          if(A[i][1] == 1)
        {
          //cout << "erase! " << B[i][1].first << "," << B[i][1].second << endl;
          found = true; 
          int value = D[i][1]-C[i][1];
          P p = Bsearch(i,1);
           C[p.first][0]+=value;
          C[p.second][1]+=value;
           A[p.first][0]--;
          A[p.second][1]--;
          assert(G[p.second][p.first] == -inf);
          G[p.second][p.first] = value;
        }
        }
 
      if(!Fin && !found)
        break;
      if(Fin)break;
 
    }
      if(!blank)blank = true;
      else cout << endl;
      if(!Fin && !found)
        cout << "NO" << endl;
      else
        {
          rep(i,ans.size())
        cout << G[ans[i].second][ans[i].first] << endl;
 
         
        }
    }
  return 0;
}

Measured memory_bytes: 1640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		int i = 0;
		int j = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int H = Integer.parseInt(input[0]);
			int W = Integer.parseInt(input[1]);

			if( H==0 & W==0 ) break;

			for( i=0 ; i<H ; i++ ){
				for( j=0 ; j<W ; j++ ){
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 36148
#include<cstdio>
#include<vector>
using namespace std;

const int N_MAX = 1e5;
int n, m;
char s[N_MAX + 1];
vector<int> len, ans;

int main() {
    scanf("%d %d", &n, &m);
    scanf("%s", s);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == s[i + 1]) cnt++;
        else {
            len.push_back(cnt);
            cnt = 0;
        }
    }
    len.push_back(cnt);

    for (int i = len.size() - 1; i >= 0; i -= 2) {
        for (int j = 0; j < len[i] / m; j++) ans.push_back(m);
        len[i] = len[i] % m;
        if (i == 0) {
            if (len[i] > 0) ans.push_back(len[i]);
            break;
        }
        if (len[i] + len[i - 1] + 2 > m) {
            if (len[i] > 0) ans.push_back(len[i]);
            len[i] = 0;
        }
        for (int j = 0, s = 0;; j++) {
            if (i - 2 * j != 0 && (s + len[i - 2 * j] + len[i - 2 * j - 1] + 1 < m)) {
                s += len[i - 2 * j] + len[i - 2 * j - 1] + 2;
            }
            else if (j == 0) {
                printf("-1\n");
                return 0;
            }
            else {
                if (s + len[i - 2 * j] < m) {
                    ans.push_back(s + len[i - 2 * j]);
                    len[i - 2 * j] = 0;
                }
                else {
                    ans.push_back(m);
                    len[i - 2 * j] = s + len[i - 2 * j] - m;
                }
                i -= 2 * (j - 1);
                break;
            }
        }
    }

    for (int i = ans.size() - 1; i >= 0; i--) printf("%d ", ans[i]);
    printf("\n");
    return 0;
}


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

k, n = (int(v) for v in input().split())
a = [int(v) for v in input().split()]

d = []
for i in range(len(a) - 1):
    d.append(a[i + 1] - a[i])
d.append(k - a[-1] + a[0])
m = max(d)
print(k - m)


Measured memory_bytes: 24948
S = input()
T = input()
lenS = len(S)
lenT = len(T)
ans = "UNRESTORABLE"
for i in range(lenS-lenT,-1,-1):
    subS = S[i:i+lenT]
    for j in range(lenT):
        if subS[j] != T[j] and subS[j] != "?":
            break
    else:
        ans = S[:i]+T+S[i+lenT:]
        ans = ans.replace("?","a")
        break

print(ans)

Measured memory_bytes: 38256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int k;
    string s;
    cin >> k >> s;

    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

th = sum(A) / (4 * M)
flag = True
for i in range(M):
    if A[i] < th:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    string s;
    string ans="";
    cin >> s;
    for(LL i=0; i<s.size(); i++){
        if(s[i]=='0'){
            ans.push_back('0');
        }else if(s[i]=='1'){
            ans.push_back('1');
        }else{
            if(ans.size()!=0){
                ans.pop_back();
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define gc getchar()
inline int read(){
	register int x(0);register char c(gc);
	while(c>'9'||c<'0')c=gc;
	while(c>='0'&&c<='9')x=x*10+c-48,c=gc;
	return x;
}
#define reset(a) memset((a),0,sizeof(a))
const int N=410000;
struct node{
	int val;
	int ID;
	int revID;
}a[N];
int b[N];
bool cmp(node x,node y){
	return x.val<y.val;
}
int in[N],cnt;
struct edge{
	int to,next;
}e[N*30];
int head[N],tot,HEAD[N];
void add(int x,int y){
//	cout<<x<<' '<<y<<'\n';
	e[++tot].next=head[x];e[tot].to=y;head[x]=tot;
	e[++tot].next=HEAD[y];e[tot].to=x;HEAD[y]=tot;
}
#define ls id<<1
#define rs id<<1|1
#define mid ((l+r)>>1)
void build(int l,int r,int id){
	if(l==r){
		in[id]=b[l];
		return;
	}
	build(l,mid,ls);
	build(mid+1,r,rs);
	in[id]=++cnt;
	add(in[id],in[ls]);
	add(in[id],in[rs]);
}
void IN(int l,int r,int x,int y,int to,int id){
	if(l>=x&&r<=y){
		add(to,in[id]);
		return;
	}
	if(x<=mid)IN(l,mid,x,y,to,ls);
	if(y>mid)IN(mid+1,r,x,y,to,rs);
}
#undef mid
int vis[N],turn[N],CNT,bl[N],n;
void clean(){
	reset(vis);reset(turn);reset(bl);CNT=tot=0;cnt=2*n;
	reset(head);reset(HEAD);reset(in);
}
void dfs1(int u){
	vis[u]=1;
	int i;
	for(i=head[u];i;i=e[i].next)
		if(!vis[e[i].to])dfs1(e[i].to);
	turn[++CNT]=u;
}
void dfs2(int u){
	bl[u]=CNT;
	for(int i=HEAD[u];i;i=e[i].next)
		if(!bl[e[i].to])dfs2(e[i].to);
}
void kosaraju(){
	register int i;
	for(i=1;i<=cnt;i++)
		if(!vis[i])dfs1(i);
	CNT=0;
	for(i=cnt;i>=1;i--)if(!bl[turn[i]]){
		CNT++;
		dfs2(turn[i]);
	}
}
int ans;
bool check(int now){
//	cout<<now<<'\n';
	clean();
	build(1,2*n,1);
	register int i;
	for(i=1;i<=n;i++)
		add(a[i].ID,n+a[i].revID),add(a[i].ID+n,a[i].revID);
	for(i=1;i<=n;i++){
		int l=1,r=i-1,L=i,R=i;
		while(l<=r){
			int mid=(l+r)>>1;
			if(a[i].val-a[mid].val<now)r=mid-1,L=mid;
			else l=mid+1;
		}
		l=i+1,r=n;
		while(l<=r){
			int mid=(l+r)>>1;
			if(a[mid].val-a[i].val<now)l=mid+1,R=mid;
			else r=mid-1;
		}
		if(L!=i)
			IN(1,2*n,L,i-1,a[i].ID,1);
		if(R!=i)
			IN(1,2*n,i+1,R,a[i].ID,1);
	}
	kosaraju();
	for(i=1;i<=n;i++)
		if(bl[a[i].ID]==bl[a[i].revID]||bl[a[i].ID]==bl[a[i].ID+n])return 0;
	return 1;
}
int main(){
	//freopen("T3.in","r",stdin);
	//freopen("T3.out","w",stdout);
	n=read();
	register int i;
	for(i=1;i<=n;i++){
		a[i*2-1].val=read();a[i*2].val=read();
		a[i*2-1].ID=i*2-1;a[i*2-1].revID=i*2;
		a[i*2].ID=i*2;a[i*2].revID=i*2-1;	
	}
	n*=2;
	cnt=2*n;	
	sort(a+1,a+1+n,cmp);
	for(i=1;i<=n;i++)
		b[i]=a[i].revID,b[i+n]=b[i]+n;
	int l=0,r=1e9;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	cout<<ans;
}

Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  ll ans=-1,v=1;
  rep(i,n){
    v=a.at(v-1);
    if(v==2){
      cout << i+1;
      return 0;
    }
  }
  cout << ans;
}
  
    

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

void printString(ll n) 
{ 
	ll MAX = 1000;
    char str[MAX]; 
    ll i = 0;  
    while (n > 0) { 
        ll rem = n % 26; 
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else 
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    reverse(str, str + strlen(str)); 
    cout << str << endl; 
  
    return; 
} 

int main(){
	ll n;
	cin>>n;
	printString(n);
	
	return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

char S[101], c;
char T[]={'k','e','y','e','n','c','e'};
int s, l, r;

int main(){
	while((c=getchar()) != 10){
		S[s++] = c;
	}
	while(S[l]==T[l]){
		l++;
		if(l>=s){break;}
	}
	s--;
	while(S[s-r]==T[6-r]){
		r++;
		if(l+r>=s){break;}
	}
	if(l+r>=7){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,m;
long long num;
int Max;
int Maxn=30;
int main()
{
    cin>>num;
    for(int i=sqrt(num);i>=1;i--)
    {
        if(num%i==0)
        {
            int ans1=0;
            int ans2=0;
            int x=num/i;
            int y=i;
            while(x)
            {
                x/=10;
                ans1++;
            }
            while(y)
            {
                y/=10;
                ans2++;
            }
            Max=max(ans1,ans2);
            Maxn=min(Max,Maxn);
        }
    }
    cout<<Maxn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int>data(n);
  for (int i=0;i<n;i++){
  cin >>data.at(i);
  }
  sort(data.begin(),data.end());
  long long c=0;
  for (int i=n-1;i>=2;--i) {
    for (int j=i-1;j>=1;j--){
    	for (int k=j-1;k>=0;k--){
  if (data.at(i)<data.at(j)+data.at(k)){
        c+=1;
        }
        }
    }
  }
  cout <<c<<endl;
}
     

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int a[10],i,n,s;
int summing(int n,int s){
    int ans=0,i,max=0,min=0,m;
    if(n==1){if(s<10 && a[s]==1)return 1; else return 0;}
    else{
        for(i=0,m=n;m>0 && i<10;i++){if(a[i]==1){min+=m*i;m--;}}
        for(i=9,m=n;m>0 && i>=0;i--){if(a[i]==1){max+=m*i;m--;}}
        if(s<min || max<s)return 0;
        //for(i=0;i<10;i++){printf("%d",a[i]);}
        for(i=0;i<10;i++){
            if(a[i]==1 && n*i<=s){
                /*if(n==2){
                    m=s-i*2;
                    if(m>=0 && m<10 && i!=m && a[m]==1)ans++;
                }
                else*/{
                    a[i]=0;
                    ans+=summing(n-1,s-n*i);
                    a[i]=1;
                }
            }
        }
        //printf("%d,%d\n",n,ans);
        return ans;
    }
}
int main(void){
    for(i=0;i<10;i++)a[i]=1;
    while(scanf("%d %d",&n,&s)!=EOF){printf("%d\n",summing(n,s));}
    return 0;
}

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

using namespace std;

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

    int B[M];

    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
    }

    int input, cell, ans = 0;
    for (int r = 0; r < N; r++)
    {
        cell = 0;
        for (int c = 0; c < M; c++)
        {
            cin >> input;
            cell += input * B[c];
        }

        if (cell + C > 0)
        {
            ans++;
        }
    }

    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n,m;cin>>n>>m;
  char a[n][n];
  char b[m][m];
  rep(i,n){
    rep(j,n){
      cin >> a[i][j];
    }
  }
  rep(i,m){
    rep(j,m){
      cin >> b[i][j];
    }
  }
  
  for(int i = 0; n-m+1 > i; i++){
    for(int j = 0; n-m+1 > j; j++){
      bool br  =false;
      for(int k = 0; m > k; k++){
        for(int l = 0; m > l; l++){
          //cout << b[k][l] << " " << a[k+i][l+j] << endl;
          if(b[k][l] != a[k+i][l+j]){
            br = true;
            break;
          }
        }
        //cout << i << " " << j << " " << br << endl;
        if(br)break;
      }
      //cout << i << " " << j  << " " << br << endl;
      if(!br){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, a[109], dp[109];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int z = 0;
	for(int i = 0; i < n; i++) {
		int ptr = min_element(a + i, a + n) - a;
		if(i != ptr) swap(a[i], a[ptr]), z++;
	}
	for(int i = 0; i < n; i++) {
		if(i) cout << ' ';
		cout << a[i];
	}
	cout << endl;
	cout << z << endl;
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 25;
constexpr int MOD = 1000000007;

int main() {
  int n, q;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];
  cin >> q;
  vector<int> T(q);
  REP(i, n) cin >> T[i];
  
  int cnt = 0;
  REP(i, q) {
    if (binary_search(ALL(S), T[i])) ++cnt;
  }

  cout << cnt << endl;
}



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

void trace(int a[],int n){
  int i;
  for(int i = 0; i < n; i++){
    if(i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

void insertionsort(int a[], int n){
  int v,j;
  for(int i = 0; i < n; i++){
    v = a[i];
    j = i -1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    trace(a,n);
  }
}

int main(void){
  int n; cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  insertionsort(a,n);
  return 0;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int func(int n){
    int cnt = 0;
    while(n){
        if(n%2 == 0){
            cnt++;
            n /= 2;
        }
        else{
            break;
        }
    }
    return cnt;
}
int main(){

    int n;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    int cnt = 0;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int tmp = func(i);
        if(cnt < tmp){
            cnt = tmp;
            ans = i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while(1){
	int n,m,t,p;//n:wide m:height
	cin>>n>>m>>t>>p;
	if(n==0)break;
	vector<vector<int> > s(2*m,vector<int>(2*n,0));
	for(int i=0;i<m;i++)for(int j=0;j<n;j++)s[i][j] = 1;
	//cout<<"OK"<<endl;
	//for(int i=0;i<2*m;i++){
	  //  for(int j=0;j<2*n;j++){
	//	cout<<s[i][j]<<' ';
	  //  }
	    //cout<<endl;
	//}
	for(int i=0;i<t;i++){
	    vector<vector<int> > s2(2*m,vector<int>(2*n,0) );
	    int d,c;
	    cin>>d>>c;
	    int w = 0,h = 0;
	    if(d==1){
		w = c;
		for(int i=0;i<2*m;i++)for(int j=0;j<c;j++) s[i][j+c] += s[i][c-1-j];
	    }else{
		h = c;
		for(int i=0;i<c;i++)for(int j=0;j<2*n;j++) s[i+c][j] += s[c-1-i][j];
	    }
	    for(int i=h;i<2*m;i++)for(int j=w;j<2*n;j++)s2[i-h][j-w] = s[i][j];
	    //cout<<i<<endl;
	    //for(int i=0;i<2*m;i++){
		//for(int j=0;j<2*n;j++)cout<<s2[i][j]<<' ';
		//cout<<endl;
	    //}
	    s = s2;
	}
	for(int i=0;i<p;i++){
	    int x,y;
	    cin>>x>>y;
	    cout<<s[y][x]<<endl;
	}

    }
    return 0;
}



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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	int tall = 0;
	for (int i = 0; i < n; i++) {
		ans += max(0, tall - a[i]);
		tall = max(tall, a[i]);
	}
	cout << ans;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 

void DEBUG_ARR(vt<T> a)
{
	f(i,0,a.size())cout<<a[i]<<" ";
	cout<<"\n";
}
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}
lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK

int main() 
{ 
  fastio;
  lli x,y;
  cin>>x>>y;
  if((x+y)%3!=0)cout<<0<<"\n";
  else{
      lli p=(2*y-x)/3,q=(2*x-y)/3;
      if(p<0 || q<0)cout<<0<<"\n";
      else{
        lli fact[p+q+1]={1};
        f(i,1,p+q+1)fact[i]=(fact[i-1]*i)%mod;
        lli ans=fact[p+q];
        ans=tmod(ans*power(fact[p],mod-2),mod);
        ans=tmod(ans*power(fact[q],mod-2),mod);
        cout<<ans<<"\n";
      }
  }
  return 0; 	
}


Measured memory_bytes: 5504
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans = 0
Asum = [0 for _ in range(N)]
Asum[0] = A[0]%(10**9+7) 
for i in range(1,N):
  Asum[i] = (Asum[i-1] + A[i])%(10**9+7)
for i in range(N-1):
  ans += (A[i]*(Asum[N-1] - Asum[i]))%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 49568
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int binary_search(int key, int left, vector<ll>& l){
    int ng = left; 
    int ok = (int)l.size(); 

    //ok と ng のどちらが大きいかわからないことを考慮
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;

        if (l[mid] >= key) ok = mid;
        else ng = mid;
    }
    return ok;
}
void solve(){
    ll n; cin >> n;
    vector<ll> l(n);
    REP(i, n) cin >> l[i];
    sort(ALL(l));
    int cnt = 0;
    for(int i=0; i<=n-3; i++){
        for(int j=i+1; j<=n-2; j++){
            //cout << binary_search(l[i]+l[j], j, l) << endl;
            cnt += binary_search(l[i]+l[j], j, l) - j - 1;
        }
    }
    cout << cnt << endl;
}

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

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    int idx = 0;
    vector<int> b(n);
    for (int i = (n % 2 == 1 ? n - 1 : n - 2); 0 <= i; i -= 2)
        b[idx++] = a[i];
    for (int i = 1; i < n; i += 2)
        b[idx++] = a[i];

    if (n % 2 == 0) {
        for (int i = n - 1; 0 <= i; --i)
            cout << b[i] << " \n"[i == 0];
    }
    else {
        for (int i = 0; i < n; ++i)
            cout << b[i] << " \n"[i == n - 1];
    }

    return 0;
}


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

int a[10], hd;
int main(void){
	int n;
	for(;;){
		scanf("%d", &n);
		if(n == -1)break;
		hd = 0;
		for(;n;n/=4)a[hd++] = n % 4;
		if(hd == 0)puts("0");
		else{
			for(;hd--;)printf("%d", a[hd]);
			puts("");
		}
	}
}

Measured memory_bytes: 3156
void main() {
    string[] tmp = readln.split('/');
    string y = "2018", m = tmp[1], d = tmp[2];
    writeln(y, '/', m, '/', d);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


bigint combi(int a, int b) {
	//aCb
	bigint ans = 1;
	rep(i, b)ans *= a - i;
	rep(i, b)ans /= i + 1;
	return ans;
}

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

	int N, A, B;
	cin >> N >> A >> B;
	vector<int>v(N);
	rep(i, N)cin >> v[i];
	sort(ALL(v), greater<int>());

	if (v[0] == v[A - 1]) {
		double ans = v[0];
		int vnum = 0;
		rep(i, N)if (v[i] == v[0])vnum++;
		bigint pattern = 0;
		for (int i = A; i <= B && v[i - 1] == v[0]; i++) {
			pattern += combi(vnum, i);
		}
		cout << setprecision(20) << ans << endl << pattern.convert_to<int>() << endl;
	}
	else {
		double ans = 0;
		rep(i, A)ans += v[i];
		ans /= A;
		int vnum = 0, vselect = 0;
		rep(i, N)if (v[i] == v[A - 1])vnum++;
		rep(i, A)if (v[i] == v[A - 1])vselect++;
		bigint pattern = combi(vnum, vselect);

		cout << setprecision(20) << ans << endl << pattern.convert_to<int>() << endl;
	}




	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S;
int n;
int main(){
	cin>>n;

	int B[27];
	for(int i=0;i<27;i++){
		B[i]=100;
	}
	for(int i=0;i<n;i++){
		cin>>S;
		int A[27]={};
		int L=S.size();
		for(int j=0;j<L;j++){
			int C=S[j]-97;
			A[C]++;
		}
		for(int j=0;j<27;j++){
			B[j]=min(A[j],B[j]);

		}
	}

	for(int i=0;i<27;i++){
		int k=i+97;
		char chr=k;
		for(int j=0;j<B[i];j++){
			cout<<chr;
		}
	}

	cout<<endl;

    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> v_sc(m);
  for (auto &p : v_sc) {
    cin >> p.first >> p.second;
    p.first--;
  }

  int min_n = n == 1 ? 0 : pow(10, n - 1), max_n = pow(10, n) - 1;
  int ans = -1;
  for (int i = min_n; i <= max_n; i++) {
    string si = to_string(i);
    bool matches = all_of(v_sc.begin(), v_sc.end(), [&](auto &p) {
      return p.first < si.size() && p.second == si[p.first];
    });

    if (matches) {
      ans = ans == -1 ? i : min(ans, i);
    }
  }

  cout << ans << '\n';

  return 0;
}

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

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        while (true)
        {
        	String[] nx = br.readLine().split(" ");
            int n = Integer.parseInt(nx[0]);
            int x = Integer.parseInt(nx[1]);
            if(n == 0 && x == 0)
            	break;
            
            int count = 0;
            for (int i = 1; i <= n - 2; i++)
            {
            	for (int j = i + 1; j <= n -1; j++)
            	{
            		for (int k = j + 1; k <= n; k++)
            		{
            			if ((i + j + k) == x)
            				count++;
            		}
            	}
            }
            System.out.println(count);
        }
        
		
	}

}

Measured memory_bytes: 25136
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 51;
ll INF = 1e19 + 10;

int k, n;
ll x[MAXN], y[MAXN];

ll calc(int a, int b, int c, int d) {
  ll xmin = min(x[a], min(x[b], min(x[c], x[d])));
  ll xmax = max(x[a], max(x[b], max(x[c], x[d])));
  ll ymin = min(y[a], min(y[b], min(y[c], y[d])));
  ll ymax = max(y[a], max(y[b], max(y[c], y[d])));
  int cnt = 0;
  for (int i=0;i<n;i++) {
    if (xmin <= x[i] && x[i] <= xmax && ymin <= y[i] && y[i] <= ymax) {
      cnt++;
    }
  }
  if (cnt >= k) {
    return (xmax - xmin) * (ymax - ymin);
  }
  return INF;
}

void solve() {
  ll ans = INF;
  for (int a=0;a<n;a++) {
    for (int b=0;b<n;b++) {
      for (int c=0;c<n;c++) {
        for (int d=0;d<n;d++) {
          ans = min(ans, calc(a, b, c, d));
        }
      }
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int N, H, W; cin >> N >> H >> W;
    int cnt_H = 0, cnt_W = 0;
    for (int i = 1; i <= N; i++) if (i + (H - 1) <= N) cnt_H++;
    for (int i = 1; i <= N; i++) if (i + (W - 1) <= N) cnt_W++;
    printf("%d\n", cnt_H * cnt_W);
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s; cin >> s;
    bool res = true;
    if (s[2] != s[3]) res = false;
    if (s[4] != s[5]) res = false;
    cout << (res?"Yes":"No") << endl;
}


Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-05 13:15:40
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

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

  int pos = -1;
  for (int i = 0; i < n; ++i) {
    if (h[i] > 0) {
      pos = i; break;
    }
  }

  for (int cx = 0; cx <= 100; ++cx) {
    for (int cy = 0; cy <= 100; ++cy) {
      int H = h[pos] + abs(x[pos] - cx) + abs(y[pos] - cy);
      bool flag = true;
      for (int i = 0; i < n; ++i) {
        if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) flag = false;
      }
      if (flag) {
        cout << cx << " " << cy << " " << H << endl; return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> l1(n), l2(n);
    rep(i, n){
        cin >> l1[i];
        l2[i] = abs(l1[i] - x);
    }
    sort(l2.rbegin(), l2.rend());
    vector<ll> l3;
    for(ll i = 1; i*i <= l2[0]; ++i){
        if(l2[0]%i == 0){
            l3.push_back(i);
            if(i*i != l2[0]) l3.push_back(l2[0]/i);
        }
    }
    sort(l3.rbegin(), l3.rend());

    ll ans = 1;
    bool z = true;
    rep(i, l3.size()){
        z = true;
        rep(j, n){
            if(l2[j]%l3[i] != 0){
                z = false;
                break;
            }
        }
        if(z){
            ans = max(ans, l3[i]);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#define INF 1000000001

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int h[n]; for (int i = 0; i < n; i++) cin >> h[i];
    int dp[n]; for (int i = 0; i < n; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < 3; j++) {
            if (i + j < n) dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

struct UnionFind {
    vector<ll> size, parents;
    UnionFind() {}
    UnionFind(ll n) {
        size.resize(n, 0);
        parents.resize(n, 0);
        for (ll i = 0; i < n; i++) {
            make(i);
        }
    }
    void make(ll x) {
        parents[x] = x;
        size[x] = 1;
    }
    bool same(ll x, ll y) { return root(x) == root(y); }
    bool union_(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int root(ll x) {
        if (x != parents[x]) {
            parents[x] = root(parents[x]);
        }
        return parents[x];
    }
    ll size_(ll x) { return size[root(x)]; }
};

int main() {
    string s;
    cin >> s;
    if (s == "SSS") {
        puts("0");
        return 0;
    }
    if (s == "RRR") {
        puts("3");
        return 0;
    }
    if (s[0] == 'R' && s[1] == 'R') {
        puts("2");
        return 0;
    }
    if (s[1] == 'R' && s[2] == 'R') {
        puts("2");
        return 0;
    }
    puts("1");
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
int n,mx,tot,head[110],nxt[500010];
ll f[110],valx[500010],valy[500010];
void add(int u,ll x,ll y){
	nxt[++tot]=head[u];
	valx[tot]=x;
	valy[tot]=y;
	head[u]=tot;
	return;
}
void init(){
	memset(head,-1,sizeof(head));
	f[0]=1;
	f[1]=1;
	for(mx=2;f[mx-1]<=1e18;mx++)
		f[mx]=f[mx-1]+f[mx-2];
	mx--;
	add(1,1,2);
	add(1,1,3);
	add(1,1,4);
	for(int i=2;i<=mx-2;i++){
		for(int j=head[i-1];~j;j=nxt[j]){
			ll x=valx[j],y=valy[j];
			for(x+=y;x<=f[i+2];x+=y)
				add(i,y,x);
		}
	}
	return;
}
void solve(ll X,ll Y){
	if(X>Y)
		swap(X,Y);
	int d,ans=0;
	for(d=1;f[d+1]<=X&&f[d+2]<=Y;d++);
	printf("%d ",d);
	d--;
	if(!d){
		printf("%d\n",X*Y%mod);
		return;
	}
	for(int i=head[d];~i;i=nxt[i]){
		ll x=valx[i],y=valy[i];
		if(X>=y)
			ans=(ans+(Y-x)/y)%mod;
		if(Y>=y)
			ans=(ans+(X-x)/y)%mod;
	}
	printf("%d\n",ans);
}
int main(){
	init();
	scanf("%d",&n);
	while(n--){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		solve(x,y);
	}
	return 0;
}

Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

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

//		System.setIn(new FileInputStream("D:\\Workspace\\SW\\src\\b\\tt"));
//		long start = System.currentTimeMillis();

		// strat
		// B - ID
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int M = Integer.parseInt(st.nextToken());

		int[] P = new int[N + 1];
		int[][] arr = new int[M + 1][4];// 0 保存原值P，1保存原值Y， 2排序， 3州内顺序

		for (int i = 1; i <= M; i++) {
			st = new StringTokenizer(br.readLine());
			int p = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());

			arr[i][0] = p;
			arr[i][1] = y;
			arr[i][2] = i;
		}

		Comparator<int[]> c = new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return o1[1] - o2[1];
			}
		};
		Arrays.sort(arr, c);

		for (int i = 1; i <= M; i++) {
			arr[i][3] = ++P[arr[i][0]];
		}

		Comparator<int[]> c1 = new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return o1[2] - o2[2];
			}
		};
		Arrays.sort(arr, c1);

		for (int i = 1; i <= M; i++) {
			System.out.format("%06d%06d\n", arr[i][0], arr[i][3]);
		}

		// end
//		long end = System.currentTimeMillis();
//		System.out.format("%.3f (s)", (end-start)/1000.0);
	}

}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n;
    cin>>n;
    cout << (n-3 + 1) * 180 << endl;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcoder_b_086
{
    class _02
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[0] + str[1]);

            for(int i = 1; i < c; i++)
            {
                if( (i*i) == c)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine(a.ToString("No"));

        }

    }
}


Measured memory_bytes: 11092
#include <cmath>
#include <iostream>
using namespace std;
int a, b, d, X, Y, x, y;

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

void change_ans(){
  if(abs(x) + abs(y) < X + Y){
    X = abs(x);
    Y = abs(y);
  }else if(abs(x) + abs(y) == X + Y && a*abs(x) + b*abs(y) < a*abs(X) + b*abs(Y)){
    X = abs(x);
    Y = abs(y);
  }
}



int main(){
  while(cin >> a >> b >> d, a){
    int g = extgcd(a,b,x,y), r = d/g;
    x *= r; y *= r;
    a /= g;
    b /= g;
    X = abs(x);
    Y = abs(y);
    if(x <= 0){
      int x_ = (b - (-x)%b)%b;
      int t = (x_ - x) / b;
      y -= t*a;
      x = x_;
      change_ans();
      x -= b;
      y += a;
      change_ans();
      x += b;
      y -= a;
    }
    if(y <= 0){
      int y_ = (a - (-y)%a)%a;
      int t = (y_ - y) / a;
      x -= t*b;
      y = y_;
      change_ans();
      x += b;
      y -= a;
      change_ans();
      x -= b;
      y += a;
    }
    if(x >= 0){
      int x_ = x%b;
      int t = x / b;
      y += t*a;
      x = x_;
      change_ans();
      x -= b;
      y += a;
      change_ans();
      x += b;
      y -= a;
    }
    if(y >= 0){
      int y_ = y%a;
      int t = y / a;
      x += t*b;
      y = y_;
      change_ans();
      x += b;
      y -= a;
      change_ans();
      x -= b;
      y += a;
    }
    cout << X << " " << Y << endl;
  }
  return 0;
}

Measured memory_bytes: 3008
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int N, H, W, B;
	cin >> H;
	cin >> W;
	cin >> N;

	B = 0;
	int i;
	for (i = 0; B < N; i++)
	{
		if (W > H)
		{
			B += W;
		}
		else
		{
			B += H;
		}
	}
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;char c;
	while(cin>>a>>c>>b){
		if(c=='+'){
			cout<<a+b<<endl;
		}else if(c=='-'){
			cout<<a-b<<endl;
		}else if(c=='*'){
			cout<<a*b<<endl;
		}else if(c=='/'){
			cout<<a/b<<endl;
		}else break;
	}
	return 0;
}


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

int main()
{
	int k;
  	cin>>k;
  	if((k%2)==0)
    {
      cout<<-1<<endl;
      return 0;
    }
  	if((k%7)==0)k/=7;
    int a=(9*k);
    int count=1;
    for(int i=2;((long long)i*i)<=a;i++)
    {
		if((a%i)==0)
        {
          int c=0;
          while(a%i==0)
          {
            c++;
            a/=i;
          }
          count*=(c+1);
        }
      	
    }
    if(a>1)count*=2;
  	count--;
  int p=10;
  a=(9*k);
  int ans=-1;
  int lim=(9*k)-count;
  for(int i=1;i<=lim;i++)
  {
    if((p%a)==1)
    {
      ans=i;
      break;
    }
   	p=(p*10)%a;
  }
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
/******************************\
*  Everyone has a different way of thinking, so God Created us
   Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Mo_Murad   *
\******************************/
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define SZ(c) int(c.size())
#define ff first
#define ss second
#define INF INT32_MAX
#define _INF INT32_MIN
#define PQ priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	LL c;
	while (a != 0) {
		c = a;
		a = b % a;
		b = c;
	}
	return b;
}
int LCM(int a, int b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
			n /= i;
		}
	}
	if (n > 2)printf("%d ", n);
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
void dijjkstra(int src, int n) {
	list<ipair>adj[1000005];
	vector<bool>visited(1000005, false);
	vector<int>dis(1000005, 1e9);
	PQ<ipair, vector<ipair>, greater<ipair>>pq;
	pq.push(MP(0, 1));
	dis[src] = 0;
	while (!pq.empty())
	{
		int u = pq.top().ss;
		visited[u] = true;
		pq.pop();
		list<ipair>::iterator i;
		for (i = adj[u].begin(); i != adj[u].end(); i++)
		{
			int v = i->ff;
			int we = i->ss;
			if (!visited[v] && dis[v] > dis[u] + we)
			{
				dis[v] = dis[u] + we;
				pq.push(MP(dis[v], v));
			}
		}
	}
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n, m;
	cin >> n;
	cin >> m;
	int *a=new int[n + 1];
	for (int i = 0; i <= n; i++)
		a[i] = 0;
	int l, r;
	for (int i = 0; i<m; i++) {
		cin >> l >> r;
		a[l]++;
		a[r + 1]--;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		a[i] += a[i - 1];
		if (a[i] == m)ans++;
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a_l = list(map(int,input().split()))
b_l = []
for i, num in enumerate(a_l):
    b_l.append((num,i+1))
b_l.sort()
ans = ''
for num, i in b_l:
    ans += str(i)+' '
print(ans[:-1])

Measured memory_bytes: 20068
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int ans;
  if(b%a==0) ans = a+b;
  else ans = b-a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int cnt = (N - 1) / X + 1;
    int ans = cnt * T;
    cout << ans << endl;
}


Measured memory_bytes: 3632