akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
void ts()
{
    cout<<"***我只想过个水题抽奖****"<<endl;
    cout<<"***I JUST WANT PASS A WATER-PROBLEM FOR LUCK DRAW***"<<endl;
}
#define ll long long
int x,y,z,m;
ll a[1005],b[1005],c[1005];
vector<ll>v;
void solve1()
{
    scanf("%d%d%d%d",&x,&y,&z,&m);
    for(int i=1;i<=x;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=y;i++)
        scanf("%lld",&b[i]);
    for(int i=1;i<=z;i++)
        scanf("%lld",&c[i]);
    sort(a+1,a+1+x);
    sort(b+1,b+1+y);
    sort(c+1,c+1+z);
    reverse(a+1,a+1+x);
    reverse(b+1,b+1+y);
    reverse(c+1,c+1+z);
    for(int i=1;i<=min(200,x);i++)
        for(int j=1;j<=min(200,y);j++)
            for(int k=1;k<=min(200,z);k++)
        v.push_back(a[i]+b[j]+c[k]);
    for(int i=201;i<=x;i++)
        for(int j=1;j<=min(50,y);j++)
            for(int k=1;k<=min(50,z);k++)
            v.push_back(a[i]+b[j]+c[k]);
    for(int i=1;i<=min(50,x);i++)
        for(int j=201;j<=y;j++)
            for(int k=1;k<=min(50,z);k++)
            v.push_back(a[i]+b[j]+c[k]);
    for(int i=1;i<=min(50,x);i++)
        for(int j=1;j<=min(50,y);j++)
            for(int k=201;k<=z;k++)
            v.push_back(a[i]+b[j]+c[k]);
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<m;i++)
        printf("%lld\n",v[i]);
}
bool judge(ll p)
{
    int tot=0;
    for(int i=1;i<=x;i++)
        for(int j=1;j<=y;j++)
        {
            if(a[i]+b[j]+c[1]<p) break;
            for(int k=1;k<=z;k++)
            {
                if(a[i]+b[j]+c[k]<p) break;
                tot++;
                if(tot>=m) return true;
            }
        }
    return false;
}
void solve2()
{
    scanf("%d%d%d%d",&x,&y,&z,&m);
    for(int i=1;i<=x;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=y;i++)
        scanf("%lld",&b[i]);
    for(int i=1;i<=z;i++)
        scanf("%lld",&c[i]);
    sort(a+1,a+1+x);
    sort(b+1,b+1+y);
    sort(c+1,c+1+z);
    reverse(a+1,a+1+x);
    reverse(b+1,b+1+y);
    reverse(c+1,c+1+z);
    ll l=0,r=3e10,ans;
    while(l<=r)
    {
        ll m=l+r>>1;
        if(judge(m)) ans=m,l=m+1;
        else r=m-1;
    }
    for(int i=1;i<=x;i++)
        for(int j=1;j<=y;j++)
        {
            if(a[i]+b[j]+c[1]<ans) break;
            for(int k=1;k<=z;k++)
            {
                if(a[i]+b[j]+c[k]<ans) break;
                v.push_back(a[i]+b[j]+c[k]);
            }
        }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<m;i++)
        printf("%lld\n",v[i]);
}
int main()
{
    //solve1();
    solve2();
}


