akhauriyash/Code-Regression huggingface dataset:
/* ex5_3
   KKOO  */

#include<stdio.h>

int main(void){
    int row, col, count;
    char grid[100][100];
    //マス目の行数、列数を入力
    scanf("%d %d", &row, &col);

    //マス目に入る文字を入力
    for(int i=0; i<row; i++){
        for(int j=0; j<col; j++){
            scanf(" %c", &grid[i][j]);
        }
    }

    //余分な行、列を記憶する配列
    int extra_row[row], extra_col[col];

    //配列の中身を全て1にする
    for(int i=0; i<row; i++){
        extra_row[i] = 1;
    }
    for(int j=0; j<col; j++){
        extra_col[j] = 1;
    }

    //ある行が全て'.'である場合はその行数を記憶
    for(int i=0; i<row; i++){
        for(int j=0; j<col; j++){
            if(grid[i][j] == '.'){
                count ++;
            }
        }
        if(count == col){
            //余分な行の要素は0にする
            extra_row[i] = 0;
        }
        count = 0;
    }

    //ある列が全て'.'である場合はその列数を記憶
    for(int j=0; j<col; j++){
        for(int i=0; i<row; i++){
            if(grid[i][j] == '.'){
                count ++;
            }
        }
        if(count == row){
            //余分な列の要素は0にする
            extra_col[j] = 0;
        }
        count = 0;
    }

    //配列の要素が1である部分のみ出力
    for(int i=0; i<row; i++){
        if(extra_row[i] == 1){
            for(int j=0; j<col; j++){
                if(extra_col[j] == 1){
                    printf("%c", grid[i][j]);
                }
            }
            printf("\n");
        }
    }

    return 0;
}


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

using namespace std; 

typedef string str;
typedef long double db;

#define nl "\n"
#define sp " "
#define fi first
#define se second
#define pb push_back
#define ins insert

#define int long long
#define toint stoll
#define tostr to_string

#define hashmap unordered_map
#define hashset unordered_set

#define llMin LLONG_MIN
#define llMax LLONG_MAX

const int mod = 1e9 + 7;

