akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
    z->parent = y;
  }

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
    if(u->left != NIL) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}


int main(){
  int n, i, j;
  int x[500001];
  char com[500001][7];
  Node t;

  scanf("%d", &n);

  for(i = 0, j = 0;i < n;i++){
    scanf("%s", com[i]);
    if(com[i][0] == 'i'){
      scanf("%d", &x[j]);
      j++;
    }
  }
  
  root = malloc(sizeof(struct node));
  t = malloc(sizeof(struct node));
  root->left = NIL;
  root->right = NIL;
  root->parent = NIL;

  t = root;

  for(i = 0,j = 0;i < n;i++){
    if(com[i][0] == 'i' && i == 0){
      root->key = x[j];
      j++;
    }
    else if(com[i][0] == 'i'){
      insert(x[j]);
      j++;
    }
    else {
      inorder(t);
      printf("\n");
      preorder(t);
      printf("\n");
    }
  }

  free(root);
  return 0;
}

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

int main(){
  int N , K ;
  cin >> N >> K ; 
  vector<int> T(N)  ; 
  int cnt = 0 ;
  
  for(int i = 0 ; i<N ; i++){
	T.at(i) = 0 ; 
    }
  
  for (int i = 0 ; i<K ; i++){
  	int d=0 ; 
    cin >> d ; 
  	vector<int> A(d) ;
    
    for(int k = 0 ; k < d ; k++){
    cin >> A.at(k) ; 
    T.at(A.at(k)-1) = T.at(A.at(k)-1) + 1 ; 
    }
    
  }
  
      for(int i = 0 ; i<N ; i++){
      if( T.at(i) == 0) {
        cnt++ ; 
      }
    }
      cout << cnt << endl ; 
}

Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()
if K - A > 0:
  B -= K-A
print(max(0, A-K), max(0, B))

Measured memory_bytes: 5400
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;

lli h[100005];
lli n;
lli a, b;