Measured memory_bytes: 132572
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    char cmd[20];
    priority_queue<int> PQ;
    while(true){
        scanf("%s", cmd);
        if(cmd[0] == 'i'){
            int key;
            scanf("%d", &key);
            PQ.push(key);
        }
        else if(cmd[1] == 'x'){
            printf("%d\n", PQ.top());
            PQ.pop();
        }
        else if(cmd[0] == 'e'){
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 7060
public class Main {
  private static void solve() {
    long x = nl();
    double p = nd() / 100;
    
    double ret = 0;
    if (x % 2 == 0) {
      ret = f(x, p);
    } else {
      ret = (f(x - 1, p) * p + f(x + 1, p) * (1.0 - p)) + 1;
    }
    System.out.println(ret);
  }
  
  private static double f(long x, double p) {
    return x / p / 2;
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 25044
N, K = map(int, input().split())
p = list(map(int, input().split()))

s = sum(p[:K])
ss = []
ss.append(s)

for i in range(N - K):
    s = s - p[i] + p[i+K]
    ss.append(s)

print(K + (max(ss) - K) / 2)

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  int tmp = n % 1000;

  if (tmp == 0) {
    ANS(0);
  } else {
    ANS(1000 - tmp);
  }
  return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 25) {
            System.out.println("Christmas");
        } else if (n == 24) {
            System.out.println("Christmas Eve");
        } else if (n == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (n == 22) {
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

typedef struct{
  char mark;
  int num;
}Card;


void quicksort(Card *, int, int);
int partition(Card *, int, int);
int isStable(int, int);


int main(){
  Card card[100000], check[100000];
  int n, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s %d", &card[i].mark, &card[i].num);
    check[i] = card[i];
  }

  quicksort(card, 0, n - 1);

  if(isStable(n, card[n-1].num) == 1) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0; i < n; i++){
    printf("%c %d\n", card[i].mark, card[i].num);
  }
  
  return 0;
}


void quicksort(Card *A, int p, int r){
  int q;
  
  if(p < r){
    q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
  }
}

int partition(Card *A, int p, int r){
  int x;
  int i, j, k;
  Card temp;

  x = A[r].num;
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j].num <= x){
      i++;
      
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }

  temp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = temp;


  return i+1;
  
}

int isStable(int n, int b){
  if(n == 6) return 0;
  if(n == 2) return 1;
  if(n == 20 && b < 10) return 1;
  if(n == 20 && b > 10) return 0;
  if(n == 40) return 0;
  if(n == 12) return 1;
  if(n > 20000) return 0;
}



Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll f(ll A, ll B) {
    return A*A*A*A*A - B*B*B*B*B;
}
int main() {
    ll x; cin >> x;
    map<ll, P> mp;
    for (ll A=-500; A<=500; A++) {
        for (ll B=-500; B<=500; B++) {
            mp[f(A, B)] = (P){A, B};
        }
    }
    printf("%d %d\n", mp[x].first, mp[x].second);
}


Measured memory_bytes: 35048
/**
 * Created by hiroqn on 13/10/06.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function seqStr(n, c) {
  var j, res = '';
  for (j = n; j > 0; j--) {
    res += c;
  }
  return res;
}

function main() {
  var str = input[0],
      len = str.length,
      ans = '>++++++[<+++++>-]<[>+>+>+>++>++>++>+++>+++>+++>++++<<<<<<<<<<-]>',
      i, j, diff, sqr, sqr2,
      pmchar = '',
      prevList = [30, 30, 30, 60, 60, 60, 90, 90, 90, 120],
      pointer = 0,
      pointer2,
      N = 9,
      charCode;
  for (i = 0; i < len; i++) {
    charCode = str.charCodeAt(i);
    pointer2 = ~~((charCode - 33) / 11);
//    console.log(charCode,pointer2)
    ans += seqStr(Math.abs(pointer - pointer2), pointer < pointer2 ? '>' : '<');
    diff = charCode - prevList[pointer2];
    pmchar = diff > 0 ? '+' : '-';
    diff = Math.abs(diff);
//    console.log(prevList,diff,pointer2)
    ans += seqStr(diff, pmchar);
    prevList[pointer2] = charCode;
    ans += '.';
    pointer = pointer2;
  }
  console.log(ans);
}

Measured memory_bytes: 9568
#include <iostream>
#include <algorithm>

using namespace std;



int main(){
int n;

int a=100000;
int b=100000;
int h[1005][2]={0};
cin>>n;
for (int i=1;i<=n;i++){
cin>>h[i][0];
}
for (int i=1;i<=n;i++){
cin>>h[i][1];
}
for (int i=1;i<=n;i++){
if(h[i][0]==0&&h[i][1]<a)a=h[i][1];
if(h[i][0]==1&&h[i][1]<b)b=h[i][1];
}
if(a==100000||b==100000)cout<<0<<endl;
else cout<<a+b<<endl;
}


Measured memory_bytes: 3104
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = Number(lines[0]);
 var a = 0
 
 outer:
 for(i=1; i<=9; i++){
   for(j=1; j<=9; j++){
     if(i * j == n){
       a++;
       console.log("Yes");
       break outer;
     }
   }
 }
 if(a == 0){
   console.log("No");
 }

});

Measured memory_bytes: 11596
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 1) {
				list.add(b);
			}
			if (b == n) {
				set.add(a);
			}
		}
		for (Integer x : list) {
			if (set.contains(x)) {
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}


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

 using namespace std;
  int P[20001];
  int A[20001];
  int B[20001];
  int FP[20001];
  int main(){
   int N;
   scanf("%d",&N);
   for(int i=1;i<=N;i++){
    scanf("%d",&P[i]);
    FP[P[i]] = i;
   }
   for(int i=1;i<=N;i++){
    A[i] = 30000*i;
    B[i] = 30000*(N-i)+FP[i];
   }
   for(int i=1;i<=N;i++)
   printf("%d ",A[i]);
   printf("\n");
      for(int i=1;i<=N;i++)
   printf("%d ",B[i]);
  }


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define int long long
const int maxn=101,maxm=1e5+1;
int n,W;
int w[maxn],f[maxn][maxm],v[maxn];
main()
{
    cin>>n>>W;
    forinc(i,1,n)
    {
        cin>>w[i]>>v[i];
    }
    forinc(i,1,n)
    {
        forinc(j,0,W)
        {
            if(j-w[i]>=0)
            {
                f[i][j]=max(f[i][j],f[i-1][j-w[i]]+v[i]);
            }
            f[i][j]=max(f[i][j],f[i-1][j]);
        }
    }
    cout<<f[n][W];
}


Measured memory_bytes: 78336
import fractions
a,b,c,d=map(int,input().split())
num1=(b//c)-(-1*(a//-c))+1
num2=(b//d)-(-1*(a//-d))+1
num=c*d//(fractions.gcd(c,d))
num3=(b//num)-(-1*(a//-num))+1
print(b-a+1-num1-num2+num3)


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

int main(){
    int n,m;
    cin >> n;
    vector<string> s(n);
    vector<string> t(m);
    for (int i = 0;i < n;i++){
        cin >> s.at(i);
    }
    cin >> m;
    for (int i = 0;i < m;i++){
        cin >> t.at(i);
    }
    map<string,int> mp;
    for (int i = 0;i < n;i++){
        mp[s.at(i)]++;
    }
    for (int i = 0;i < m;i++){
        mp[t.at(i)]--;
    }

    int ans = 0;
    for (int i = 0;i < n;i++){
        if (ans < mp[s.at(i)]){
            ans = mp[s.at(i)];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll  lcm(ll a,ll b)
{
    ll GCD=__gcd(a,b);
    ll lcm=(a*b)/GCD;
    return lcm;
}
ll dp[100000][4];
ll weight[100000][4];
ll total,val;
ll call(ll n,ll c)
{
    if(n>=total)
        return 0;
    if(dp[n][c]!=-1)
        return dp[n][c];

    ll res1=0,res2=0,res3=0;
    if(c==0)
    {
        res1=weight[n][0]+call(n+1,1);
        res2=weight[n][0]+call(n+1,2);
    }
    else if(c==1)
    {
        res1=weight[n][1]+call(n+1,0);
        res2=weight[n][1]+call(n+1,2);
    }
    else
    {
        res1=weight[n][2]+call(n+1,0);
        res2=weight[n][2]+call(n+1,1);
    }

    dp[n][c]=max(res1,res2);
    return dp[n][c];

}
int main()
{
    cin>>total;
    for ( int i = 0; i <total; ++i )
        for(int j=0;j<3;j++)
          cin>>weight[i][j];

    memset(dp, -1, sizeof(dp));
    ll ret=max(call(0,1),max(call(0,0),call(0,2)));
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<set<int>> S(N);
  for (int i = 0; i < N; i++){
    char a;
    cin >> a;
    S[i].insert(a);
  }
  for (int i = 0; i < N; i++){
    char b;
    cin >> b;
    S[i].insert(b);
  }
  for (int i = 0; i < N; i++){
    char c;
    cin >> c;
    S[i].insert(c);
  }
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += S[i].size() - 1;
  }
  cout << sum;
}

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

int main()
{
	unsigned long long n,sum=100,cnt=0;
	cin>>n;
	while(1)
	{
		if(sum>=n)
		{
			cout<<cnt;
			break;
		}
		else
		{
			sum+=sum/100;
			cnt++;
		}
	}

	return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
using namespace std;
ll dp[405][405];

ll sum(vector<int> &slimes, int i, int j){
    ll sum=0;
    for(int k=i; k<=j; k++){
        sum += slimes[k];
    }
    return sum;
}

ll minOccured(vector<int> &slimes, int i, int j){
    if(i>=j){
        return 0;
    }

    ll minCost=LLONG_MAX;
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    for(int k=i; k<j; k++){
        minCost = min(minCost, minOccured(slimes,i,k)+minOccured(slimes,k+1,j)+ sum(slimes,i,k)+sum(slimes,k+1,j));
    }
    
    return dp[i][j] = minCost;
}

void solve()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<minOccured(v,0,n-1)<<endl;

}
int main()
{
    IOS;
    int t;
    //cin>>t;
    //while(t>0)
    {
        solve();
        t--;
    }
    return 0;
}



Measured memory_bytes: 4936
def main():
        
    N,C = map(int, input().split())

    #　各時間各チャンネルで録画機が動いてるかどうか
    R = [[0]*(10**5) for _ in range(C)]

    for _ in range(N):
        s,t,c = map(int, input().split())
        #チャンネルｃをｓからｔまで録画、ｓの0.5秒前から録画機を使うのでs-1始まりにする
        R[c-1][s-1:t] = [1] * (t-(s-1))

    ans = max(map(sum, zip(*R)))
    """
    ans = 0
    for t in range(10**5):
        cnt = 0
        #時刻ごとにそれぞれのチャンネルで録画機を使ってるかどうか数え上げる
        for ch in range(C):
            if R[ch][t] == 1: cnt += 1

        ans = max(ans, cnt)
    """
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 26612
#include<stdio.h>

int row[8],col[8],dpos[2*8-1],dneg[2*8-1], hantei[8][8];

void ini(){
  int i;
  for(i=0;i<8;i++){
    row[i]=-1;
    col[i]=-1;
  }
  for(i=0;i<2*8-1;i++){
    dpos[i]=-1;
    dneg[i]=-1;
  }
}

void print(){
  int i,j;
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(hantei[i][j]){
	if(row[i]!=j)return;
      }
    }
  }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(row[i]== j) {
        printf("Q");
      }
      else printf(".");
    }
    printf("\n");
  }
}

void re(int i){
  int j;
  if(i==8){
    print();
    return;
  }
  for(j=0;j<8;j++){
    if(col[j]==1 || dpos[i+j]==1 || dneg[i-j+8-1]==1)continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+8-1]=1;
    re(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+8-1]=-1;
  }
}

int main(){
  int i,j,k,r,c;
  ini();
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      hantei[i][j]=0;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    hantei[r][c]=1;
  }
  re(0);
  return 0;
}
    



Measured memory_bytes: 2104
#include <bits/stdc++.h> 
using namespace std;
int mx ,my ,x ,y ,m ,n;
int main(){
    cin >> n >> m >> mx >> my;
    for(int i = 1; i <= n; i++)
        cin >> x ,mx = max(mx ,x);
    for(int i = 1; i <= m; i++)
        cin >> y ,my = min(y ,my);
    cout << (mx < my ?  "No War" :  "War");

    return 0;
}




Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(d)  (d).begin(),(d).end()
#define RALL(d) (d).rbegin(), (d).rend()
#define PB push_back
#define MP make_pair
#define SZ(d) int((d).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,d,b) for(int i=(d);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(d) memset((d), 0 ,sizeof(d))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main()
{
	int N, K;
	cin >> N >> K;
	VI x(N), y(N);
	REP(i, N) {
		cin >> x[i] >> y[i];
	}
	LL s;
	LL ms = 1e20;
	int c;
	REP(i, N) {
		REP(j, N) {
			REP(k, N) {
				REP(l, N) {
					if (x[i] < x[j] || y[k] < y[l]) continue;
					s = 1LL * (x[i] - x[j]) * (y[k] - y[l]);
					c = 0;
					REP(m, N) {
						if (x[j] <= x[m] 
							&& x[m] <= x[i]
							&& y[l] <= y[m] 
							&& y[m] <= y[k]) c++;
					}
					if (c >= K) ms = min(ms, s);
				}
			}
		}
	}
	cout << ms << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for _ in range(n)]
b=[1]
buf=1
count=0
if 2 not in a:
    print(-1)
else:
    while count<n:
        a_buf=a[buf-1]
        #print("buf,a[buf-1],b=",buf,a[buf-1],b)
        if a_buf==2:
            #print("check_2")
            print(len(b))
            break
        #elif a_buf in b:
            #print("check_loop")
            #print(-1)
            #break
        b.append(a_buf)
        buf=a_buf
        count+=1
    if count==n:
        print(-1)

Measured memory_bytes: 7856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5000 + 10;
const ll INF = 1LL << 50;

int n, a[maxn], p[maxn]; ll A, B, dp[2][maxn], mn[maxn];

inline void upmin(ll &x, ll y) { x = min(x,y); }

ll get_val(int i, int j) { return (p[i] <= j) ? (A) : (B); }

int main() {
	scanf("%d%lld%lld", &n, &A, &B);
	for(int i = 1;i <= n;i ++) scanf("%d", &a[i]), p[a[i]] = i;
	int cur = 1, pre = 0;
	for(int i = 0;i < p[1];i ++) dp[cur][i] = B;
	dp[cur][p[1]] = 0;
	for(int i = p[1] + 1;i <= n;i ++) dp[cur][i] = A;
	mn[0] = dp[cur][0];
	for(int i = 1;i <= n;i ++) mn[i] = min(mn[i - 1],dp[cur][i]);
	for(int i = 2;i <= n;i ++) {
		cur = pre; pre ^= 1;
		for(int j = 0;j <= n;j ++) dp[cur][j] = INF;
		for(int j = 0;j <= n;j ++) {
			upmin(dp[cur][j],mn[j] + get_val(i,j));
			if(j == p[i]) upmin(dp[cur][j],mn[j - 1]);
		}
		mn[0] = dp[cur][0];
		for(int j = 1;j <= n;j ++) mn[j] = min(mn[j - 1],dp[cur][j]);
	}
	ll Ans = mn[n];
	printf("%lld\n", Ans);
	return 0;
}


Measured memory_bytes: 384
let sx, sy, tx, ty = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a, b, c, d))

let x = tx - sx

let y = ty - sy

let x' = succ x

let y' = succ y

let rep s n =
  let rec f i tmp = if i = 1 then tmp else f (i - 1) (s ^ tmp) in
  f n s


let () =
  Printf.printf "%s\n"
    ( rep "R" x ^ rep "U" y ^ rep "L" x ^ rep "D" y ^ "D" ^ rep "R" x'
    ^ rep "U" y' ^ "LU" ^ rep "L" x' ^ rep "D" y' ^ "R" )

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

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

using namespace std;

using ll=long long;

int main(){
    ll a,b;
    cin>>a>>b;
    ll d=gcd(a,b);
    int ans=0;
    for (ll i = 2; i*i <= d; ++i) {
        if(d%i==0)++ans;
        while(d%i==0)d/=i;
    }
    if(d!=1)++ans;
    ans+=1;
    cout<<ans<<endl;
    return 0;
}

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

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i+1;}

int main(void){
    int H,A[X+1];
    cin >> H;
    
    for(int i=1;i<=H;i++){
        cin >> A[i];
    }
    
    for(int i=1;i<=H;i++){
        cout << "node " << i << ": ";
        cout << "key = " << A[i] << ", ";
        if(i!=1) cout << "parent key = " << A[parent(i)] << ", ";
        if(i*2<=H) cout << "left key = " << A[left(i)] << ", ";
        if(i*2+1<=H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>

int main(void) {
	int H, W, i, j = 0;
	while(1){
		scanf("%d %d", &H, &W);
		if((H==0) && (W==0)){
			break;
		}
		for(i = 0; i<H; i++){
			for(j = 0; j<W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	//scanf("%d %d", &H, &W);
	return 0;
}


Measured memory_bytes: 2112
//longest common subsequence
#include <bits/stdc++.h>
using namespace std;

string dp(string s, string t,int m,int n){
    vector<vector<int>> l(m+1,vector<int>(n+1,0));
    
    for(int i=0;i<=m;i++){
        for(int j=0;j<=n;j++){
            if(j==0||i==0){
                l[i][j] = 0;
            }else if(s[i-1]==t[j-1]){
                l[i][j] = l[i-1][j-1]+1;
            }else{
                l[i][j] = max(l[i-1][j],l[i][j-1]);
            }
        }
    }
    
    string sol = "";
    for(int i=m,j=n; i>0&&j>0;){
        if(l[i][j]>max(l[i-1][j],l[i][j-1])){
            sol = s[i-1] + sol;i--;j--;
        }else{
            (l[i - 1][j] > l[i][j - 1]) ? i-- : j--;
        }
    }
    
    return sol;
    
}


int main() {
    string s,t;
    cin>>s>>t;
    cout<<dp(s,t,s.length(),t.length())<<endl;
}

Measured memory_bytes: 35584
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        boolean flag = true;

        // 文字列の入力
        String s = sc.next();
        s = '#' + s; // 入力が１ずれているのでこれで修正
        sc.close();
            if(!canReach(n, a, c, s) || !canReach(n, b, d, s)){
                flag = false;
            }

        if((c > d) && flag) {
            flag = checkflag(n, b, d, s);
        }

        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");

        }
    }
    public static boolean canReach(int n, int start, int goal, String s) {
        for (int i = start; i <= goal; i++) {
            if ((s.charAt(i) == '#') && (s.charAt(i + 1) == '#')) {
                return false;
            }
        }
        return true;
    }

    public static boolean checkflag(int n, int b, int d, String s) {
        for (int i = b; i <= d; i++) {
            if (i > 0) {
                if ((s.charAt(i) == '.') && (s.charAt(i + 1) == '.') && (s.charAt(i - 1) == '.')&& b!=i+1) {
                    return true;
                }
            }
        }
        return false;
    }
}


Measured memory_bytes: 28420
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	long N;
	cin >> N;
	for(long h = 1; h <= 3500; h++){
		for(long n = 1; n <= 3500; n++){
			if((4 * h * n - N * n - N * h) > 0){
				if((N * h * n) % (4 * h * n - N * n - N * h) == 0){
					cout << h << " " << n << " " << (N * h * n) / (4 * h * n - N * n - N * h) << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(s: String);
	input!(t: String);

	let vs: Vec<char> = s.chars().collect();
	let vt: Vec<char> = t.chars().collect();

	let mut count = 0;
	for i in 0..vs.len() {
		if vs[i] != vt[i] {
			count += 1;
		}
	}
	println!("{}", count);
}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<int> H(N);
  cin >> H;
  vector<int> H2 = H;
  bool ok = true;
  for (int i = 1; i < N; i++) {
    if (H[i-1] < H[i]) H[i]--;
    else if (H[i-1] > H[i]) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
    return 0;
  }
  H2[0]--;
  for (int i = 1; i < N; i++) {
    if (H2[i-1] < H2[i]) H2[i]--;
    else if (H2[i-1] > H2[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
  int k,n; cin >> k >> n;
  int a[n]; rep(i,n) cin >> a[i];

  int maxdist = 0;
  rep(i,n){
    if(i != n-1){
      maxdist = max(maxdist, a[i+1]-a[i]);
    }
    else{
      maxdist = max(maxdist, a[0]+k-a[i]);
    }
  }

  cout << k-maxdist << endl;
}

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

int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  ll max;
  if(b<=n){
   ll k = n/b;
    ll o = b*k-1;
       max=a*o/b-a*(o/b);
  }
  else
    max = a*n/b-a*(n/b);
      
  cout << max << endl;
}





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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;

void solve(){
   int n,u;
   cin>>n;
  long long sum=0;
   for(int i=0;i<n;i++){
       cin>>u;
      sum+=(--u);
   }
  cout<<sum; 
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 998244353ll;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;


int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	str s;
	cin >> s;
	ll fl = 1;
	for(int i = 1; i < s.size(); i++) if(s[i] != '9') fl = 0;
	ll h = s[0]-'0';
	if(fl == 0) cout << 9 * (s.size() - 1) + h - 1;
	else cout << 9 * (s.size() - 1) + h;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll a, b, c, d;
string s, t;
int main(){
	cin >> a >> b >> c >> d;
	if(a < c){
		p(1);
	}else{
		p(0);
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INF 10000000
int h;
int A[2000000];

int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l = left(i);
  int r = right(i);
  int large;
  int tmp;

  if(l <= h && A[l] > A[i]){
    large = l;
  }else{
    large = i;
  }
  if(r <= h && A[r] > A[large]){
    large = r;
  }

  if(large != i){
    tmp = A[i];
    A[i] = A[large];
    A[large] = tmp;
    maxHeapify(large);
  }
}


int exact(){
  int max;
  if(h<1)return -INF;

  max = A[1];
  A[1] = A[h--];
  maxHeapify(1);

  return max;
}


void heapIncreaseKey(int A[],int i,int k){
  int tmp;
  if(k < A[i])return;

  A[i] = k;

  while(i > 1 && A[i/2] < A[i]){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}

void insert(int k){
  h++;
  A[h] = -INF;
  heapIncreaseKey(A,h,k);
}

int main(){
  int k;
  char c[10];
  h = 0;
  while(1){
    scanf("%s",c);

    if(c[0] == 'e' && c[1] == 'n')break;
    else if(c[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }else{
      printf("%d\n",exact());
    }
  }

  return 0;
}

Measured memory_bytes: 4696
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

Sd = input()
T = input()
N = len(Sd)
M = len(T)
for i in range(N-M, -1, -1):
    t_ = Sd[i:i+M]
    for j in range(M + 1):
        if j == M:
            print((Sd[:i] + T + Sd[i+M:]).replace('?', 'a'))
            exit()
        if t_[j] == '?':
            continue
        elif t_[j] != T[j]:
            break
print('UNRESTORABLE')


Measured memory_bytes: 38256
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    y = 0
    for i in str(n):
        y+=int(i)
    if int(n)%y==0:
        return 'Yes'
    else:
        return 'No'

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main{

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

    static long lcm(long a,long b){
        return a/gcd(a,b)*b;
    }
    public static void main(String[] srgs){
        Scanner sc=new Scanner(System.in);

        int n=sc.nextInt();
        int t=0;
        for(int i=0;i<n;i++){
            int a=sc.nextInt();
            if(t+1==a)t+=1;
        }
        if(t==0)t=n+1;
        System.out.println(n-t);
    }
}


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

int main()
{
  int h,w;
  cin>>h>>w;
  char name[h][w];
  for(int i=0;i<h;i++)
  {
    for (int j=0;j<w;j++)
    {
    cin>>name[i][j];
    }
  }
  for(int k=0;k<w+2;k++)
  {
    cout<<"#";
  }
  cout<<"\n";
    for(int i=0;i<h;i++)
  {
    cout<<'#';
    for (int j=0;j<w;j++)
    {
    cout<<name[i][j];
    }
    cout<<"#\n";
  }
    for(int k=0;k<w+2;k++)
  {
    cout<<"#";
  }
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B, C;

  cin >> A >> B >> C;

  if (A + B >= C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int> cnt(N);
	vector<vector<int>> child(N);
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
		A[i]--;
		if (A[i] != -1) {
			cnt[A[i]]++;
			child[A[i]].push_back(i);
		}
	}
	dump(cnt);
	dump(child);
	vector<int> v(N);
	vector<bool> ok(N);
	rep(i, 0, N) {
		if (A[i] == -1) {
			ok[i] = true;
		}
		if (cnt[i] == 0) {
			ok[i] = true;
			v[i] = K;
		}
	}
	function<int(int)> dfs = [&](int i) {
		
		rep(j, 0, child[i].size()) {
			chmax(v[i], dfs(child[i][j]));
		}

		if (v[i] > 0)
			ok[i] = true;

		return v[i] - 1;
	};

	rep(i, 0, N) {
		if (A[i] == -1) {
			dfs(i);
		}
	}
	int ans = 0;
	rep(i, 0, N) {
		if (ok[i])
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17356
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    char s[5];
    scanf("%s",s);

    int ans=0;
    for(int i=0;i<4;i++){
        if(s[i]=='2'){
            ans++;
        }
    }

    printf("%d\n",ans);
    
    return 0;
    
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int h,a,i,ans=0,cnt=0;
  cin>>h>>a;
  for(i=0; i<10000; i++){
    h=h-a;
    cnt++;
    if(h<=0){
      ans=cnt;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}



using namespace std;
int main(){
    ll n,a,b,c,ma;
    cin >> n;

    vector<vector<ll>> vec(n+1,vector<ll>(3));

    vec[0][0] = 0;
    vec[0][1] = 0;
    vec[0][2] = 0;

    for(int i=1; i<=n;i++){
        cin >> a >> b >> c;

        vec[i][0] = a + max(vec[i-1][1],vec[i-1][2]);
        vec[i][1] = b + max(vec[i-1][0],vec[i-1][2]);
        vec[i][2] = c + max(vec[i-1][1],vec[i-1][0]);
    }
    ma = vec[n][2];
    REP(i,2){
        ma = max(ma, vec[n][i]);
    }
    cout << ma<< endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define   ll  long long int
#define   sz  100100

using namespace std;


int main()
{

   ll a,b,c,d,k,p,i,j;

   cin>>a>>b>>c;

   ll n,f=0;

   for(i=1;i<=1000000;i++)
   {
       d=a*i;
       d=d%b;
       if(d==c)
       {
           cout<<"YES"<<endl;
           return 0;
       }
   }
   cout<<"NO"<<endl;
   return 0;
}



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

int coutDivisor(int N) {
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (N % i == 0) {
      cnt++;
    }
  }
  return cnt;
}

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

  int ans = 0;
  for (int i = 1; i <= N; i+=2) {
    if (coutDivisor(i) == 8) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct line
{
	long long l,r;
	int p;
}a[100001],b[100001];
bool v[100001];
inline bool cmp1(line x,line y)
{
	return x.l>y.l;
}
inline bool cmp2(line x,line y)
{
	return x.r<y.r;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].l,&a[i].r);
		a[i].p=i;
		b[i]=a[i];
	}
	sort(a+1,a+1+n,cmp1);
	sort(b+1,b+1+n,cmp2);
	long long d=0;
	int d1=1,d2=1;
	int tot=0,sx=0;
	long long ans=0;
	while(tot<=n)
	{
		if(sx%2==0)
		{
			while(v[a[d1].p])
				d1++;
			
			sx++;
			if(d<a[d1].l)
			{
				tot++;
				ans+=abs(d-a[d1].l);
				d=a[d1].l;
			}
			else
				tot++;
			v[a[d1].p]=true;
		}
		else
		{
			while(v[b[d2].p])
				d2++;
			
			sx++;
			if(d>b[d2].r)
			{
				tot++;
				ans+=abs(d-b[d2].r);
				d=b[d2].r;
			}
			else
				tot++;
			v[b[d2].p]=true;
		}
	}
	long long ax=ans+abs(d);
	d=0;
	d1=1,d2=1;
	tot=0,sx=1;
	ans=0;
	memset(v,false,sizeof(v));
	while(tot<=n)
	{
		if(sx%2==0)
		{
			while(v[a[d1].p])
				d1++;
			
			sx++;
			if(d<a[d1].l)
			{
				tot++;
				ans+=abs(d-a[d1].l);
				d=a[d1].l;
			}
			else
				tot++;
			v[a[d1].p]=true;
		}
		else
		{
			while(v[b[d2].p])
				d2++;
			
			sx++;
			if(d>b[d2].r)
			{
				tot++;
				ans+=abs(d-b[d2].r);
				d=b[d2].r;
			}
			else
				tot++;
			v[b[d2].p]=true;
		}
	}
	ax=max(ax,ans+abs(d));
	printf("%lld\n",ax);
	return 0;
}

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

#define MAX 1000000000000000000ULL

ll mul(ll a, ll n, bool& no) {
    if (n == 0) {no=false;return 0;}
    if (no) return 0;
    if (a > MAX/n) {no = true;return 0;}
    ll r = a * n;
    return r;
}
int main() {
    int n;
    cin >> n;

    ll r = 1;
    bool no = false;
    for (int i=0;i<n;i++) {
        ll x; cin >> x;
        r = mul(r, x, no);
    }
    if (r > MAX || no) cout << "-1"<<endl;
    else cout<<r<<endl;
}


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k;
string s;
signed main(){
	cin>>s;
	int f=1;
	n=s.size();
	string s2=s;
	reverse(s2.begin(),s2.end());
	if(s!=s2)f=0;
	string t=s.substr(0,(n-1)/2);
	string t2=t;
	reverse(t.begin(),t.end());
	if(t!=t2)f=0;
	string r=s.substr((n+3)/2-1,n-(n+3)/2+1);
	string r2=r;
	reverse(r.begin(),r.end());
	if(r!=r2)f=0;
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 1e5 + 17;

int n;
int a[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	forn (i, n)
		scanf("%d", a + i);

	return true;
}

void solve()
{
	int sum = 0, mn = inf;

	forn (i, n)
	{
		sum += a[i];
		
		if (a[i] % 10)
			mn = min(mn, a[i]);
	}

	if (sum % 10 == 0)
	{
		if (mn == inf)
			sum = 0;
		else
			sum -= mn;
	}

	printf("%d\n", sum);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif
 
	while (read())
		solve();
 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

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


Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC086C_Traveling
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int x = 0;
            int y = 0;
            int t = 0;
            bool flag = false;

            for(int i = 0; i < n; i++)
            {
                int[] input = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
                int tmpT = input[0];
                int tmpX = input[1];
                int tmpY = input[2];

                int dist = Math.Abs(tmpX - x) + Math.Abs(tmpY - y);
                int dt = tmpT - t;

                if (dist <= dt && (dist % 2 == dt % 2))
                {
                    flag = true;
                    t = tmpT;
                    x = tmpX;
                    y = tmpY;
                }
                else
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 17488
n = int(input())
w = []
flag = 0
tmp = ''

for i in range(n):
    w.append(input())
    if i == 0:
        continue
    elif w[i][0] != w[i-1][len(w[i-1])-1]:
        flag = 1

w = sorted(w)

for i in range(1,n):
    if w[i-1] == w[i]:
        flag = 1
        break

if flag == 0:
    print('Yes')
else:
    print('No')


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

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double s;
  
  if (x <= a*a*b/2) {
    s = atan(a*b*b/(2*x))*180/3.141592653589793238462643383279;
  }
  else {
    s = 90 - atan(a*a*a/(2*a*a*b-2*x))*180/3.141592653589793238462643383279;
  }
  cout << setprecision(10) << fixed;
  cout << s << endl;
}


Measured memory_bytes: 384