akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int m = sc.nextInt();
			if ((n | k | m) == 0)
				break;
			Stone head = new Stone(1);
			Stone tail = head;
			for (int i = 2; i <= n; i++) {
				Stone s = new Stone(i);
				tail.next = s;
				tail = tail.next;
			}
			tail.next = head;
			for (int i = 0; i < m - 1; i++) {
				tail = tail.next;
			}
			deleteNext(tail);
			while (!tail.next.equals(tail)) {
				for (int i = 0; i < k - 1; i++) {
					tail = tail.next;
				}
				deleteNext(tail);
			}
			System.out.println(tail.id);
		}
	}

	static void deleteNext(Stone s) {
		Stone t = s.next;
		s.next = t.next;
	}

}

class Stone {
	int id;
	Stone next;

	Stone(int i) {
		id = i;
	}

	@Override
	public boolean equals(Object s) {
		if (!(s instanceof Stone))
			return false;
		return ((Stone) s).id == id;
	}
}

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

int main(){
    string a,b;
    cin >> a >> b;
    bool f = true;
    for(int i = 0; i < 3; i++){
        if(a[i] != b[2 - i]){
            f = false;
            break;
        }
    }
    if(f) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 3628
from collections import deque

v, e = map(int, input().split())
adj = [[] for _ in range( v)]
inflow = [0] * v
for _ in range(e):
    s, t = map(int, input().split())
    inflow[t] += 1
    adj[s].append(t)

def topological_sort(adj, inflow):
    is_visited = [False] * len(inflow)
    res = []

    def bfs(s):
        #sを始点とする
        q = deque([s])
        is_visited[s] = True
        res.append(s)
        while q:
            p = q.popleft()
          
            for r in adj[p]:
                inflow[r] -= 1
                if (inflow[r] == 0) and (not is_visited[r]):
                    q.append(r)
                    is_visited[r] = True
                    res.append(r)

    for x in range(len(inflow)):
        if (inflow[x] == 0) and (not is_visited[x]):
            bfs(x)
    return res

for i in topological_sort(adj, inflow):
    print(i)


Measured memory_bytes: 9252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int A;
    int B;
    cin  >> A >> B;
    int ans = 1;
    int count = 0;
    while(true){
        if(ans>=B)break;
        ans -=1;
        ans += A;
        count ++;
    }
    
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] arg){
		Scanner in = new Scanner(System.in);
		boolean[][] trump = new boolean[4][13];
		char[] head = {'S','H','C','D'} ;
		int n = in.nextInt();
		for(int i=0;i<n;i++){
			char head_in = in.next().charAt(0);
			int num = Integer.parseInt(in.next());
			switch(head_in){
			case 'S':trump[0][num-1] = true;break;
			case 'H':trump[1][num-1] = true;break;
			case 'C':trump[2][num-1] = true;break;
			case 'D':trump[3][num-1] = true;break;
			}	
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				if(trump[i][j] == false){
					System.out.println(head[i]+" "+(j+1));
				}
			}
		}
	}	
}

Measured memory_bytes: 17260
#include<cstdio>
using namespace std;
int main(){
    int n,k,cnt=0;
    long a[1000],sum[1001],ans=0,t[41],b;
    t[0]=1;
    for(int i=1;i<=40;i++){
        t[i]=t[i-1]*2;
    }
    sum[0]=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
        sum[i+1]=sum[i]+a[i];
    }
    for(int i=40;i>=0;i--){
        cnt=0;
        for(int j=0;j<n;j++){
            for(int l=j+1;l<=n;l++){
                b=(ans+t[i])&(sum[l]-sum[j]);
                if(b==ans+t[i]){
                    cnt++;
                }
            }
        }
        if(cnt>=k){
            ans+=t[i];
        }
    }
    printf("%ld\n",ans);
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: i64, b: i64,
    }
    if a + b == 15 {
        println!("+");
    } else if a * b == 15 {
        println!("*");
    } else {
        println!("x");
    }
}


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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

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; }