bool ok(lli k)
{
    lli fo[100005];
    rep(i, n)
    {
        fo[i] = h[i] - k * b;
    }
    lli sum = 0;
    rep(i, n)
    {
        if (fo[i] <= 0)
            continue;
        sum += fo[i] % (a - b) == 0 ? fo[i] / (a - b) : fo[i] / (a - b) + 1;
    }
    return sum <= k;
}
int main()
{
    cin >> n >> a >> b;
    rep(i, n)
    {
        cin >> h[i];
    }
    lli up = 2 * (*max_element(h, h + n));
    lli low = -1;
    while (up - low > 1) {
        lli mid = (up + low) / 2;
        //cout << up << " " << low << endl;
        if (ok(mid)) {
            up = mid;
        } else {
            low = mid;
        }
    }
    cout << up << endl;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

ll X;

int main(void) {
    cin >> X;

    ll year = 0;
    ll x = 100;
    while(x < X) {
        x += (x / 100);
        year++;
    }

    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define MAX 25

struct NODE{
    // int id; idにあった配列番号nに要素を入れればok
    int parent;
    int left;
    int right;
};

void preorder(struct NODE *node, int root){
    if (root == -1){
        return;
    }
    printf(" %d", root);
    preorder(node, node[root].left);
    preorder(node, node[root].right);
}

void inorder(struct NODE *node, int root){
    if (root == -1){
        return;
    }
    
    inorder(node, node[root].left);
    printf(" %d", root);
    inorder(node, node[root].right);
}

void postorder(struct NODE *node, int root){
    if (root == -1){
        return;
    }
    
    postorder(node, node[root].left);
    postorder(node, node[root].right);
    printf(" %d", root);
}



int main(void){
    int n;
    struct NODE node[MAX];
    int i;
    int id, left, right;
    int root;

    scanf("%d", &n);

    for (i = 0; i < MAX; i++){
        node[i].parent = node[i].left = node[i].right = -1;
    }

    for (i = 0; i < n; i++){
        scanf("%d %d %d", &id, &left, &right);
        node[id].left = left;
        node[id].right = right;

        if (left != -1){
            node[left].parent = id;
        }
        if (right != -1){
            node[right].parent = id;
        }
    }

    for (i = 0; i < n; i++){
        if (node[i].parent == -1){
            root = i;
            // printf("%d\n", root);
        }
    }

    

    printf("Preorder\n");
    preorder(node, root);
    printf("\n");

    printf("Inorder\n");
    inorder(node, root);
    printf("\n");

    printf("Postorder\n");
    postorder(node, root);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2056
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

using namespace std;

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

typedef long long ll;

int a[3],b[3];
int perm[4]={1,2,3,4};
bool ed[10][10];

bool jud()
{
	if(ed[perm[0]][perm[1]]!=1)return false;
	if(ed[perm[1]][perm[2]]!=1)return false;
	if(ed[perm[2]][perm[3]]!=1)return false;
	return true;
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	for(int i=0;i<3;i++)
	{
		cin>>a[i]>>b[i];
		
		ed[a[i]][b[i]]=1;
		ed[b[i]][a[i]]=1;
	}
	
	do{
		if(jud()){cout<<"YES";return 0;}
	}while(next_permutation(perm,perm+4));
	
	cout<<"NO";
	
	//printf("Time used = %.4f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
# 問題数が奇数のときは問題数が同じにはならない
if N%2==1:
    print(0)

di = sorted(list(map(int, input().split())))
first_of_center = di[int(len(di)/2)-1]
second_of_center = di[int(len(di)/2)]
#中央の2つの値が同じ時Kは選べない
if first_of_center == second_of_center:
    print(0)
else:
    print(second_of_center - first_of_center)

Measured memory_bytes: 14428
N = int(input())
A = list(map(int, input().split()))

pre = A[0]
ans = 0

for i in range(1, N):
    if A[i] >= pre:
        pre = A[i]
    else:
        base = pre - A[i]
        pre = A[i] + base
        ans += base

print(ans)


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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

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

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


int main(){
    string S;
    cin >> S;

    int ans = 0;
    rep(i,S.size()/2){
        if( S[i] != S[S.size()-i-1]) ++ans;
    }
    cout << ans  << endl;





}


Measured memory_bytes: 3624
def main():
    M = int(input())
    reduced = [0] * M
    loop = [[] for _ in range(10)]
    for i in range(10):
        sm = i
        cnt = 0
        while True:
            loop[i].append((sm, cnt))
            if sm == i and cnt != 0:
                break
            sm += i
            cnt += 1
            if sm >= 10:
                sm = (sm % 10) + 1
                cnt += 1
        #print(i, loop[i])
    ans = 0
    for i in range(M):
        d, c = map(int, input().split())
        cycle = len(loop[d]) - 1
        a = (c-1) % cycle
        b = (c-1) // cycle
        ans += loop[d][cycle][1] * b + loop[d][a][1]
        reduced[i] = loop[d][a][0]
    # print(ans)
    # print(reduced)
    sm = 0
    for i in range(M):
        sm += reduced[i]
        if sm >= 10:
            sm = (sm % 10) + 1
            ans += 1
    ans += M-1
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
	int a;
    cin >> a;
    int ans = a + a*a + a*a*a;
    cout << ans;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, h[100000], dp[100000];
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h[i];
    int cost = 0;
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        int t = dp[i - 1] + abs(h[i] - h[i - 1]);
        int j = 2;
        while (j <= k) {
            if (i - j < 0) break;
            t = min(t, dp[i - j] + abs(h[i] - h[i - j]));
            ++j;
        }
        dp[i] = t;
    }
    cout << dp[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        List<int> num = new List<int>(n);
        int count = 1;
        do
        {
            count++;
            num.Add(n);
            n = n % 2 == 0 ? n / 2 : 3 * n + 1;
        } while (!num.Contains(n));
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,m; vector< pair<ll,ll> > vc;
bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	if(a.sc!=b.sc) return a.sc>b.sc;
	else return a.fs<b.fs;
}
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m;
	set<ll> st;
	for(i=1;i<=m;i++){
		st.insert(i);
	}
	for(i=1;i<=n;i++){
		cin>>k>>l;
		vc.ps({k,l});
	}
	sort(all(vc),comp);

	ll ans=0;
	for(i=0;i<n;i++){
		if(st.size()==0) break;
		auto it=st.lower_bound(vc[i].fs);
		if(it!=st.end()){
			ans+=vc[i].sc;
			st.erase(it);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7160
import java.util.Scanner;

public class Main {
	static int[] parent;

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			int[] p = new int[n];
			parent = new int[n];
			for (int i = 0; i < n; i++) {
				parent[i] = i;
				p[i] = sc.nextInt() - 1;
			}
			for (int i = 0; i < m; i++) {
				unite(sc.nextInt() - 1, sc.nextInt() - 1);
			}
			int ans = 0;
			for (int i = 0; i < n; i++) {
				if (same(i, p[i]))
					ans++;
			}
			System.out.println(ans);
		}
	}

	static void unite(int x, int y) {
		int rootx = root(x);
		int rooty = root(y);
		if (rootx != rooty)
			parent[rooty] = parent[rootx];
	}

	static public int root(int x) {
		if (parent[x] == x) {
			return x;
		}
		return parent[x] = root(parent[x]);
	}

	static public boolean same(int x, int y) {
		return root(x) == root(y);

	}
}

Measured memory_bytes: 59528
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, val[MAXN], res[MAXN], f[MAXN], N;
vector<int> a[MAXN];

void dfs(int u, int p) {
    for (int v : a[u]) {
        if (v == p) continue;
        int dau = 1, cuoi = N, mid;
        while (dau <= cuoi) {
            mid = (dau + cuoi) >> 1;
            if (f[mid] < val[v]) dau = mid+1;
            else cuoi = mid-1;
        }
        int oldVal = 0; bool add = false;
        if (dau > N) {
            f[++N] = val[v];
            add = true;
        }
        else {
            if (val[v] < f[dau]) {
                oldVal = f[dau];
                f[dau] = val[v];
            }
        }
        res[v] = max(res[u], dau);
        dfs(v, u);
        if (add) N--;
        else if (oldVal) f[dau] = oldVal;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> val[i];
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    f[1] = val[1];
    res[1] = 1;
    N = 1;
    dfs(1, 0);
    FOR(i,1,n) cout << res[i] << "\n";
    return 0;
}


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

bool isParindrome(const string& s) {
    string::const_iterator it = s.begin();
    string::const_reverse_iterator rit = s.rbegin();
    for(int i = 0; i <= s.size()/2; ++i, ++it, ++rit) {
        if(*it!=*rit) {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    if(isParindrome(s) && isParindrome(s.substr(0, s.size()/2))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define EPS 1e-10

using namespace std;


int main(){
	double x1,x2,x3,x4,y1,y2,y3,y4,slope1,slope2;

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4) != EOF){
		if(x1 == x2){
			if(y3 == y4)printf("YES\n");
			else{
				printf("NO\n");
			}
		}else{ //x1 != x2
			if(x3 == x4){
				if(y1 == y2)printf("YES\n");
				else{
					printf("NO\n");
				}
			}else{
				slope1 = (double)((y2-y1)/(x2-x1));
				slope2 = (double)((y4-y3)/(x4-x3));
				if(fabs(slope1*slope2 + 1) < EPS){
					printf("YES\n");
				}else{
					printf("NO\n");
				}
			}
		}
	}

    return 0;
}


Measured memory_bytes: 2576
#include <iostream>
 
using namespace std;
 
int main(){
    int N,a=0;
    long long int Aa=1,A[100010];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]==0){
            printf("0\n");
            a=1;
            break;
        }
    }
    if(a==0){for(int i=0;i<N;i++){
        if(Aa>1&&1000000000000000000/Aa<A[i]){
            printf("-1\n");
            a=1;
            break;
        }
        Aa*=A[i];
    }
    }
    if(a==0){
        printf("%lld\n",Aa);
    }
}

Measured memory_bytes: 4424
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    int n;
    scanf("%d", &n);
    int ans = 1;
    while (true) {
        if (ans * 2 > n) {
            break;
        }
        else {
            ans *= 2;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int main()
{
    int x,sum = 0,div;

    cin >> x;

    div = x;


    while(div != 0){


    sum = sum + div % 10;

    div = div / 10;


    }


    if(x % sum == 0)
    {
        cout<<"Yes\n"<<endl;
    }
    else{

        cout<<"No\n"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
def main():
    S = input()

    odd_tile_dict = {"0": 0, "1": 0}
    even_tile_dict = {"0": 0, "1": 0}
    for s in S[1::2]:
        odd_tile_dict[s] += 1

    for s in S[::2]:
        even_tile_dict[s] += 1

    res = min(odd_tile_dict["0"] + even_tile_dict["1"], odd_tile_dict["1"] + even_tile_dict["0"])
    print(res)

if __name__ == '__main__':
    main()

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

int main(void){
    int n;
    cin >> n;
    for(int i=1;i <= n;i++){
        int x = i;
        if(x%3 == 0){
            cout << " " << i;
        }
        else while(x){
            if(x%10 == 3){
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3132
import Control.Applicative

up n = take n (repeat 'U')
dw n = take n (repeat 'D')
ri n = take n (repeat 'R')
le n = take n (repeat 'L')

main = do
  (sx:sy:tx:ty:_) <- (map (read::String->Int)) . words <$> getLine
  let
    dx = tx - sx
    dy = ty - sy

  putStrLn $ foldl1 (++) [up dy, ri dx, dw dy, le dx, le 1, up (dy+1), ri (dx+1), dw 1, ri 1, dw (dy+1), le (dx+1), up 1]
  


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
ll dp[110][100010];
int main(){
    int n;cin>>n;
    ll W;cin>>W;
    vector<ll> w(n+10),v(n+10);
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
    for(int i=0;i<=n;i++)for(int j=0;j<=100000;j++)dp[i][j]=LINF;
    dp[0][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=100000;j++){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j>=v[i])dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
        }
    }
    ll ans=0;
    for(int i=0;i<=100000;i++){
        if(dp[n][i]<=W){
            ans=i;
        }
    }
    cout<<ans<<endl;
}   


Measured memory_bytes: 80128
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
using namespace std;

//long long A[100000];
//int stand_bit_num[40];

//int t[1000000];
//long long d[100000];

int x[100];
int y[100];

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

    int a = atoi(s.substr(0,1).c_str());
    int b = atoi(s.substr(1,1).c_str());
    int c = atoi(s.substr(2,1).c_str());
    int d = atoi(s.substr(3,1).c_str());


   for(int i = 0; i < 2; i++){
       for(int j = 0; j < 2; j++){
           for(int k = 0; k < 2; k++){
               int ans = a;
               char signs[3];
               if(i == 0){
                   ans += b;
                   signs[0] = '+';
               } else {
                   ans -= b;
                   signs[0] = '-';
               }

               if(j == 0){
                   ans += c;
                   signs[1] = '+';
               } else {
                   ans -= c;
                   signs[1] = '-';
               }

               if(k == 0){
                   ans += d;
                   signs[2] = '+';
               } else {
                   ans -= d;
                   signs[2] = '-';
               }

               if(ans == 7){
                   printf("%d%c%d%c%d%c%d=7", a, signs[0],b,signs[1],c,signs[2],d);
                   return 0;
                }
           }
       }

   }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        r: f64,
    }
    println!("{}", 2.0 * std::f64::consts::PI * r);
}


Measured memory_bytes: 2184
#include<iostream>
using namespace std;
int main() {
	int a, b, c, t;
	cin >> a >> b >> c;
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 1164
$debug=0
def aux(l)

  b=[0]
  c=[0]
  puts "l: #{l}" if $debug & 1==1
  while l.length > 0
    ball=l.shift
    puts "ball: #{ball} b:#{b.to_s} c:#{c.to_s}" if $debug & 1==1
    if ball > b[-1] and ball > c[-1]
      if ball-b[-1] <= ball-c[-1]
        b.push(ball)
        puts "push #{ball} to b" if $debug & 1==1
      else
        c.push(ball)
        puts "push #{ball} to c" if $debug & 1==1
      end
    elsif ball>b[-1] 
      b.push(ball)
      puts "push #{ball} to b" if $debug & 1==1
    elsif ball>c[-1] 
      c.push(ball)
      puts "push #{ball} to c" if $debug & 1==1
    else
      puts "cannot push #{ball}" if $debug & 1==1
      return "NO"
    end
  end
  return "YES"

end

def main
  dat=[]
  if $debug & 2 == 2
    fh=File.new("vol0-0033.txt", "r")
  else
    fh=STDIN
  end

  n = fh.gets.chomp.to_i
  n.times {|i|
    l=fh.gets.chomp.split.map{|x| x.to_i}
    puts aux(l)
  }

end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6852
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10 ** 9 + 7
INF = 1 << 60

# ---------------------------------------------------
# ---------------------------------------------------
# ---------------------------------------------------

def resolve():
    N = int(inp())
    A = [int(inp()) for _ in range(N)]
    minV = A[0]
    maxV = -(1<<60)
    for i in range(1, N):
        maxV = max(maxV, A[i]-minV)
        minV = min(minV, A[i])
    print(maxV)

if __name__ == '__main__':
    resolve()


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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int main()
{
	c_p_c();
	int n, W;
	cin >> n >> W;
	int weights[105];
	ll values[105];
	for (int i = 1; i <= n; i++) {
		cin >> weights[i] >> values[i];
	}
	ll profit = 0;
	ll *prev = new ll[W + 1] {0};
	ll *curr = new ll[W + 1] {0};
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= W; j++) {
			ll inc = INT_MIN , exc;
			exc = prev[j];
			if (j - weights[i] >= 0) {
				inc = values[i]  + prev[j - weights[i] ];
			}
			if (inc > exc) {
				curr[j] = inc;
			} else {
				curr[j] = exc;
			}
		}
		ll* temp = prev;
		prev = curr;
		curr = temp;
	}
	cout << prev[W] << endl;
	delete [] prev;
	delete [] curr;
	return 0;
}

Measured memory_bytes: 1792
def main():
    K, N = map(int,input().split())
    A = list(map(int,input().split()))
    A.append(K+A[0])
    B = []
    for i in range(N):
        B.append(A[i+1] - A[i]) # 内包表記
    # Maxを抜く
    tmp = max(B)
    print(sum(B) - tmp)
    
main()

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int abc[3];
cin >> abc[0] >> abc[1] >> abc[2];
map<int, int> oe;
ll ans = 0;
rep(i,3){
    oe[abc[i] % 2]++;
}
int max_v=0;
rep(i,3){
    if(oe[abc[i]%2]==2){
        abc[i]++;
        ans = 1;
    }
    max_v = max(max_v, abc[i]);
}
int diff[3]={max_v-abc[0],max_v-abc[1],max_v-abc[2]};


rep(i,3){
    if(diff[i]!=0){
        ans += floor(diff[i] / 2);
        diff[i] = diff[i] % 2;
    }
}
cout << ans << endl;
//system("pause");
return 0;
}

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

const ll MOD = 1e9+7;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    
    ll ans = 0;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
        for(int j = 0; j < i; j++){
            if(a[i] < a[j]) ans = (ans + ((k * (k+1)) / 2) % MOD) % MOD;
            else if(a[i] > a[j]) ans = (ans + ((k * (k - 1)) / 2) % MOD) % MOD;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    var count = 0L
    for (i in 0 until n) {
        when {
            (a[i] == b[i] && a[i] == c[i]) -> {
                //do nothing
            }
            (a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) -> {
                count += 2
            }
            else -> {
                count++
            }
        }

    }
    println(count)
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v
#define NUM(x,v) (POSU(x,v)-POSL(x,v))
const ll INF=1e9+7;
const ll N = 20002;
ll n,p[N],a[N],b[N],c[N],pi[N];

int main(){
	cin>>n;
	p[0]=0;
	FOR(i,0,n){
		cin>>p[i+1];
		pi[p[i+1]]=i+1;
	}
	FOR(i,1,n+1){
		a[i]=30000*i;
		b[i]=30000*(n-i)+pi[i];	
	}
	FOR(i,1,n){
		cout<<a[i]<<" ";
	}
	cout<<a[n]<<endl;
	FOR(i,1,n){
		cout<<b[i]<<" ";
	}
	cout<<b[n]<<endl;
	return 0;
}

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


int main() {
	int h, n;
	cin >> h >> n;
	while(n--){
		int a;
		cin >> a;
		if((h -= a) <=0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
ln, kn, *ki = map(int, open(0).read().split())
# 順回転
pa = ki[-1]
ky = [pa]
kigu = 1
for ys in range(2, kn + 1):
    # 要素数が偶数の場合
    if kigu == 1:
        pa += ki[kn - ys] * 2 + ln - ki[-(ys // 2)] * 2
    # 要素数が奇数の場合
    else:
        pa += ki[kn - ys] * 2 - ki[-(ys // 2) - 1] + ln - ki[-(ys // 2)]
    ky.append(pa)
    kigu *= -1

# 逆回転
pa = ln - ki[0]
ky.append(pa)
kigu = 1
for ys in range(2, kn + 1):
    # 要素数が偶数の場合
    if kigu == 1:
        pa += (ln-ki[ys - 1]) * 2 - ln + ki[ys // 2 - 1] * 2
    # 要素数が奇数の場合
    else:
        pa += (ln-ki[ys - 1]) * 2+ki[ys//2]-ln+ki[ys//2-1]
    ky.append(pa)
    kigu *= -1

print(max(ky))

Measured memory_bytes: 33452
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

// Rolling Hash
// long long にして使うこと
class RHash{
	public:
	int n;
	vi base,mo;//mod
	vvi hash;
	vvi po;//pow
	
	RHash(string s){
		base={1009,9973};
		mo={1000000007,1000000009};
		
		n=s.size();
		hash=vvi(n+1,vi(2));
		po=vvi(n+1,vi(2,1));
		
		rep(i,n)rep(j,2){
			hash[i+1][j]=(hash[i][j]+s[i])*base[j]%mo[j];
			po[i+1][j]=po[i][j]*base[j]%mo[j];
		}
	}
	pii get(int l,int r){// [l,r)
		Def t[2];
		rep(i,2)t[i]=((hash[r][i]-hash[l][i]*po[r-l][i])%mo[i]+mo[i])%mo[i];
		return {t[0],t[1]};
	}
};

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	string rs=s;
	reverse(all(rs));
	RHash rh(s),rh1(rs);
	loop(i,2,n+1){
		bool h=true;
		pii p1=rh.get(0,i),p2=rh1.get(n-i,n);
		bool w=0;
		for(int j=0;j<n;j+=i-1){
			if(j+i>n){
				int c=n-j;
				if(!w){
					if(rh.get(0,c)!=rh.get(j,j+c))h=false;
				}else{
					if(rh1.get(n-i,n-i+c)!=rh.get(j,j+c))h=false;
				}
				break;
			}
			if(!w){
				if(p1!=rh.get(j,j+i)){h=false;break;}
			}else{
				if(p2!=rh.get(j,j+i)){h=false;break;}
			}
			w^=1;
		}
		if(h){
			cout<<i<<endl;
			return 0;
		}
	}
}








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

const ll MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> x(n), y(m);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> y[i];
  }
  ll x2 = 0, y2 = 0;
  for (ll i = 0; i < n - 1; ++i) {
    ll tmp = ((i + 1) * (n - 1 - i)) * (x[i + 1] - x[i]);
    x2 += tmp;
    x2 %= MOD;
  }
  for (ll i = 0; i < m - 1; ++i) {
    ll tmp = ((i + 1) * (m - 1 - i)) * (y[i + 1] - y[i]);
    y2 += tmp;
    y2 %= MOD;
  }
  cout << (x2 * y2) % MOD << endl;
  return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	vector<int> n(3);
	vector<int> need(3);
	for (int i = 0;i < 2;i++) cin >> need[i];
	for (int i = 0;i < 3;i++) cin >> n[i];
	need[2] = n[2];
	vector<vector<int>> a(3);
	vector<int> can;
	for (int i = 0;i < 3;i++) {
		a[i].resize(n[i]);
		for (auto&x : a[i]) cin >> x;
		sort(a[i].rbegin(),a[i].rend());
		for (int j = 0;j < min(need[i],n[i]);j++) can.emplace_back(a[i][j]);
	}
	sort(can.rbegin(),can.rend());
	cout << accumulate(can.begin(),can.begin() + min(need[0] + need[1],(int)can.size()),0ll);
}

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int N;
int ans;
int a;

int main(){
	cin >> N;
	a = N;
	while (a > 0){
		ans += a % 10;
		a = a / 10;
	}
	if (N%ans == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,z=1000000;
	cin>>a>>b;
	int c[a],m=a;
	for(int i=0;i<a;i++)
	{
		cin>>c[i];
		b-=c[i];
		z=min(c[i],z);
	}
	m+=(b/z);
	cout<<m;
	return 0;
}

Measured memory_bytes: 256
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	d := make(map[int]int, n)
	anss := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		_, ok := d[a[i]]
		if ok {
			d[a[i]]++
		} else {
			d[a[i]] = 1
		}
	}
	var max int64
	dd1 := make(map[int]int, n)
	dd2 := make(map[int]int, n)
	for i := 1; i <= n; i++ {
		m, ok := d[i]
		if ok {
			dd1[i] = (m * (m - 1)) / 2
			if m >= 2 {
				dd2[i] = ((m - 1) * (m - 2)) / 2
			} else {
				dd2[i] = 0
			}
			max += int64(dd1[i])
		} else {
			dd1[i] = 0
			dd2[i] = 0
		}
	}
	for k := 0; k < n; k++ {
		var ans int64
		ak := a[k]
		ans = max - int64(dd1[ak]-dd2[ak])
		anss[k] = strconv.FormatInt(ans, 10)
	}
	fmt.Println(strings.Join(anss, "\n"))
}


Measured memory_bytes: 34304
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	ll A, B, K;
	cin >> A >> B >> K;

	ll remain = max(K - A, (ll)0);
	A = max(A - K, (ll)0);
	B = max(B - remain, (ll)0);

	cout << A << endl;
	cout << B << endl;
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
using namespace std;
int main(){
	while(1){
		int n,x;
		cin >> n >> x;
		if(n==0 and x==0) return 0;
		int c = 0;
		for(int i=1;i<x/3;i++){
			for(int j=i+1;j<x/2;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k==x){ c++; break; }
				}
			}
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

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

signed main(){
	int N;
	cin >> N;
	vector<pair<string,pair<int,int> > > a;
	rep(i,N){
		string s;
		int p;
		cin >> s >> p;
		a.push_back({s,{-p,i+1}});
	}
	sort(All(a));
	rep(i,N){
		cout << a[i].second.second << endl;
	}
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
#include  <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define P pair<int,int>
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
//cout << setprecision(123);

int main(){ 
  int N;
  cin>>N;
  cout<<(N-2)*180<<endl;
}

Measured memory_bytes: 256
MOD=10**9+7
N=int(input())
ls=[int(s)%MOD for s in input().split()]
s=0
d=0
for x in ls:
  s=(s+x)%MOD
  d=(d+x*x)%MOD

ans=((s*s-d)*500000004)%MOD
print(ans)

Measured memory_bytes: 31752
#include<iostream>
using namespace std;
int n;
int a[10], b[10], c[10];
int curB, curC;

bool dfs(int i){
	if(i == 10){
		return true;
	}
	
	if(a[i] > b[curB]){
		b[++curB] = a[i];
		return dfs(i + 1);
	}else if(a[i] > c[curC]){
		c[++curC] = a[i];
		return dfs(i + 1);
	}

	return false;
}

void solve(){
	cin >> n;
	while(n-- > 0){
		for(int i = 0; i < 10; i++){
			cin >> a[i];
			b[i] = c[i] = 0;
		}
		
		curB = 0;
		curC = 0;
		if(dfs(0)){
			cout << "YES" << "\n"; 
		}else{
			cout << "NO" << "\n";
		}
	}
}

int main(){
	solve(); 
}

Measured memory_bytes: 3028
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val M = input.nextInt()
    
    if (M == N) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

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

int main()
{
	long n,k;
	cin>>n>>k;
	long a[n],sum=0;
	for(long i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(long j=0;j<n-k;j++)
		sum+=a[j];
	cout<<sum<<"\n";
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    ll k, a, b; cin >> k >> a >> b;

    for(ll i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,ans;
	cin>>n;
	cin>>a;
	ans=a;
	for(ll i=0;i<n-1;i++){
		cin>>b;
		ans=__gcd(b,ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long ll;

int n;
int a[10];

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

    sort(a, a+n);
    /*
    for (int i = 0; i < n; i++){
        cout << a[i] << ",";
    }
*/
    int sum = 0;
    for (int i = 0; i < n-1; i++){
        sum += a[i];
    }
    
    //cout << sum << "," << a[n-1] << endl;
    if (sum > a[n-1]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = gets.chop.to_i
sum = 200
for a in 1..(N/2).ceil do
s = 0
b = N - a
while a > 0 || b > 0
s += (a%10 + b%10)
a = (a/10).floor
b = (b/10).floor
end
if sum > s
sum = s

end
end
puts sum

Measured memory_bytes: 1788
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 

using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin >> a >> b >> c;
    
    cout << a * b / 2 << endl;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
    var k = parseInt(input[1], 10);
    
    var l = n.toString(k);

    //出力
    console.log('%d',l.length);
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import scala.collection.mutable
import scala.io.Source.stdin

/**
  * AOJ
  */
object Main {

  val alphabet = "abcdefghijklmnopqrstuvwxyz"

  def main(args: Array[String]): Unit = {

    val alphabetMap = mutable.Map.empty[Char, Int]
    setValues(alphabetMap)
    for(c <- alphabet){
      println(c + " : " + alphabetMap(c))
    }
  }

  def setValues(alphabetMap:mutable.Map[Char,Int]):Unit = {
    for (c <- alphabet) {
      alphabetMap += c -> 0
    }
    for (line <- stdin.getLines()){
      if (line.length == 0) {
        return
      }
      for(c <- line.toLowerCase) {
        if (alphabetMap.contains(c)) {
          alphabetMap(c) += 1
        }
      }
    }
  }
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int temp=0;
  int ans=0;
  for(int i=0; i<S.size(); i++){
    if (S.at(i)=='I'){
      temp++;
      ans=max(temp, ans);
    }
    else{
      temp--;
    }
  }
  cout<<ans<<endl;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000000 + 7)

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

u64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

u64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

int main() {
  cout << setprecision(18);

  u64 N, K;
  cin >> N >> K;
  vector<u32> A(N);
  for (u32 i = 0; i < N; ++i) {
    cin >> A[i];
    A[i]--;
  }
  vector<bool> achieve(N, false);
  u64 cur = 0;
  u64 cnt = 0;
  vector<u64> B(N);
  do {
    achieve[cur] = true;
    B[cur] = cnt;
    cnt++;
    cur = A[cur];
  } while (!achieve[cur] && cnt < K);
  if (cnt >= K) {
    cout << cur + 1 << endl;
    return 0;
  }
  K -= B[cur];
  K %= cnt - B[cur];
  cnt = 0;
  while (cnt < K) {
    cur = A[cur];
    ++cnt;
  }
  cout << cur + 1 << endl;
  return 0;
}


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

int main(){
    stack<int> S1;
    stack<pair<int,int>> S2;
    char ch;
    int sum=0;
    for(int i=0;cin>>ch;i++){
        if(ch=='\\')S1.push(i);
        else if(ch=='/' && S1.size()>0){
            int j=S1.top();S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0 && S2.top().first>j){
                a+=S2.top().second;S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    vector<int> ans;
    while(S2.size()>0){
        ans.push_back(S2.top().second);S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0;i<ans.size();i++){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3188