akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,-1,sizeof(i));
#define pb push_back
const ll mod=998244353;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	while(cin >> n){
		vector<ll>pl,mi;
		vector<pair<ll,ll> >ans;
		f(n){
			ll add;
			cin >> add;
			if(add>=0)pl.pb(add);
			else mi.pb(add);
		}
		sort(pl.begin(),pl.end());
		sort(mi.begin(),mi.end());
		reverse(mi.begin(),mi.end());
		if(pl.size()&&mi.size()){
			ll now1 = mi[0],now2=pl[0];
			for(int i=1;i<(int)mi.size();i++){
				//cout<<now2<<' '<<mi[i]<<'\n';
				ans.pb({now2,mi[i]});
				now2 -= mi[i];
			}
			for(int i=1;i<(int)pl.size();i++){
				//cout<<now1<<' '<<pl[i]<<'\n';
				ans.pb({now1,pl[i]});
				now1 -= pl[i];
			}
			//cout<<now2<<' '<<now1<<endl;
			ans.pb({now2,now1});
			cout<<now2-now1<<endl;
		}
		else if(pl.size()){
			ll now1=pl[0];
			for(int i=1;i<pl.size()-1;i++){
				//cout<<now1<<' '<<pl[i]<<'\n';
				ans.pb({now1,pl[i]});
				now1 -= pl[i];
			}
			//cout<<pl.back()<<' '<<now1<<endl;
			ans.pb({pl.back(),now1});
			cout<<pl.back()-now1<<endl;
		}
		else{
			ll now1=mi[0];
			for(int i=1;i<mi.size();i++){
				//cout<<now1<<' '<<mi[i]<<'\n';
				ans.pb({now1,mi[i]});
				now1 -= mi[i];
			}
			cout<<now1<<endl;
		}
		for(auto i:ans){
			cout<<i.first<<' '<<i.second<<'\n';
		}
	}
}

Measured memory_bytes: 5104
#include<iostream>
using namespace std;
char toupr(char c) {
  return (c - 0x20);
}
main(){
	string x,y,z;
  	cin>> x>>y>>z;
  	cout<<toupr(x[0])<<toupr(y[0])<<toupr(z[0])<<endl;
  	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import math
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]
num = list(range(n))
su = 0
for i in permutations(num):
  for j in range(n-1):
    a = i[j]
    b = i[j+1]
    su += ((l[a][0]-l[b][0])**2+(l[a][1]-l[b][1])**2)**0.5
print(su/math.factorial(n))