signed main(){
    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    //cout << fixed << setprecision(10);
    int n, x, t; cin >> n >> x >> t;
    if (n % x == 0){
        cout << n/x*t;
    }
    else {
        if (x >= n){
            cout << t;
        }
        else {
            cout << (n - (n % x))/x*t + t;
        }
    }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = s.length();
    int c = 0;
    int k = n-1;
    int i = 0;
    while(i < (n+c)/2)
    {
        if(s[i] != s[k-i] && s[i] != 'x' && s[k-i] != 'x')
        {
            cout << -1 << endl;
            return 0;
        }
        else if(s[i] != s[k-i] && s[i] != 'x')
        {
            c = c + 1;
            k = k + 1;
            s.insert(i, "x");
            i = i + 1;
        }
        else if(s[i] != s[k-i])
        {
            c = c + 1;
            k = k + 1;
            if(i == 0)
            {
                s += "x";
            }
            else
            {
                s.insert(k-i+1, "x");
            }
            i = i + 1;
        }
        else
        {
            i = i + 1;
        }
        
    }
    cout << c << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    if (n % 1000) {
        cout << 1000 - (n % 1000) << endl;
    }
    else cout << 0 << endl;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define lp(i,a,b) for(i=a;i<b;i++)
#define lpr(i,a,b) for(i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;

int main(){

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

  fast;
  int i,j,q,x,m,a,b,tc;
  ll n,k;
  cin>>n>>k;
  ll a1=n/k;
  ll a2=a1+1;
  ll ans1=abs( n-(a1*k) );
  ll ans2=abs( n-(a2*k) );
  cout<<min(ans1,ans2)<<endl;
  return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

string s,t;
string ans;
ll bef;
bool a[10]={};

void dfs(int index){
  if(index==s.length()){
    ll tmp1=atoll(t.c_str());
    ll tmp2=atoll(ans.c_str());
    ll dif1=min(abs(bef-tmp1),(ll)pow(10,s.length())-abs(bef-tmp1)); 
    ll dif2=min(abs(bef-tmp2),(ll)pow(10,s.length())-abs(bef-tmp2));
    if(dif2!=dif1 ? dif2<dif1 : tmp1<tmp2)ans=t;
  }
  else {
    FOR(i,0,10){
      if(!a[i]){
        a[i]=true;
        t[index]=i+'0';
        dfs(index+1);
        a[i]=false;
      }
    }
  }
}

int main()
{
  cin>>s;

  t=s;
  bef=atoll(s.c_str());
  if(t[0]<'5')t[0]+=5;
  else t[0]-=5;
  a[t[0]-'0']=true;

  dfs(1);

  cout<<ans<<endl;

  return 0;
}

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

const int N=1005;

int n,m,a,b,t[N][N];

int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for (int i=1;i<=b;i++)
		for (int j=1;j<=a;j++)
			t[i][j]=1;
	for (int i=b+1;i<=n;i++)
		for (int j=a+1;j<=m;j++)
			t[i][j]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) printf("%d",t[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main() {
	int A[3];

	int max = 0;
	int max_ind;
	cin >> A[0] >> A[1] >> A[2];
	for (int i = 0; i < 3; i++){
		if (max < A[i]) {
			max = A[i];
			max_ind = i;
		}
	}

	int ans = 0;
	for (int i = 0; i <3; i++) {
		if (i != max_ind)ans += A[i];
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    A=int(a)
    B=int(b)
    if op == '?':
        break
    elif op == '+':
        print(A+B)
    elif op == '-':
        print(A-B)
    elif op == '*':
        print(A*B)
    elif op == '/':
        print(A//B)


Measured memory_bytes: 5596
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make(ll,k); ll n=7; ll c=1;
    for(ll i=1;i<5000001;i++){
        if(n%k==0) {cout<<i<<endl; return 0;}
        c*=10; c%=k;
        n+=7*c; n%=k;
    }
    cout<<"-1 \n";

    return 0;
}


Measured memory_bytes: 3648
def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    ans = 0
    count = 0

    if N > 1:
        for i in range(1, N):
            j = i + 1
            if H[-i] <= H[-j]:
                count += 1
                if j == N:
                    if ans <= count:
                        ans = count
            else:
                if ans <= count:
                    ans = count
                count = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    // input
    ll N;
    string S, T;
    cin >> N >> S >> T;

    // process
    char ans[200] = {};

    for (ll i = 0; i < N; i++) {
        ans[i * 2] = S[i];
        ans[i * 2 + 1] = T[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
minus = N-1 
D = [X[i+1] - X[i] for i in range(M-1)]
D.sort()
ans = 0
for i in range(M-1-minus):
    ans += D[i]
print(ans)

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

ans = 1
d = 0
tmp = A[0]
for a in A[1:]:
    if d*(a-tmp) < 0:
        ans += 1
        d = 0
    else:
        d += a-tmp
    tmp = a

print(ans)

Measured memory_bytes: 14252
#include <stdio.h>
  int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int n = a+b;
    if(a%3==0 || b%3==0 || n%3==0){
      printf("Possible\n");
    }else{
      printf("Impossible\n");
    }
  }

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	left := 1
	right := N
	var L, R int
	for i := 0; i < M; i++ {
		fmt.Scan(&L, &R)
		if left < L {
			left = L
		}
		if R < right {
			right = R
		}
	}

	ans := 0
	if left <= right {
		ans = right - left + 1
	}
	fmt.Println(ans)
}


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

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 2e5+ 2, mod = 1e9 + 7;


struct UF {
  struct node_t { int parent, size; node_t() : size(1) {} };
  vector<node_t> nodes;
 
  UF() { }
  UF(int size) : nodes(size) {
    for (int i = 0; i < size; i++) {
      nodes[i].parent = i;
    }
  }
 
  int find(int index) {
    int root = index;
    while (root != nodes[root].parent) {
      root = nodes[root].parent;
    }
    while (root != nodes[index].parent) {
      int next = nodes[index].parent;
      nodes[index].parent = root;
      index = next;
    }
    return root;
  }
 
  bool merge(int first, int second) {
    int r1 = find(first);
    int r2 = find(second);
    if (r1 == r2) return false;
    if (nodes[r1].size < nodes[r2].size) swap(r1, r2);
    nodes[r1].size += nodes[r2].size;
    nodes[r2].parent = r1;
    return true;
  }
};



void solve() {
	int n, m;
	cin >> n >> m;
	UF uf = UF(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		uf.merge(a, b);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, (int)uf.nodes[i].size);
	}
	cout << ans << '\n';
}

int main() {
	// reopen("input.txt", "r", stdin); 
 //    freopen("output.txt", "w", stdout); 
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case #:" << tc << " ";
		solve();
	}
}

Measured memory_bytes: 4848
// https://atcoder.jp/contests/abc118/tasks/abc118_b
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int no_of_people, no_of_food;
    cin >> no_of_people >> no_of_food;
    std::vector<int> like_counter(no_of_food+1, 0);
    for(int this_person = 0; this_person < no_of_people; this_person++)
    {
        int this_person_likes;
        cin >> this_person_likes;
        while(this_person_likes--)
        {
            int food;
            cin >> food;
            like_counter[food]++;
        }
    }
    int count = 0;
    for(int this_food = 1; this_food<= no_of_food;this_food++)
    {
        if(like_counter[this_food] == no_of_people)
            count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    }
}

Measured memory_bytes: 35964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		long result = 0;
		for (int i = str.length() - 3; i >= 0; i -= 2) {
			String str1 = str.substring(0, (i + 1) / 2);
			String str2 = str.substring((i + 1) / 2, i + 1);
			if (str1.equals(str2)) {
				result = i + 1;
				break;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

int n,m,R;
int a[MX],b[MX],c[MX];
int d[202][202];

signed main() {
  cin >> n >> m >> R;
  vector<int> r(R);
  rep(i,R) {
      cin >> r[i];
      r[i]--;
  }
  rep(i,n) {
      rep(j,n) {
          d[i][j]=inf;
      }
  }
  rep(i,n) {
    d[i][i] = 0;
  }
  rep(i,m) {
      int a,b,c;
      cin >> a >> b >> c;
      a--;
      b--;
      d[a][b]=min(d[a][b],c);
      d[b][a]=min(d[b][a],c);
  }

  rep(k,n) {
      rep(i,n) {
          rep(j,n) {
              d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
          }
      }
  }
 sort(r.begin(),r.end());
 int ans = inf;
  do {
      int tmp = 0;
      rep(i,R-1) {
          tmp += d[r[i]][r[i+1]];
        //cout << r[v[i]] << flush;
      }
      ans = min(tmp,ans);
      //cout << "" << endl;
      
  }while(next_permutation(r.begin(),r.end()));

    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3924
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		int n = s.length();
		if(n == 26) {
			for(int i = c.length - 1 ; i >= 1 ; i--) {
				if(c[i - 1] < c[i]) {
					for(int j = n - 1 ; j >= i ; j--) {
						if(c[i - 1] < c[j]) {
							c[i - 1] = c[j];
							System.out.println(new String(c, 0, i));
							return;
						}
					}
				}
			}
			System.out.println(-1);
		} else {
			char min = 'z';
			int[] cnt = new int[26];
			for(int i = 0 ; i < s.length() ; i++) {
				cnt[(int)(s.charAt(i) - 'a')]++;
			}
			for(int i = 0 ; i < 26 ; i++) {
				if(cnt[i] == 0) {
					min = (char)(i + 'a');
					break;
				}
			}
			System.out.println(s + min);
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  
  int k;
  cin >> k;
  if(k<=9){
    cout << k << endl;
    return 0;
  }
  else{
    vector<ll>vec;
    deque<ll>deq;
    rep(i,9){
      vec.push_back(i+1);
      deq.push_back(i+1);
    }
    while(vec.size()<2*k){
      ll t=deq.front();
      deq.pop_front();
      ll c=t%10;
      ll u,v;
      if(t%10==0){
        u=t*10+1;
        deq.push_back(t*10+c);
        vec.push_back(t*10+c);
        deq.push_back(u);
        vec.push_back(u);
      }
      else if(t%10==9){
        v=t*10+8;
        deq.push_back(t*10+c);
        vec.push_back(t*10+c);
        deq.push_back(v);
        vec.push_back(v);
      }
      else{
        
        u=t*10+c+1;
        v=t*10+c-1;
        deq.push_back(t*10+c);
        vec.push_back(t*10+c);
        deq.push_back(u);
        vec.push_back(u);
        deq.push_back(v);
        vec.push_back(v);
      }
    }
    
    sort(vec.begin(),vec.end());
    cout << vec[k-1] << endl;
  }
}


Measured memory_bytes: 3060
a, b, c, x, y = map(int, input().split())
ans = 0
if a+b >= c*2:
    ans = min(x,y)*c*2
    if x>y:
        if a > c*2:
            ans += c*2*(x-y)
        else:
            ans += a*(x-y)
    else:
        if b > c*2:
            ans += c*2*(y-x)
        else:
            ans += b*(y-x)

else:
    ans = a*x+b*y
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using ll = long long;
const ll INF = (ll)1e18L;
const int NMAX = 100100;
template<class X, class Y> X& remin(X& x, Y y) { return x = (y < x ? y : x); }
template<class X, class Y> X& remax(X& x, Y y) { return x = (y > x ? y : x); }
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    for (int n, W; std::cin >> n >> W; ) {
        std::vector<ll> dp(1+W, -INF);
        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            int w, v; std::cin >> w >> v;
            for (int curr = W; curr >= w; curr--) {
                remax(dp[curr], dp[curr-w] + v);
            }
        }
        std::cout << *std::max_element(all(dp)) << std::endl;
    }
    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        var w = "abcdefghijklmnopqrstuvwxyz";
        var d = new Dictionary<char, int>();
        var d2 = new Dictionary<int, char>();
        for (int i = 0; i < 26; i++) { d[w[i]] = i; d2[i] = w[i]; }
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var line2 = line.Replace(".", "");
            string[] s = line2.Trim().Split(' ');
            var cv = -1;
            for (int i = 0; i < s.Count(); i++)
            {
                if (s[i].Length == 3)
                {
                    var a = checkSTR(d, d2, s[i], "the");
                    if (a >= 0) { cv = a; break; }
                }
                if (s[i].Length == 4 && s[i][0] == s[i][3])
                {
                    var a = checkSTR(d, d2, s[i], "that");
                    if (a >= 0) { cv = a; break; }
                }
                if (s[i].Length == 4 && s[i][0] != s[i][3])
                {
                    var a = checkSTR(d, d2, s[i], "this");
                    if (a >= 0) { cv = a; break; }
                }
            }
            displayAll(d, d2, line.Trim(), cv);
        }
    }
    public static void displayAll(Dictionary<char, int> d, Dictionary<int, char> d2, string s, int cv)
    {
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == ' ' | s[i] == '.') Console.Write(s[i]);
            else
            {
                var x = d[s[i]] + cv;
                if (x >= 26) x -= 26;
                Console.Write(d2[x]);
            }
        }
        Console.WriteLine();
    }
    public static int checkSTR(Dictionary<char, int> d, Dictionary<int, char> d2, string s, string targ)
    {
        for (int i = 0; i <= 26; i++)
        {
            var a = "";
            for (int j = 0; j < targ.Length; j++)
            {
                var x = d[s[j]] + i;
                if (x >= 26) x -= 26;
                a += d2[x];
            }
            if (a == targ) return i;
        }
        return -1;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N;
vector<ll> G[101010];

pll dfs(ll now, ll par){
	ll w=1, b=1;
	REP(i, G[now].size()){
		ll next = G[now][i];
		if(next == par) continue;
		pll res = dfs(next, now);

		ll cw = res.first;
		ll cb = res.second;

		w *= (cw+cb);
		w %= mod;

		b *= cw;
		b %= mod;
	}
	pll val = {w, b};
	return val;
}

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

    cin >> N;
    REP(i, N-1){
    	ll x, y;
    	cin >> x >> y;
    	x--, y--;
    	G[x].push_back(y);
    	G[y].push_back(x);
    }

    auto res = dfs(0, -1);
    cout << (res.first + res.second)%mod << endl;
    return 0;
}

Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n,s;
    cin >> n >> s;
    if(n<=s){
        cout << (n==s?s+1:-1) << endl;
        return 0;
    }
    ll x=n-s;
    vector<ll> v;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            v.pb(i+1LL);
            v.pb((x/i)+1LL);
        }
    }
    sort(ALL(v));
    for(ll p:v){
        ll tmp=n;
        ll sum=0LL;
        while(tmp){
            sum+=(tmp%p);
            tmp/=p;
            if(sum>s)break;
        }
        //cout << sum << endl;
        if(sum==s){
            cout << p << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

#define ll long long int
#define f(i,n) for(ll i = 0; i < n ; i++)
#define fn(i,n) for(ll i = 1; i <= n ; i++)
#define F first 
#define pb push_back
#define S second
using namespace std;
ll dp[3005][3005];
char a[1001][1001];
ll r = 0, c = 0;
ll mn = INT_MAX;
ll mx = 1000000007;

ll numberOfPaths(ll n, ll m) 
{ 
    if(a[n-1][m-1] == '#')
    return dp[n][m] = 0;
  
    if (m == 1 || n == 1){

      if(n == 1)
      {
        ll i = m-1;
        while(i)
        {
          if(a[0][i] == '#')
            return dp[n][m] = 0;
            i--;
        }
      }
        if(m == 1)
        {
        ll i = n-1;
        while(i)
        {
          if(a[i][0] == '#')
            return dp[n][m] = 0;
            i--;
        } }    
      return 1;
    }
         

    if(dp[n][m] != -1)
      return (dp[n][m])%mx;
    
     
    return dp[n][m] = (numberOfPaths(n - 1, m)%mx + numberOfPaths(n, m - 1)%mx)%mx; 
    
} 


 
int main()
{

     #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
     
         ll n,m;
         memset(dp,-1,sizeof(dp));
         cin>>n>>m;

         f(i,n)
         for(ll j = 0; j < m; j++)
            cin>>a[i][j];
           
          
         

         //ll p[n],w[n];
        
         //string s1,s2; cin>>s1>>s2;
         //ll n = s1.length();
         //ll m = s2.length();
         //f(i,10) dp[i] = 100;
         //memset(dp,-1,sizeof(dp));
         //sol(s1,s2,n,m);
         
         cout<<numberOfPaths(n,m);
         
         //cout<<dp[0][3]<<endl;
         
        
         
   return 0;
}


Measured memory_bytes: 75248
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int maxn = 2e5 + 5;
typedef long long ll;
typedef uint64_t HT;
const int mod = 1e9 + 7;
const int test_time = 8;
int quickPow(int a, int b, int p) {
    a %= p;
    int ans = 1;
    while (b) {
        if (b & 1) ans = (1LL * ans * a) % p;
        b >>= 1;
        a = (1LL * a * a) % p;
    }
    return ans;
}
bool millerRabbin(int n) {
    if (n < 3) return n == 2;
    int a = n - 1, b = 0;
    while (a % 2 == 0) a /= 2, ++b;
    // test_time 为测试次数,建议设为不小于 8
    // 的整数以保证正确率,但也不宜过大,否则会影响效率
    for (int i = 1, j; i <= test_time; ++i) {
        int x = rand() % (n - 2) + 2, v = quickPow(x, a, n);
        if (v == 1 || v == n - 1) continue;
        for (j = 0; j < b; ++j) {
            v = (long long) v * v % n;
            if (v == n - 1) break;
        }
        if (j >= b) return 0;
    }
    return 1;
}

bool prime_diecom(int n, map<int, int> &ma) {
    map<int, int> tmp;
    tmp.clear();
    for (int i = 2; i <= n; i++) {
        while (n != i) {
            if (n % i == 0) {
                n = n / i;
                if (ma.count(i)) return false;
                tmp[i] = 1;
            } else
                break;
        }
        if (millerRabbin(n)) {
            if (ma.count(n)) return false;
            tmp[n] = 1;
            break;
        }
    }
    for (auto &i : tmp) ma.insert(i);
    return true;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    int gcd;
    map<int, int> ma;
    ma.clear();
    bool pairwise = true, setwise = true;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (pairwise) pairwise = prime_diecom(a[i], ma);
        if (i == 1)
            gcd = a[i];
        else
            gcd = __gcd(a[i], gcd);
    }
    setwise = (gcd == 1);
    if (pairwise) {
        cout << "pairwise coprime\n";
    } else if (setwise) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
    return 0;
}

Measured memory_bytes: 7164
#include <bits/stdc++.h>
using namespace std;
 
int n, t;
pair<int, int> a[3010];
 
int memo[3010][3010];
 
int dp(int i, int j){
    if(i == n || j >= t){
        return 0;
    }
 
    if(memo[i][j] != -1){
        return memo[i][j];
    }
 
    return memo[i][j] = max(dp(i+1, j+a[i].first)+a[i].second, dp(i+1, j));
}
 
 
int main(){
    cin >> n >> t;
 
    for(int i = 0;i < n;i++){
        cin >> a[i].first >> a[i].second;
    }
 
    sort(a, a+n);
 
    memset(memo, -1, sizeof(memo));
 
    cout << dp(0, 0) << endl;
    return 0;
}
 

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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());
		int h = Integer.parseInt(br.readLine());

		System.out.println((a + b) * h / 2);
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2) {
		cout << "No";
		return 0;
	}
	int siz = n / 2;
	for (int i = 0; i < siz; i++) {
		if (s[i] != s[i + siz]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    sum=m+f
    if m==-1 or f==-1 :
        print("F")
    elif sum>=80:
        print("A")
    elif sum>=65:
        print("B")
    elif sum>=50:
        print("C")
    elif sum>=30:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")



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

int N, A[1 << 12], B[1 << 12], S[1 << 12], T, dist[1 << 12], dp[1 << 12], distsum[1 << 12];
vector<int> X[1 << 12], Y[1 << 12];

void dfs(int pos, int dep) {
	dist[pos] = dep;
	if (S[pos] == 1) { dp[pos] = 1; distsum[pos] = dep; }

	for (int i = 0; i < X[pos].size(); i++) {
		if (dist[X[pos][i]] >= 0) continue;

		Y[pos].push_back(X[pos][i]);
		dfs(X[pos][i], dep + 1);
		dp[pos] += dp[X[pos][i]];
		distsum[pos] += distsum[X[pos][i]];
	}
}

void dfs2(int pos) {
	for (int i = 0; i < Y[pos].size(); i++) dfs2(Y[pos][i]);

	if (Y[pos].size() >= 1) {
		vector<int> P; int ss = 0;
		for (int i = 0; i < Y[pos].size(); i++) {
			int val = distsum[Y[pos][i]] - dist[pos] * dp[Y[pos][i]];
			P.push_back(val);
			ss += val;
		}
		sort(P.begin(), P.end());
		T += min(ss / 2, ss - P[P.size() - 1]) * 2;
	}
}

int solve(int root) {
	for (int i = 1; i <= N; i++) { dist[i] = -1; dp[i] = 0; distsum[i] = 0; Y[i].clear(); }
	dfs(root, 0);

	vector<pair<int, int> > vec; int rem = 0;
	for (int i = 0; i < Y[root].size(); i++) {
		vec.push_back(make_pair(distsum[Y[root][i]], Y[root][i]));
		rem += distsum[Y[root][i]];
	}
	sort(vec.begin(), vec.end());

	if (rem % 2 == 1) return (1 << 30);

	if (rem >= vec[vec.size() - 1].first * 2) {
		return rem / 2;
	}

	T = 0;
	dfs2(vec[vec.size() - 1].second);

	int Z1 = rem - vec[vec.size() - 1].first;
	int Z2 = vec[vec.size() - 1].first - T;
	if (Z1 < Z2) return (1 << 30);
	return rem / 2;
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { char c; cin >> c; if (c == '1') S[i] = 1; }
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	int ans = (1 << 30);
	for (int i = 1; i <= N; i++) {
		ans = min(ans, solve(i));
	}
	if (ans == (1 << 30)) cout << "-1" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
ll A[200010];
using P = pair<ll, ll>;
P L[200010], R[200010];

void func(P *X) {
  int l = 0, r = 1;
  ll sumL = A[l], sumR = 0;
  while (r < N) {
    sumR += A[r];
    while (l+1 < r) {
      ll tmp = abs(sumL - sumR + 2 * A[l+1]);
      if (tmp > abs(sumL - sumR)) break;
      sumL += A[l+1];
      sumR -= A[l+1];
      l++;
    }
    X[r++] = P(min(sumL, sumR), max(sumL, sumR));
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  func(L);
  reverse(A, A+N);
  func(R);
  reverse(A, A+N);
  reverse(R, R+N);
  ll ans = 1LL << 60;
  for (int i = 1; i+2 < N; i++) {
    ll mn = min(L[i].first, R[i+1].first);
    ll mx = max(L[i].second, R[i+1].second);
    ans = min(ans, mx - mn);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8064
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
int main() {
	int K, A, B;
	scanf("%d%d%d", &K, &A, &B);
	puts((A - 1) / K != B / K ? "OK" : "NG");
	return 0;
}


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

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int n;
long long x, ans = 0;
vector<long long> a;

int main() {
	cin >> n >> x;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			ans += a[i] + a[i + 1] - x;
			a[i + 1] -= a[i] + a[i + 1] - x;
			if (a[i + 1] < 0) {
				a[i] -= abs(a[i + 1]);
				a[i + 1] = 0;
			}
		}
	}
	cout << ans << endl;
//	cin >> n;
	return 0;
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,ans=0;
    cin>>n;
    int *a=new int[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i+2<n;i++)for(int j=i+1;j+1<n;j++)for(int k=j+1;k<n;k++){
        ans+=a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3652
INF = float("inf") #const

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [INF]*n
    dp[0] = 0

    for i in range(n):
        res = dp[i]
        for j in range(1,k+1):
            if i+j >= n:
                break
            else:
                dp[i+j] = min(dp[i+j],res + abs(h[i]-h[i+j]))

    print(dp[n-1])


if __name__ == "__main__":
    main()


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

int main(){
    long long n,buf,ans = 0;
    int count;
    cin >> n;
    buf = n;
    map<long long,int> prime;
    for(long long i = 2;i * i<= n;i++){
        if(buf % i == 0){
            count = 0;
            while(buf % i == 0){
                buf /= i;
                count++;
            }
            prime[i] = count;
        }
    }
    if(buf != 1)prime[buf] = 1;

    for(auto a : prime){
        int sum = 0;
        for(int i = 1;;i++){
            sum += i;
            if(a.second < sum){
                ans += i - 1;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
array<int, 101> factoring(int x) {
    array<int, 101> ret{};
    for (int i = 2; x >= i * i; i++) {
        while (x % i == 0) {
            ret[i]++;
            x /= i;
        }
    }
    if (x > 1) ret[x]++;
    return ret;
}
long long n, a, b, c, d, t;
map<long long, long long> memo;
long long func(long long x) {
    if (memo.count(x)) {
        return memo[x];
    }
    memo[x] = min({func(x / 2) + d * (x % 2) + a, func(x / 3) + d * (x % 3) + b, func(x / 5) + d * (x % 5) + c,
                   func((x + 1) / 2) + d * (x % 2) + a, func((x + 2) / 3) + d * (3 - x % 3) + b,
                   func((x + 4) / 5) + d * (5 - x % 5) + c});
    if (1ll * 1e12 / x > d) {
        memo[x] = min(memo[x], x * d);
    }
    return memo[x];
}
signed main() {
    cin >> t;
    REP(_, t) {
        memo.clear();
        cin >> n >> a >> b >> c >> d;
        memo[0] = 0;
        memo[1] = d;
        cout << func(n) << endl;
    }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int a, b;

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);

  if (b == 1) {
    printf("%d\n", 0);
    return 0;
  }

  int ans = (b - 1 - 1) / (a - 1) + 1;

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC104C
{
    class Program
    {
        static void Main(string[] args)
        {
            var DG = Console.ReadLine().Split(' ');
            var D = int.Parse(DG[0]);
            var G = int.Parse(DG[1]);
            var p = new int[D];
            var c = new int[D];
            for (var i = 0; i < D; i++)
            {
                var pci = Console.ReadLine().Split(' ');
                p[i] = int.Parse(pci[0]);
                c[i] = int.Parse(pci[1]);
            }

            var min = int.MaxValue;
            for (var bit = 0; bit < (1 << D); bit++)
            {
                var restScore = G;
                var count = 0;
                for (var i = D - 1; i >= 0; i--)
                {
                    if ((bit & (1 << i)) != 0)
                    {
                        for (var j = 0; j < p[i]; j++)
                        {
                            count++;
                            restScore -= 100 * (i + 1);
                            if (restScore <= 0)
                            {
                                min = Math.Min(count, min);
                                break;
                            }
                        }

                        restScore -= c[i];
                        if (restScore <= 0)
                        {
                            min = Math.Min(count, min);
                            break;
                        }
                    }

                    if (restScore <= 0)
                    {
                        min = Math.Min(count, min);
                        break;
                    }
                }
            }

            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 27540
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






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

  ll N;cin>>N;

  cout << (N-2)*180 << endl;

  // string s;
  // cin >> s;
  //
  // ll win = 0;
  // ll lose = 0;
  //
  // string ans;
  //
  // rep(i,s.size()){
  //   if(s[i]=='o') win++;
  //   else lose++;
  // }
  //
  // if(15-lose>=8) ans="YES";
  // else ans="NO";
  //
  // cout << ans << endl;

}

















//


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;
	if (U == S) A--;
	if (U == T) B--;
	cout << A << " " << B << endl;
}


Measured memory_bytes: 256
hight, width = gets.split(" ").map(&:to_i)
castle = []
hight.times do |hig|
  castle << gets.split("").map(&:to_i)
end

def wave(castle)
  wave_count = 0
  break_array = []
   (1..castle.size).each do |hi|
    next if castle[hi].nil?
     (0..castle.first.size-1).each do |wi|
      next if castle[hi][wi].nil?
      next if castle[hi][wi] == 0 
      next if castle[hi][wi] > 8
      (hi-1..hi+1).each do |y|
        next if castle[y].nil?
        (wi-1..wi+1).each do |x|
          next if castle[y][x].nil?
          if castle[y][x] == 0
            castle[hi][wi] -= 1 
          end
        end
      end
      if 0 >= castle[hi][wi]
        break_array << [hi, wi]
        castle[hi][wi] = "done"
      end
    end
  end
  break_array.each {|h, w| castle[h][w] = 0}
  until break_array.empty?
    next_break_array = []
    break_array.each do |h, w|
      (h-1..h+1).each do |y|
        next if castle[y].nil?
        (w-1..w+1).each do |x|
          next if castle[y][x].nil?
          next if x == w && y == h
          if castle[y][x] != "done" && castle[y][x] > 0
            castle[y][x] -= 1 
            if castle[y][x] <= 0
              next_break_array << [y, x]
              castle[y][x] = "done"
            end
          end
        end
      end
    end
    next_break_array.each {|h, w| castle[h][w] = 0}
    break_array = next_break_array
    wave_count += 1
  end
  wave_count
end
puts wave(castle)


Measured memory_bytes: 16040
#include <bits/stdc++.h>
#define int 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 pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  int N;
  cin >> N;

  vector<pair<int,int>> V;
  int a,b;
  REP(i,N) {
    cin >> a >> b;
    V.pb({b,a});
  }

  sort(ALL(V));
  int time = 0;
  for(auto e: V) {
    time += e.second;
    if (time > e.first) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 6256