void Main(){
    int D; cin >> D;
    VI c(26); REP(i,26) cin >> c[i];
    int s[D][26]; REP(i,D)REP(j,26) cin >> s[i][j];
    VI last(26,0);
    int ans = 0;
    REP(i,D){
        int t; cin >> t; t--;
        ans += s[i][t];
        last[t] = i+1;
        REP(j,26) ans -= c[j] * (i+1-last[j]);
        cout << ans << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


public class Main {

	Scanner sc;
	final double EPS=1e-7;
	
	class Pair{
		public int first;
		public double second;
		public Pair(int a,double b){
			first=a;
			second=b;
		}
		public String toString(){
			return first+" "+second;
		}
	}
	
	class PairComparator implements Comparator<Pair>{

		//第一要素で比較する⇒true
		private boolean first;
		PairComparator(boolean first){
			this.first=first;
		}

		@Override
		public int compare(Pair o1, Pair o2) {
			// TODO Auto-generated method stub
			if(first){
				return o1.first-o2.first;
			}
			else{
				double d1=o1.second,d2=o2.second;
				if(Math.abs(d1-d2)<EPS) return 0;
				else if(d1<d2) return -1;
				else return 1;
			}
		}
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	double BMI(int h,int w){
		return ((double)w)/h/h*10000;
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		int n;
		while((n=ni())!=0){
			Pair[] person=new Pair[n];
			for(int i=0;i<n;++i){
				person[i]=new Pair(ni(),Math.abs(BMI(ni(),ni())-22.0));
			}
			Arrays.sort(person,new PairComparator(true));
			Arrays.sort(person,new PairComparator(false));
			System.out.println(person[0].first);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 36080
import math

N ,K = (int(i) for i in input().split())
ans = 0
for i in range(int(N)):
  if i < K:
    x = math.log2(K/(i+1))
    x_ceil = math.ceil(x)
    ans += pow(0.5,x_ceil)/N
  else:
    ans += 1/N

print(ans)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
#define MOD 998244353LL
long long best[3030][3030];
long long v[4444], N, S;
int main() {

  cin >> N >> S;
  for(int i=1;i<=N;++i) {
    cin >> v[i];
  }
  best[0][0] = 1;
  for(int i=0;i<N;++i) {
    for(int j=0;j<=S;++j) {
      if ( best[i][j] == 0) continue;
      int n = j + v[i+1];
     // cout << n << " " << i << endl;
      if(n <= S) {
        best[i+1][n] += best[i][j];
        best[i+1][n] %= MOD;
      }
      best[i+1][j] += best[i][j] * 2;
      best[i+1][j] %= MOD;
    }
  }
 // cout << best[N][0] << endl;
  cout << best[N][S] << endl;
}

Measured memory_bytes: 74556
#include <stdio.h>

int L_search(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key){
    i++;
  }
  return i != n;
}

int main(){
  int i, n, A[10000+1], q, key, sum = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&key);
    if(L_search(A, n, key)) sum++;
  }
  printf("%d\n", sum);

  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int r,d,x2000;
  cin >>r>>d>>x2000;
  
  
  for(int i =0;i<10;i++){
    x2000 = r*x2000 -d;
  cout << x2000 <<endl;
  }
  
  
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  rep(i, N - 1) cin >> b[i];
  ll ans = 0;
  if (N == 2) {
    cout << b[0] * 2 << endl;
    return;
  }
  a[0] = b[0];
  for (int i = 1; i < N - 1; i++) {
    a[i] = min(b[i - 1], b[i]);
  }
  a[N - 1] = b[N - 2];
  rep(i, N) ans += a[i];
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
a = list(map(int,input().split()))

p = [0] * (n-1)
m = [0] * (n-1)

for i in range(n-1):
    x,y = a[i:i+2]
    cnt = 0
    if(x > y):
        while(x>y):
            y *= 4
            cnt += 2
    else:
        x *= 4
        while(x<=y):
            x*=4
            cnt -= 2
    p[i] = cnt

for i in range(n-1):
    x,y = a[i:i+2]
    cnt = 0
    if(x < y):
        while(x<y):
            x *= 4
            cnt += 2
    else:
        y *= 4
        while(x>=y):
            y*=4
            cnt -= 2
    m[i] = cnt

cumsum_p = [0] * (n+1)
cumsum_m = [0] * (n+1)

d = deque()
for i in range(n-2,-1,-1):
    cumsum_p[i] = cumsum_p[i+1]
    if(p[i] < 0):
        d.appendleft((i,p[i]))
    elif(p[i] > 0):
        cnt = p[i]
        while(d):
            j,rem_j = d.popleft()
            if(cnt + rem_j <= 0):
                cumsum_p[i] += (j-i) * cnt
                if(cnt + rem_j < 0):
                    d.appendleft((j,cnt + rem_j))
                cnt = 0
                break
            else:
                cumsum_p[i] += (j-i) * (-1 * rem_j)
                cnt = cnt + rem_j
        cumsum_p[i] += (n-i-1) * cnt

d = deque()
cumsum_m[1] = 1
for i in range(n-1):
    cumsum_m[i+2] = cumsum_m[i+1] + 1
    if(m[i] < 0):
        d.appendleft((i,m[i]))
    elif(m[i] > 0):
        cnt = m[i]
        while(d):
            j,rem_j = d.popleft()
            if( cnt + rem_j <= 0 ):
                cumsum_m[i+2] += (i-j) * cnt
                if( cnt + rem_j < 0):
                    d.appendleft((j,cnt + rem_j))
                cnt = 0
                break
            else:
                cumsum_m[i+2] += (i-j) * (-1*rem_j)
                cnt = cnt + rem_j
        cumsum_m[i+2] += (i+1) * cnt

ans = cumsum_p[0]
for i in range(n+1):
    ans = min(ans, cumsum_p[i] + cumsum_m[i])

print(ans)

Measured memory_bytes: 105972
from collections import Counter

N, A = map(int, input().split())
X = list(map(int, input().split()))

for i in range(N):
    X[i] -= A
    
sums = Counter([0,X[0]])

for i in range(1,N):
    ith_x = X[i]
    ith_hash = {}
    for key, value in sums.items():
        ith_hash[ith_x + key] = value
        
    sums += ith_hash
    
print(sums[0]-1)

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        sc.close();
        int n = s.length;
        int cnt = 0;
        int res;
        //白黒
        for(int i=0;i<n;i++){
            if(i%2==0 && s[i] !='1'){
                cnt++;
            }else if(i%2 != 0 && s[i]!='0'){
                cnt++;
            }
        }
        //黒白
        res = cnt;
        cnt = 0;
        for(int i=0;i<n;i++){
            if(i%2==0 && s[i] !='0'){
                cnt++;
            }else if(i%2 != 0 && s[i]!='1'){
                cnt++;
            }
        }
        System.out.println(Math.min(res,cnt));
    }
}

Measured memory_bytes: 27908
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using coord= pair<int, int>;

int BFS(vector<string> &board){
  int H= board.size();
  int W= board.at(0).size();

  const vector<coord> diff= {make_pair(0,-1),
                             make_pair(-1,0), make_pair(1,0),
                             make_pair(0,1)};                   // 探索方向

  vector<vector<int>> checked(H, vector<int>(W, -1));
  queue<coord> bfs;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(board.at(i).at(j)=='#'){
        checked.at(i).at(j)= 0;
        bfs.push(make_pair(i,j));
      }
    }
  }

  int ans= 0;
  while( !bfs.empty() ){
    coord p= bfs.front();
    int x= p.first;
    int y= p.second;
    for(auto ds:diff){
      int dx= ds.first;
      int dy= ds.second;
      if(x+dx <= -1 || x+dx >= H || y+dy <= -1 || y+dy >= W) continue;
      else if(  board.at(x+dx).at(y+dy)=='#') continue;
      else if(checked.at(x+dx).at(y+dy)== -1){
        ans= checked.at(x).at(y)+ 1;
        checked.at(x+dx).at(y+dy)= checked.at(x).at(y)+ 1;
        bfs.push(make_pair(x+dx, y+dy));
      }
    }
    bfs.pop();
  }

  return ans;
}

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

  vector<string> Board(H);
  for(int i=0; i<H; i++){
    cin >> Board.at(i);
  }

  cout << BFS(Board) << endl;
}