Measured memory_bytes: 3064
def main():
    n = int(input())
    if n%2 == 1:
        print(0)
    else:
        ans = 0
        for i in range(1,19):
            ans += n//10**i
        for i in range(1,51):
            ans += n//(10*(5**i)) - n//(10*(5**i)*(2**i))
        print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const M = parseInt(args[0][1], 10)
	const a = new Array(N + 2).fill(true)
	const dp = new Array(N + 2).fill(0)

	args.slice(1, M + 1).forEach(arg => {
		a[parseInt(arg[0], 10)] = false
	})

	dp[0] = 1

	for (let i = 0; i < N; i++) {
		for (let j = 1; j <= 2; j++) {
			if (a[i + j]) {
				dp[i + j] += dp[i]
				dp[i + j] = dp[i + j] % 1000000007
			}
		} 
	}

	console.log(dp[N])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main () {
  int A, B, C, D, R, L;
  cin >> A >> B >> C >> D;
  string answer;
  L = A + B;
  R = C + D;
  if (L > R) {
    answer = "Left";
  }
  if (L == R) {
    answer = "Balanced";
  }
  if (L < R) {
    answer = "Right";
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int i,j,k;
        int[][][] x = new int[4][3][10];
        
		for(i = 0; i < a; i++){
			int b = sc.nextInt() - 1;
			int c = sc.nextInt() - 1;
			int d = sc.nextInt() - 1;
            int e = sc.nextInt();
            
            x[b][c][d] = x[b][c][d] + e;
		}

		for(i = 0; i < 4; i++){
			for(j = 0; j < 3; j++){
				for(k = 0; k < 10; k++){
					System.out.print(" " + x[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3) System.out.printf("####################\n");
		}

	}
}



Measured memory_bytes: 30152
def is_prime(n):
    result = True
    i = 2
    while i * i <= n:
        if n % i == 0:
            result = False
            break
        i += 1
    if n == 1:
        result = False
    return result


def main():
    q = int(input())
    max_num = 10 ** 5
    count_num = [0 for _ in range(max_num + 1)]
    is_prime_num = [False for _ in range(max_num + 1)]
    count_num[3] = 1
    is_prime_num[3] = True
    for i in range(4, max_num + 1):
        count_num[i] = count_num[i - 1]
        if i % 2:
            if is_prime(i):
                is_prime_num[i] = True
                count_num[i] = count_num[i - 1]
                if is_prime_num[(i + 1) // 2]:
                    count_num[i] += 1
    for _ in range(q):
        l, r = map(int, input().split())
        print(count_num[r] - count_num[l - 1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int sz = h*w;
	vector<int> karte;
	for( int i = 1; i <= n; ++i ){
		int temp;
		cin >> temp;
		for( int j = 0; j < temp; ++j ){
			karte.push_back(i);
		}
	}
	for( int i = 0; i < h; ++i ){
		vector<int> lis;
		for( int j = 0; j < w; ++j ){
			lis.push_back(karte.at(i*w + j));
		}
		if( i % 2 == 1 ){
			reverse( lis.begin(), lis.end() );
		}
		for( int j = 0; j < w; ++j ){
			cout << lis.at(j);
			if( j != w-1 ) cout << ' '; 
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
const int mod = (119<<23)+1;
const int M = 1e9+7;
const int N = 1e5+5;

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

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << fixed << setprecision(15);
	
	int a, b; cin >> a >> b;
	print(a/gcd(a, b)*b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vis[20];
int a[10];
int n,k,x;
bool check(int x)
{
    int len=0;
    while (x) {
        a[++len]=x%10;
        x/=10;
    }
    for (int i=1;i<=len;i++)
        if (vis[a[i]]) return false;
    return true;
}
int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<=k;i++) {
        scanf("%d",&x);
        vis[x]=true;
    }
    while (true) {
        if (check(n)) break;
        n++;
    }
    printf("%d\n",n);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}


int main(){
    int n;
    cin>>n;
    double x;
    string u;
    double ans=0;
    for( int i=0;i<n;++i){
        cin>>x>>u;
        if(u=="BTC")x*=380000.0;
        ans+=x;
    }
    cout<<ans<<endl;
}

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

int gcd(int a, int b) {
	if (a < b)
		return gcd(b, a);
	else if (b != 0)
		return gcd(b, a % b);
	else 
		return a;
}

int main (void) {
	cin.tie(0);
	cin.sync_with_stdio(false);
	int a, b, k;
	cin >> a >> b >> k;
	int aa = gcd(a, b), times = 0;
	for (int i = aa; i >= 1; i --) {
		if (aa % i == 0)
			times ++;
		if (times == k) {
			cout << i;
			break;
		}

	}
	return 0;
}

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

using namespace std;

#define int long long

constexpr int INF = 1LL << 60;

constexpr int MAX_L = 4005;

typedef pair<int, int> pii;

string s[2];
int alpha[2][MAX_L][30];

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

    cin >> s[0] >> s[1];
    if (s[1].size() <= s[0].size())
    {
        swap(s[0], s[1]);
    }

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < s[i].size(); j++)
        {
            alpha[i][j + 1][s[i][j] - 'a']++;
            for (int k = 0; k < 26; k++)
            {
                alpha[i][j + 2][k] += alpha[i][j + 1][k];
            }
        }
    }

    for (int len = s[0].size(); 0 < len; len--)
    {
        set<array<int, 26>> aset;
        for (int l = 0; l <= s[1].size() - len; l++)
        {
            auto r = l + len;
            array<int, 26> ar;
            for (int i = 0; i < 26; i++)
            {
                ar[i] = alpha[1][r][i] - alpha[1][l][i];
            }
            aset.insert(ar);
        }

        for (int l = 0; l <= s[0].size() - len; l++)
        {
            auto r = l + len;
            array<int, 26> ar;
            for (int i = 0; i < 26; i++)
            {
                ar[i] = alpha[0][r][i] - alpha[0][l][i];
            }
            if (aset.find(ar) != aset.end())
            {
                cout << len << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}



Measured memory_bytes: 5888
import heapq

N, M = map(int, input().split())

#仕事の制約の厳しい順にリストに格納する
Blist = [[] for _ in range(M)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M: # AがMより大きいといつやっても間に合わない
        Blist[A-1].append(-B) # heapqを使うことを考慮して「-」倍しておく

ans = 0
q = [] # heapq.heapify(q)でリストのヒープ化ができるがここではlen(q)を使いたいためにしないでおく

# 可能な仕事をqに入れて扱う。その中でもBが最大(「-」倍しているのでここでは最小)のものを優先して取り出す。
for i in range(M):
    for b in Blist[i]: # ヒープ化されたリストqに2次元のBlistのi番目のリストの要素を全て入れる
        heapq.heappush(q, b)
    if len(q) > 0: # qに要素があるならば、qから最小の要素を取り出して(「-」倍してあるので)それを引き算する
        ans -= heapq.heappop(q)

print(ans)



Measured memory_bytes: 17604
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
	string a, b;
	vector<int> ans;
	int n, num, ai, bi, c=0;
	bool flag;

	//f[^ZbgÌüÍ
	cin >> n;
	
	for(int i=0 ; i<n ; i++){
		cin >> a >> b;
		flag = false;
		
		//aðvZ·é
		for(int j=0 ; j<100 ; j++){
			num = 0;
			ai = a.size()-j-1;
			bi = b.size()-j-1;
			if( ai<0 && bi<0 && c==0) break;
			
			if(ai>=0)num += a[ ai ] - 48;
			if(bi>=0)num += b[ bi ] - 48;
			ans.push_back( (num+c)%10 );
			if(num+c >= 10) c = 1;
			else c = 0;
		}
		if(ans.size()>80){
			flag = true;
		}
		if(flag){
			printf("overflow");
		}else{
			for(int j=ans.size()-1 ; j>=0 ; --j){
				printf("%d", ans[j]);
			}
		}
		printf("\n");
		ans.clear();
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int a[3][101];
int dp[3][101];

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

int dou(int n)
{
  int p = 0;
  int i, j;
  for ( i=0; i<=1; i++ ) {
    for ( j=0; j<n; j++ ) {
      if ( i == 0 && j == 0 ) {
        dp[i][j] = a[i][j];
      } else if ( i == 0 ) {
        dp[i][j] = dp[i][j-1] + a[i][j];
      } else if ( j == 0 ) {
        dp[i][j] = dp[0][j] + a[i][j];
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + a[i][j];
      }
    }
  }
  return dp[1][n-1];
}

int main(void)
{
  int n;
  int p;
  int i, j;
  scanf("%d", &n);
  for ( i=0; i<=1; i++ ) {
    for ( j=0; j<n; j++ ) {
      scanf("%d", &a[i][j]);
    }
  }
  p = dou(n);
  printf("%d\n", p);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int t,n,m,i,j,k,l,p;
    string s;
    cin>>s;
    l=0;
   if(s[i]=='S' && s[i+1]=='S'&&s[i+2]=='S')
   cout<<"0";
   else if(s[i]=='R' &&s[i+1]=='R'&&s[i+2]=='R')
   cout<<"3";
   else if(s[i]=='R' && s[i+1]=='R'&&s[i+2]=='S')
   cout<<"2";
   else if(s[i]=='S'&&s[i+1]=='R' && s[i+2]=='R')
   cout<<"2";
   else
   cout<<"1";
   
    
    
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

const int MOD = (int) 1e9 + 7;

typedef pair<int, int> P;


struct edge {
	int u, v, cost;
};

bool compc(edge &e1, edge &e2) {
	return e1.cost < e2.cost;
}


// UF
int par[100000];
int trank[100000];

int find(int x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	
	if (trank[x] < trank[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (trank[x] == trank[y]) trank[x]++;
	}
}


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	P xpairi[N], ypairi[N];
	REP(i, N) {
		int x, y;
		cin >> x >> y;
		xpairi[i] = make_pair(x, i);
		ypairi[i] = make_pair(y, i);
		par[i] = i;
		trank[i] = 0;
	}
	
	sort(xpairi, xpairi + N);
	sort(ypairi, ypairi + N);
	
	vector<edge> elist;
	REP(i, N - 1) {
		edge e;
		e.u = xpairi[i].second;
		e.v = xpairi[i + 1].second;
		e.cost = xpairi[i + 1].first - xpairi[i].first;
		elist.push_back(e);
		e.u = ypairi[i].second;
		e.v = ypairi[i + 1].second;
		e.cost = ypairi[i + 1].first - ypairi[i].first;
		elist.push_back(e);
	}
	
	sort(ALL(elist), compc);
	
	ll ans = 0;
	REP(i, elist.size()) {
		edge e = elist[i];
		if (find(e.u) != find(e.v)) {
			ans += e.cost;
			unite(e.u, e.v);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7284
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int n;
    cin>>n;
    int stuff[n],boss[200010]={0};
    for(int i=2;i<=n;i++) cin>>stuff[i];
    for(int i=2;i<=n;i++) boss[stuff[i]]++;
    for(int i=1;i<=n;i++) cout<<boss[i]<<endl;
}

Measured memory_bytes: 5180
ND = input()
N = int(ND.split()[0])
D = int(ND.split()[1])
count = 0
for i in range(N):
  XiYi = input()
  Xi = int(XiYi.split()[0])
  Yi = int(XiYi.split()[1])
  R = (Xi**2+Yi**2)**(1/2)
  if R <= D:
    count += 1
print(count)

Measured memory_bytes: 9648
import math
class prime_number:
    def __init__(self,N,num):
        self.N=N
        self.num=num

    def judge(self):
        if self.num==2:
            return 'true'
        elif self.num<2 or self.num%2==0:
            return 'false'
        else:
            root=math.floor(math.sqrt(self.num))+1
            for j in range(3,root,2):
                if self.num%j==0:
                    return 'false'
            return 'true'


N=int(input())
count=0

for i in range(N):
    x=int(input())
    prime=prime_number(N,x)
    if prime.judge()=='true':
        count=count+1
    else:
        count=count
print(count)



Measured memory_bytes: 5676
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    s = int(input())
    mod = pow(10,9) + 7

    dp = [0]*(s+1)
    dp[0] = 1
    for i in range(2,s+1):
        for j in range(0, (i-3)+1):
            dp[i] += dp[j]

    print(dp[s]%mod)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 8968
X, Y = map(int, input().split())

a = 2*X - Y/2
b = Y/2 - X


def judge(a,b):
    if a < 0 or b < 0:
        return "No"
    elif not a.is_integer():
        return "No" 
    elif not b.is_integer():
        return "No" 
    else:
        return "Yes"

print(judge(a,b))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;

vi dp;
const int mod = 1e9 + 7;

int solve(int s){
  if(s == 0)
    return 1;

  int& state = dp[s];
  if(state != -1)
    return state;

  state = 0;
  for(int i=3;i<=s;i++)
    state += solve(s-i), state %= mod;

  return state;
}

int main(){
  fastio;

  int s;
  cin >> s;
  dp.assign(s+1,-1);
  cout << solve(s) << endl;

  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a,b;
	getline(cin,a);
	getline(cin,b);
	sort(b.begin(),b.end(),greater<char>());
	sort(a.begin(),a.end());
	if(a<b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

s=deque(input())
n=int(input())
r=False
for i in range(n):
    q=input()
    if q[0]=="1":
        r= not r
    else:
        t,f,c=map(str,q.split())
        if f=="1":
            if r==False:
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if r==True:
                s.appendleft(c)
            else:
                s.append(c)
s=list(s)
if r==True:
    s=s[::-1]
print(*s,sep="")

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    string s;
    cin >> s;
    if (s == "ABC") {
        out("ARC");
    } else {
        out("ABC");
    }

    return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>
#include <math.h>
#include <string.h>
#define PI 3.14159265358979

int main(){
    
    double x=0,y=0,kakudo=0;
    int i=0,j=0;
    int d[1000],t[1000];
    while (1) {
        scanf("%d,%d",&d[i],&t[i]);
        if(d[i]==0 && t[i]==0) break;
        i++;
    }
    
    y=d[0];
    
    for (j=1; j<=i-1; j++) {
        kakudo += t[j-1]/180.0*PI;
        x +=d[j]*sin(kakudo);
        y +=d[j]*cos(kakudo);
    }
    printf("%d\n%d\n",(int)x,(int)y);
    return 0;
    
}

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

char c;
cin >> c ;

if (c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
    {
        cout << "vowel" ;

    }else
    {
        cout << "consonant" ;
    }
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  int a[200000];
  int count = 1;
  int brokenBlocks = 0;
  for(int i=0; i!=n; i++){
    cin >> a[i];
    if(a[i] == count){
      count += 1;
    }else{
      brokenBlocks += 1;
    }
  }
  if(count == 1){
    cout << -1 << '\n';
  }else{
    cout << brokenBlocks << '\n';
  }
  return 0;
}


Measured memory_bytes: 1024
s = list(map(int, list(input())))
e = [i % 2 for i in range(len(s))]
o = [(i+1) % 2 for i in range(len(s))]
print(min(sum(x != y for x, y in zip(s, e)), sum(x != y for x, y in zip(s, o))))


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

A = sorted(list(map(int, input().split())))
'''
INF = 10**6

ind = INF
for i in range(len(A)):
    if A[i]>=0:
        ind = i
        break
    else:
        A[i] *= -1

if ind == INF:
    ind = N

if ind %2 == 0:
    print(sum(A))
elif ind==N:
    print(sum(A)-2*A[ind-1])
else:
    print(sum(A)-2*min(A[ind], A[ind-1]))
'''
start = 0
end = N-1

while end != start:
    if A[(start+end)//2] >= 0:
        end = (start+end)//2
    elif end-start==1:
        start = (start+end)//2+1
    else:
        start = (start+end)//2

if start==N-1 and A[N-1]<0:
    start=N

if start%2==0:
    print(sum(A[:start])*(-1) + sum(A[start:]))
elif start==N:
    print(sum(A[:start])*(-1) + sum(A[start:]) + 2*A[N-1])
else:
    print(sum(A[:start])*(-1) + sum(A[start:]) - 2*min(A[start], (-1)*A[start-1]))

Measured memory_bytes: 14480
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

int main() {
    const i64 INF = 1e16;
    int N, M;
    cin >> N >> M;
    i64 S = 0;
    vector<i64> A(N);
    rev_priority_queue<pair<i64, int>> q;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    set<int> shortcut, inv_range;
    i64 L = 0;
    for(int i = 0; i < N - 1; i++) {
        S += (A[i + 1] - A[i] + M) % M;
        if(A[i] < A[i + 1]) { // 向きが同じ
            q.push({A[i], i});
            q.push({A[i + 1], i});
        } else { //
            q.push({A[i + 1], i});
            q.push({A[i], i});
            inv_range.insert(i);
            shortcut.insert(i);
            L += A[i];
        }
    }
    i64 ans = INF;

    for(int x = 0; x < M; x++) {
        i64 cand = 0;
        cand = S;
        cand -= x * shortcut.size() - L + inv_range.size() * M;
        cand += shortcut.size();
        ans = min(ans, cand);
        while(q.size() && x >= q.top().first) {
            i64 a; int i;
            tie(a, i) = q.top();
            inv_range.erase(i);
            if(shortcut.count(i)) {
                shortcut.erase(i);
                L -= A[i];
            } else {
                shortcut.insert(i);
                L += A[i];
            }
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}



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

//taken fron https://www.geeksforgeeks.org/longest-repeating-and-non-overlapping-substring/
int longestRepeatedSubstring(string str)
{
	int n = str.length();
	int LCSRe[n+1][n+1];
	memset(LCSRe, 0, sizeof(LCSRe));
	string res;
	int res_length = 0;
	int i, index = 0;
	for (i=1; i<=n; i++)
	{
		for (int j=i+1; j<=n; j++)
		{
			if (str[i-1] == str[j-1] &&
				LCSRe[i-1][j-1] < (j - i))
			{
				LCSRe[i][j] = LCSRe[i-1][j-1] + 1;

				// updating maximum length of the
				// substring and updating the finishing
				// index of the suffix
				if (LCSRe[i][j] > res_length)
				{
					res_length = LCSRe[i][j];
					index = max(i, index);
				}
			}
			else
				LCSRe[i][j] = 0;
		}
	}
	return res_length;
}

int main()
{
    int n;
	string str;
	cin>>n>>str;
	cout << longestRepeatedSubstring(str);
	return 0;
}


Measured memory_bytes: 97920
import datetime

def last_day_of_month(any_day):
    next_month = any_day.replace(day=28) + datetime.timedelta(days=4)  # this will never fail
    return next_month - datetime.timedelta(days=next_month.day)

m1, d1 = map(int, input().split(' '))
m2, d2 = map(int, input().split(' '))

date1 = datetime.date(2019, m1, d1)
date2 = datetime.date(2019, m2, d2)

if (date2>date1):
  print('1') if(last_day_of_month(datetime.date(2019, m1, d1) ) == datetime.date(2019, m1, d1)) else print('0')

Measured memory_bytes: 3440
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>x(n),y(n);

    REP(i,n){
        cin >> x[i];
        y[i] = x[i];
    }

    SORT(y);
    ll left = y[n/2-1],right = y[n/2];
    REP(i,n){
        if(x[i] < right)cout <<right<< endl;
        else cout << left << endl;
    }
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
// Loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

#define ALL(v) v.begin(), v.end()

const int INF = 10000;


int main(void) {
	int x, n;
	int diff = INF;
	int ans  = 100;
	cin >> x >> n;

	int itemp;
	bool q[102];
	rep(i, 102) { q[i] = false; }
	rep(i, n) {
		cin >> itemp;
		q[itemp] = true;
	}
	REP(i, 0, 102) {
		if(q[i]) {
			continue;
		}
		int dtemp = abs(x - i);
		if(diff == dtemp) {
			cout << ans << endl;
			return 0;
		}
		if(diff > dtemp) {
			diff = dtemp;
			ans  = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int D = scan.nextInt();
        HashMap<Integer, Point> map = new HashMap<>();
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int A = scan.nextInt();
                map.put(A, new Point(i, j));
            }
        }
        int[] s = new int[H*W+1];
        for (int i = 1; i <= H * W - D; i++) {
            Point p1 = map.get(i);
            Point p2 = map.get(i+D);
            s[i+D] = s[i]
                    + Math.abs(p1.i-p2.i)
                    + Math.abs(p1.j-p2.j);
        }
        int Q = scan.nextInt();
        for (int i = 0; i < Q; i++) {
            int L = scan.nextInt();
            int R = scan.nextInt();
            System.out.println(s[R]-s[L]);
        }
    }
    class Point {
        int i;
        int j;
        Point(int i, int j) {
            this.i = i;
            this.j = j;
        }
    }
}


Measured memory_bytes: 105148
#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() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int f = 0, t = 0;
  rep(i, n) {
    if (a[i] % 4 == 0) ++f;
    else if (a[i] % 2 == 0) ++t;
  }
  if (f * 2 + 1 >= n || f * 2 + t >= n) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3716
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    A = list(map(int,input().split()))
    t = 0
    for e in A:
        t ^= e
    print(*[A[k]^t for k in range(N)])
if __name__ == '__main__':
    main()


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

int main(){
   int ABCD;
   std::cin >> ABCD;
   int A, B, C, D;
   A = ABCD/1000;
   B = (ABCD%1000)/100;
   C = (ABCD%1000)%100/10;
   D = (ABCD%1000)%100%10;

   for (int i=0; i<8; i++){
      int ans;
      int m1 = 4;
      int m2 = 2;
      int m3 = 1;
      int op1 = (i & m1) >> 2;
      int op2 = (i & m2) >> 1;
      int op3 = (i & m3);
      std::cerr << op1 << " " << op2 << " " << op3 << std::endl;
      ans = (op1 == 0)? A-B: A+B;
      ans = (op2 == 0)? ans-C: ans+C;
      ans = (op3 == 0)? ans-D: ans+D;
      char op1s = (op1 == 0)? '-': '+';
      char op2s = (op2 == 0)? '-': '+';
      char op3s = (op3 == 0)? '-': '+';
      if (ans == 7){
         std::cout << A << op1s << B << op2s << C <<op3s << D << "=7" << std::endl;
         break;
      }
   }
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = 10000;
		for(int i=0; i<s.length()-2; i++){
			min = Math.min(Math.abs(753-Integer.parseInt(s.substring(i, i+3))), min);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 22484
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i=0; i<n; i++) {
        cin >> c.at(i);
    }
    vector<ll> dp(n+1);
    dp.at(0) = 1;
    vector<int> pre(2e5 + 1, -1);
    for (int i=0; i<n; i++) {
        dp.at(i+1) = dp.at(i);
        if (pre.at(c.at(i)) != -1 && pre.at(c.at(i)) != i-1) {
            dp.at(i+1) += dp.at(pre.at(c.at(i)) + 1);
            dp.at(i+1) %= MOD;
        }
        pre.at(c.at(i)) = i;
    }
    cout << dp.at(n) % MOD << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3456
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> p(n);
    ll res = 0;
    rep(i, n) cin >> p[i];
    for(ll i = 1; i < n - 1; i++){
        if(p[i - 1] < p[i] && p[i] < p[i + 1] || p[i + 1] < p[i] && p[i] < p[i - 1]) res++;
    }
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    ll n,k,q; cin>>n>>k>>q;
    vector<int> p(n, k-q);
    rep(i,q){
        int a;
        cin >> a;
        --a;
        p[a]++;
    }
    
    rep(i,n){
        if(p[i]>0) cout << "Yes" << ln;
        else cout << "No" << ln;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int K,X;
  scanf("%d",&K);
  scanf("%d",&X);
  if(X-K>-1000000 && X+K<1000000)
  {for(int i=0;i<K;i++)
   {printf("%d\n",X-K+i+1);}
   for(int n=0;n<K-1;n++)
   {printf("%d\n",X+n+1);}
  }
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  vector<int> pattern;
  int Pindex, Qindex, index;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    pattern.push_back(i+1);
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }

  index = 1;
  do {
    if(P == pattern){
      Pindex = index;
    }
    if(Q == pattern){
      Qindex = index;
    }
    index++;
  } while (std::next_permutation(pattern.begin(), pattern.end()));

  cout << abs(Pindex - Qindex) << endl;
  return 0;
}


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

using namespace std;

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

	int sum = 0;
	int tmp = n;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}

	bool ok = n % sum == 0;
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)
#define FOR(i,a,b) for(int i = a;i<b;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

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

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

bool K[100010] = { false };

int main() {

	ll n, m;
	cin >> n >> m;
	pr(abs((n - 2)*(m - 2)));

	//system("pause");
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define ll long long int
            #define ull unsigned long long
            ll power(ll,ll);
            ll ncr(ll,ll);
            ll add(ll a,ll b);
            void fact();
            ll mul(ll a,ll b);
            #define watch(x) cerr<<(#x)<<"is"<<x<<nl;
            #define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
            #define fi(a,b) for(ll i=a; i<b; i++)
            #define fk(a,b) for(ll k=a; k<b; k++)
            #define fri(a,b) for(ll i=a; i>=b; i--)
            #define fj(a,b) for(ll j=a; j<b; j++)
            #define ffi(a,b) for(ll i=a;i*i<=b;i++)
            #define mp make_pair
            #define ff first 
            #define  tc ll t; cin>>t; while(t--)
            #define all(v) (v).begin(),(v).end()
            #define ss second
            #define pb push_back
            #define mem(v,a) memset((v),a,sizeof(v));
            #define pll pair<ll,ll>
            #define mll map<ll,ll>
            #define sll set<ll>
            #define vll vector<ll>
            #define max3(a,b,c) max(a,max(b,c))
            #define min3(a,b,c) min(a,min(b,c))
            #define nl endl
             int mod=1e9+7;
            const ll  N=1000032LL;
            ll fac[N+2];
            ll inv[N+2];
            
           
            
            signed main(){  
        	fast
        	//~ fact();
        	//~ tc
            {
    		  string s;
    		 
    		 cin>>s;
    		 if(s=="SAT") cout<<1;
    		  if(s=="SUN") cout<<7;
    		   if(s=="MON") cout<<6;
    		    if(s=="TUE") cout<<5;
    		     if(s=="WED") cout<<4;
    		      if(s=="THU") cout<<3;
    		       if(s=="FRI") cout<<2;
    		 
    		 
    		 
    	    
    	     }
                return 0;
            }
             
             
            /******************************************************************************/
             
            ll add(ll a,ll b){
    			a+=b;
    		   if(a>=mod) a-=mod;
    		   if(a<0) a+=mod;
    		   return a;
    		} 
             
            ll mul(ll a,ll b){
                return ((a)*(b))%mod;
            }
             
            ll power(ll a,ll n){
              ll res=1;
              while(n){
                  if(n&1) res= mul(res,a);
                 n>>=1; 
                 a= mul(a,a);
              }
                return res;
            }
            void fact(){
            	inv[0]=fac[0]=1;
            	fi(1,N){
            	 fac[i]=mul(fac[i-1],i);
            	inv[i]=power(fac[i],mod-2);
            }
            }
             
            ll ncr(ll n,ll r){
            	
            	if(r>n) return 0;
            	ll e=fac[n];
            	e=mul(e,inv[r]);
            	e=mul(e,inv[n-r]);
            	return e;
            }

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define mod 1000000007
 #define f first
 #define se second
 #define pb push_back
 #define int long long int
using namespace std;
 signed main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);cout.tie(NULL);
     
    /* #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
     #endif*/

         int n;
         cin>>n;

         cout<<(n-2)*180<<"\n";

 }


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
#define PRINT_ENTER() cout << endl;
#define ll long long

int main() {
    /* code */
    long long n;
    long long a, b;
    cin >> n >> a >> b;
    long long plus;
    if (a == 0) {
        cout << 0 << endl;
        return 0;
    }
    plus = min(n % (a + b), a);
    cout << plus + (n / (a + b)) * a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int dp[3005][3005];
int solve(){
    string s,t; cin>>s>>t;
    n=sz(s); m=sz(t);
    s=" "+s; t=" "+t;
    rep(i,1,n){
        rep(j,1,m){
            if(s[i]==t[j])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i=n,j=m;
    vc<char> ans;
    while(i>0&&j>0){
        if(s[i]==t[j]){
            ans.pb(s[i]);
            i--; j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(all(ans));
    rep(i,0,sz(ans)-1) cout<<ans[i];
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 70784
N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

dp = [[-1] * (T + 1) for _ in range(N + 1)]
dp[0][0] = 0
X.sort()

for i in range(N):
    for j in range(T + 1):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        if dp[i][j] >= 0 and j < T:
            dp[i + 1][min(T, j + X[i][0])] = max(dp[i + 1][min(T, j + X[i][0])],
                                                 dp[i][j] + X[i][1])

print(max(dp[-1]))


Measured memory_bytes: 146224
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n,m,k[50],a[50][50],l[50],ans;
  ans=0;
  cin >> n >> m;
  rep(i,m)l[i]=0;
  rep(i,n){cin >> k[i];
           rep(j,k[i])cin >> a[i][j];
          }
  rep(i,n){
           rep(j,k[i])l[a[i][j]-1]++;
          }
  rep(i,m)if(l[i]==n)ans++;
  printf("%lld",ans);
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader =
                new BufferedReader(new InputStreamReader(System.in));
        int [] count = new int[4];
        while (true) {
            String input = reader.readLine();
            if (input == null) {
                break;
            }
            String[] temp = input.split(",");
            if (temp[1].equals("A")) {
                count[0]++;
            }else if (temp[1].equals("B")) {
                count[1]++;
            }else if (temp[1].equals("AB")) {
                count[2]++;
            }else if (temp[1].equals("O")) {
                count[3]++;
            }
        }
        for (int i : count) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 9364
import Control.Monad
import Control.Applicative
import Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- replicateM n readLn :: IO [Int]
  print $ solve ns

solve :: [Int] -> Int
solve (n:ns:nss) = go (min n ns) (ns - n) nss
  where
    go x y [] = y
    go x y (z:zs)
      | z < x = go z y zs
      | y < z - x = go x (z-x) zs
      | otherwise = go x y zs
--solve [n, m] = m - n

Measured memory_bytes: 124976