Measured memory_bytes: 13456
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/5/17 20:10:57
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
double x,y,z,ans;
const double pi=acos(-1.0);
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int a=read(),b=read(),h=read(),m=read();
	x=h*pi/6.0+pi/360.0*m;
	y=m*pi/30.0;
	z=x-y;
	ans=a*a+b*b-2*cos(z)*a*b;
	ans=sqrt(ans);
	printf("%.18lf",ans);
	return 0;
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
int a[3],b,c;
int main()
{
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[1]-a[0]==a[2]-a[1])
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    return 0;
}

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

using namespace std;

int main()
{

    int n, q, t, size, cnt = 0;

    cin >> n;

    int s[n];

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

    cin >> q;

    for(int i = 0; i < q; ++i)
    {
        cin >> t;

        int l = 0, r = n, m;
        while(l <= r)
        {
            m = (l + r) / 2;
            if(s[m] == t)
            {
                ++cnt;
                break;
            }
            else if(s[m] < t)
            {
                l = m + 1;
            }
            else if(s[m] > t)
            {
                r = m - 1;
            }
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 1548
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int bubbleSort(int *num, int n) {
    int flag = 1;
    int count = 0;
    
    while(flag) {
        flag = 0;
        for(int j=n-1; 0<j; j--) {
            if(num[j]<num[j-1]) {
                swap(num[j], num[j-1]);
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

int main() {
    int n;
    int count = 0;
    cin >> n;
    
    int num[n];
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    count = bubbleSort(num, n);
    
    for(int i=0; i<n; i++) {
        printf("%d", num[i]);
        if(i!=n-1) {
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", count);
}


Measured memory_bytes: 3212
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                while (a[i] % 2 == 0)
                {
                    a[i] /= 2;
                    ans++;
                }
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 14304
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int n,s[1000],i;
    double score,a;
    while(1){
        cin >> n;
        if(n==0) break;
        score=0;
        for(i=0;i<n;i++){
            cin >> s[i];
            score+=s[i];
        }
        score/=n;
        a=0;
        for(i=0;i<n;i++) a+=pow(s[i]-score,2);
        cout << fixed << setprecision(12) << sqrt(a/n) <<endl;
    }
}



Measured memory_bytes: 3264
N = int(input())
char_map = {'M':0,'A':0,'R':0,'C':0,'H':0}
comb = [['M','A','R'],['M','A','C'],['M','A','H'],['M','R','C'],['M','R','H'],['M','C','H'],['A','R','C'],['A','R','H'],['A','C','H'],['R','C','H']]

for i in range(N):
    tmp_str = input()
    try:
        char_map[tmp_str[0]] += 1
    except KeyError:
        pass

result = 0
for i in comb:
    tmp = 1
    for j in i:
        tmp *= char_map[j]
    result += tmp
    
print(result)

Measured memory_bytes: 3064
s = gets.strip

INF = 10 ** 6

n = 1  
if (s.size - 3) > 0
  n += s.size - 3
end

ans = INF 
n.times do |i|
  res = (753 - s[i, 3].to_i).abs
  ans = res if res < ans
end

puts ans


Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);
  if(1<=A<=9 && 1<=B<=9 && A+B<10){
    printf("%d\n", A+B);
  } else {
    printf ("error");
  }
  return 0;
}
  

Measured memory_bytes: 1720
#include <cstdio>

int main(int argc, const char * argv[]) {
   
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    int ans = 0;
    for(int i=a;i<=b;i++){
        
        int val[5];
        int cnt = 0;
        int tmp= i;
        while(tmp){
            
            val[cnt++] = tmp%10;
            tmp/=10;
            
        }
        if(val[0] == val[4] && val[1] == val[3]) ans++;
        
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n; scanf("%d",&n); int ans=0;
	for (;n;n--){
		int k1; scanf("%d",&k1); if (k1&1) ans++;
	}
	if (ans%2) printf("NO\n"); else printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	vector<ll> abc;
	abc.resize(3);
	cin >> abc[0] >> abc[1] >> abc[2];
	sort(abc.begin(), abc.end());

	if (abc[2] % 2) {
		cout << abc[0] * abc[1] << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

ll a[200000];
ll dp[200000][2];
int main(){
	int n;cin>>n;
	rep(i,n+1)rep(j,2)dp[i][j]=-INFL;
	rep(i,n){
		cin>>a[i];
	}
	dp[0][0]=0;
	rep(i,n)rep(j,2){
		if(dp[i][j]==-INFL)continue;
		rep(k,2){
			if(k==1&&i==n-1)continue;
			int x=j^k;
			dp[i+1][k]=max(dp[i+1][k],dp[i][j]+(x?-a[i]:a[i]));
		}
	}
	cout<<max(dp[n][0],dp[n][1])<<endl;
}

Measured memory_bytes: 3840
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int calc(int x){
    int ret = 0;
    while (x) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    int ans = 1e9;
    FOR(a,1,n-1){
        int b = n - a;
        ans = min(ans, calc(a) + calc(b));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int x, ans;
    cin>>x;
    if(x >= 400 && x < 600) ans = 8;
    if(x >= 600 && x < 800) ans = 7;
    if(x >= 800 && x < 1000) ans = 6;
    if(x >= 1000 && x < 1200) ans = 5;
    if(x >= 1200 && x < 1400) ans = 4;
    if(x >= 1400 && x < 1600) ans = 3;
    if(x >= 1600 && x < 1800) ans = 2;
    if(x >= 1800 && x < 2000) ans = 1;
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int x1,y1,x2,y2,z1,z2;
	while(scanf("%d%d%d%d",&x1,&y1,&x2,&y2)!=EOF)
	{
		if(x2-x1<0) z1=x1-x2;
		else z1=x2-x1;
		if(y2-y1<0) z2=y1-y2;
		else z2=y2-y1;
		for(int i=1;i<=z2;i++)
		   printf("U");
		for(int j=1;j<=z1;j++)
		   printf("R");
		for(int i=1;i<=z2;i++)
		   printf("D");
		for(int j=1;j<=z1+1;j++)
		   printf("L");
		for(int i=1;i<=z2+1;i++)
		   printf("U");	
		for(int j=1;j<=z1+1;j++)
		   printf("R");	 
           printf("DR");
		for(int i=1;i<=z2+1;i++)
		   printf("D");	
		for(int j=1;j<=z1+1;j++)
		   printf("L");
		   printf("U");
	}
	return 0;
}

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

int main(){
  int N, D, X; cin >> N >> D >> X;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int ans=X;
  for(int i=0;i<N;i++){
    ans+=(D-1)/MY.at(i)+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

long long d[100000];
vector <pair <long long, int> > edges[100000];
void dijikstra(int S, int N){
    for(int i = 0; i < N; i++){
      d[i] = LLONG_MAX;
    }

    priority_queue < pair <long long, int>, vector <pair <long long, int> >, greater<pair <long long, int> > > pq;
    d[S] = 0;
    pq.push(make_pair(0, S));
    while(!pq.empty()){
        auto cur = pq.top();
        auto cur_cost = cur.first;
        auto cur_node = cur.second;
        pq.pop();
        if(d[cur_node] < cur_cost){
            continue;
        }

        for(int i = 0; i < edges[cur_node].size(); i++){
          int next_node = edges[cur_node][i].second;
          long long next_d = d[cur_node] + edges[cur_node][i].first;
          if(d[next_node] > next_d){
            d[next_node] = next_d;
            pq.push(make_pair(next_d, next_node));
          }
        }
      }
}

int cumsum[100000];
int main(void){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int L;
    int R;
    long long C;
    cin >> L >> R >> C;
    edges[L - 1].push_back(make_pair(C, R - 1));
    cumsum[L - 1] ++;
    cumsum[R - 1] --;
  }

  for(int i = 1; i < N - 1; i++){
    cumsum[i] += cumsum[i - 1];
  }

  for(int i = 0; i < N - 1; i++){
    if(cumsum[i] > 0){
      edges[i + 1].push_back(make_pair(0, i));
    }
  }

  dijikstra(0, N);
  if(d[N - 1] == LLONG_MAX){
    cout << -1 << endl;
  } else {
    cout << d[N - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 9724
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
type pair struct {
	a, b int
}
type pairSlice []pair

func (p pairSlice) Len() int {
	return len(p)
}
func (p pairSlice) Less(i, j int) bool {
	return p[i].b < p[j].b
}
func (p pairSlice) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func main() {
	defer stdout.Flush()

	_ = readInt()
	m := readInt()
	p := make([]pair, m)
	for i := 0; i < m; i++ {
		p[i].a = readInt()
		p[i].b = readInt()
	}
	sort.Sort(pairSlice(p))

	ans := 0
	prev := -1
	for _, c := range p {
		if c.a <= prev && prev < c.b {
			continue
		}
		prev = c.b - 1
		ans++
	}
	println(ans)
}


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

template<typename T>
bool updMax(T& tmax, const T& x) {
  if (x > tmax) { tmax = x; return true;  }
  else          {           return false; }
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  ll M = N % 2 == 0 ? 1 : 2;
  vector<vector<ll>> tbl(N+2, vector<ll>(M+1, LLONG_MIN));
  tbl.at(0).at(0) = 0;
  for (ll i = 0; i < N+2; i++) {
    for (ll j = 0; j <= M; j++) {
      ll cur = tbl.at(i).at(j);
      if (cur == LLONG_MIN) continue;
      if (i+2 < N+2) updMax(tbl.at(i+2).at(j), cur + A.at(i));
      if (i+1 < N+2 && j+1 < M+1) updMax(tbl.at(i+1).at(j+1), cur);
    }
  }
  cout << tbl.at(N+1).at(M) << endl;
  return 0;
}



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

#define int long long

const int N = 50 + 5;
int n, m, dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
char ar[N][N];

bool is_val(int i, int j) {
	return i >= 0 && i < n && j >= 0 && j < m;
}

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> ar[i][j];
	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (ar[i][j] == '#') {
				int cnt = 0;
				for (int k = 0; k < 4; k++) {
					int x = i + dx[k], y = j + dy[k];
					if (is_val(x, y) && ar[x][y] == '#')
						cnt++;
				}
				if (!cnt)
					return cout << "No" << endl, 0;
			}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    for i in a:
        if i%2:
            continue
        if i%3 == 0 or i%5 == 0:
            continue
        print("DENIED")
        break
    else:
        print("APPROVED")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  auto A = mvec<ll>(N+1);
  auto B = mvec<ll>(N);
  for(auto&& i : A){
    cin >> i;
  }
  for(auto&& i : B){
    cin >> i;
  }
  ll first = accumulate(all(A), 0LL);
  rep(i, 0, N){
    if(A[i] >= B[i]) A[i] -= B[i];
    else{
      A[i+1] -= min(A[i+1], B[i] - A[i]);
      A[i] = 0;
    }
  }
  cout << first - accumulate(all(A), 0LL) << rt;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, t, cnt;
bool a[100001];

int main() {
	cin >> n;
	rep(i,n) {
		cin >> t;
		if (a[t]) cnt++;
		else a[t] = true;
	}
	cout << n - (cnt+1)/2*2 << ln;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		String t=sc.nextLine();
		int ans=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)!=t.charAt(i)) ans++;
		}
		
		System.out.println(ans);

	}

}


Measured memory_bytes: 33928
#include <stdio.h>
#include <cmath>
#include <algorithm>

struct Info{
	Info(){
		index = 0;
		num = 0;
	}
	short index;
	short num;
};

int main(){

	int n,m,tmp;

	while(true){
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0)break;
		Info info[m];
		for(int i=0; i < m; i++)info[i].index = i+1;

		for(int i=0; i < n; i++){
			for(int k=0; k < m; k++){
				scanf("%d",&tmp);
				info[k].num += tmp;
			}
		}

		for(int i = 1; i <= m-1;i++){
			for(int k = m-1; k >= i; k--){
				if(info[k].num > info[k-1].num){
					std::swap(info[k],info[k-1]);
				}
			}
		}

		for(int i=0;i<m-1;i++){
			printf("%d ",info[i].index);
		}
		printf("%d\n",info[m-1].index);

	}


	return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int l = 0, r = 1e9;
  while (r-l > 1) {
    int x = (l+r)/2;
    auto f = [&](int x) {
      ll now = 0;
      rep(i,n) now += (a[i]-1)/x;
      return now <= k;
    };
    if (f(x)) r = x; else l = x;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3980
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int h, w, d;
  cin >> h >> w >> d;
  vector<vector<int>> vv(h,vector<int>(w,0));
  vector<p> position(h * w + 1, p(0,0));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> vv[i][j];
      p p = make_pair(i,j);
      position[vv[i][j]] = p;
    }
  }

  int q;
  cin >> q;
  vector<int> l(q,0);
  vector<int> r(q,0);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }

  vector<int> costFirst(h * w - d + 1, 0);// 1から
  for (int i = 1; i < h * w - d + 1; i++) {
    costFirst[i] = abs(position[i].first - position[i+d].first) + abs(position[i].second - position[i+d].second);
  }


  vector<int> costSecond(h*w, 0);

  for (int i = h * w - d - 1; i >= 0; i--){
    costSecond[i] = costSecond[i+d] + costFirst[i+1];
  }


  for (int i = 0; i < q; i++){
    cout << costSecond[l[i] - 1] - costSecond[r[i] - 1] << endl;
  }

}


Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			int res = numA - 1;
			res += numB >= numA ? 1 : 0;

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int[] wk = new int[3];
		int numK = 0;

		try {
			scanner = new Scanner(System.in);
			wk[0] = scanner.nextInt();
			wk[1] = scanner.nextInt();
			wk[2] = scanner.nextInt();
			numK = scanner.nextInt();

			Arrays.sort(wk);

			int res = wk[wk.length - 1];
			for (int i = 0; i < numK; i++) {
				res *= 2;
			}
			wk[wk.length - 1] = res;
			res = 0;
			for (int i = 0; i < 3; i++) {
				res += wk[i];
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

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

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


int main() {
    int N,A,B;
    cin >> N >> A >> B;

    int d,t;
    d=A*N;
    t=B;

    if(d<t) cout << d << endl;
    else cout << t << endl;




}


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

namespace _20170410_AOJ
{
    class ALDS1_9B
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                int[] A = new int[n + 1];

                int[] vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                Array.Copy(vals, 0, A, 1, n);

                BuildMaxHeap(A);
                WriteArray(A);
            }
        }

        static void WriteArray(int[] A)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 1; i < A.Length; i++)
            {
                sb.Append(' ');
                sb.Append(A[i]);
            }

            Console.WriteLine(sb.ToString());
        }

        static void MaxHeapify(int[] A, int i)
        {
            int l = i * 2;
            int r = l + 1;
            int h = A.Length - 1;
            int largest = 0;

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

            if (r <= h && A[r] > A[largest])
            {
                largest = r;
            }

            if (largest != i)
            {
                int temp = A[i];
                A[i] = A[largest];
                A[largest] = temp;
                MaxHeapify(A, largest);
            }
        }

        static void BuildMaxHeap(int[] A)
        {
            int h = A.Length - 1;
            for (int i = h / 2; i >= 1; i--)
            {
                MaxHeapify(A, i);
            }
        }
    }
}



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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b,N=0;
    cin>>a>>b;
    bool f=0;

    while (++N<=200000000) {
        if (N/10==b && floor(N/12.5)==a) {
            f=1;
            break;
        }
        
    }
    cout<<(f?N:-1)<<endl;
}


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

long long dp[60][2600];

main()
{
	dp[0][0]=1;
	int n,a;
	scanf("%d %d",&n,&a);
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		for(int j=i;j>=0;j--)
		{
			for(int k=2520;k>=0;k--)
			{
				if(dp[j][k])
				{
					dp[j+1][k+x]+=dp[j][k];
				}
			}
		}
		
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		int fi=a*i;
		ans+=dp[i][fi];
		//printf("%d %d %d\n",i,fi,dp[i][fi]);
	}
	printf("%lld",ans);
	
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,c,a[100000],b,k,q;
int main(){
  for(cin>>n>>k>>q;i<q;i++){
    cin>>b;
    b--;
    a[b]++;
  }
  for(i=0;i<n;i++){
    if(a[i]+k-q<1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
}

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

using namespace std;

const int maxn = 1e5 + 10;
unordered_map<int, int> mp;
int n, a[maxn];
int tot = 0;
int cnt[maxn];
int b[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        if (!mp.count(a[i])) {
            mp[a[i]] = ++tot;
            b[tot] = a[i];
        }
        cnt[mp[a[i]]]++;
    }
    int ans = b[1] ^b[2] ^b[3];
    if (mp.size() == 1 && b[1] == 0) printf("Yes\n");
    else if (mp.size() == 2) {
        if (cnt[1] == cnt[2] * 2 && b[2] == 0) {
            printf("Yes\n");
        } else if (cnt[1] * 2 == cnt[2] && b[1] == 0) {
            printf("Yes\n");
        } else printf("No\n");
    } else if (mp.size() == 3 && ans == 0 && n % 3 == 0 && cnt[1] == cnt[2] && cnt[2] == cnt[3])
        printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 4516
#include <iostream>

#include <algorithm>

#include <string>

#include <queue>

#include <vector>

using namespace std;
int main()
{
	priority_queue<int> pque;
	priority_queue<int> qque;
	int x, n, a, b;
	cin >> x >> n;

	if (x>=n)cout << 0 << endl;
	else {
		for (int i = 0; i < n; i++) {
			cin >> b;
			pque.push(b);
		}
		a = pque.top();
		int sum = 0;
		pque.pop();
		for (int i = 1; i < n; i++) {
			b = pque.top();
			qque.push(a - b);
			sum += (a - b);
			pque.pop();
			a = b;
		}

		//cout << sum << endl;

		n = 0;
		for (int i = 1; i < x; i++) {
			n += qque.top();
			qque.pop();
		}
		cout << sum - n << endl;
	}
}

Measured memory_bytes: 1400
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        s: [(Usize1, String); m]
    }

    let mut status = HashMap::new();
    for p in 0..n {
        status.insert(p, 0);
    }

    let mut ac = 0;
    let mut penalty = 0;
    for (p, r) in s {
        let h = status.entry(p).or_insert(0);
        if r == "AC".to_string() {
            if *h > -1 {
                ac += 1;
                penalty += *h;
                *h = -100000;
            }
        } else {
            *h += 1;
        }
    }

    println!("{} {}", ac, penalty);
}


Measured memory_bytes: 12520