akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int h = sc.nextInt();
        int w = sc.nextInt();

        char[][] grid = new char[h][w];

        for (int i = 0; i < h; i++) {
            grid[i] = sc.next().toCharArray();
        }

        int[][] dp = new int[h][w];
        dp[0][0] = 1;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i + 1 < h && grid[i + 1][j] == '.') {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= 1000000007;
                }

                if (j + 1 < w && grid[i][j + 1] == '.') {
                    dp[i][j + 1] += dp[i][j];
                    dp[i][j + 1] %= 1000000007;
                }
            }
        }

        out.println(dp[h-1][w-1]);
        out.flush();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 34052
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    #ifdef LOCAL_DEBUG
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
    #endif // LOCAL_DEBUG
    int a,b,c,sum,f=0;
    cin>>a>>b;
    for(int c=1;c<=3;c++)
    {
        sum=a*b*c;
        if(sum%2==1)
            f=1;
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
  
  	struct aaa {
      int index;
      string name;
      int ten;
      bool operator<(const aaa &rhs) const {
        return
          name < rhs.name ||
          (name == rhs.name && ten > rhs.ten);
      };
    };
  
  	vector<aaa> lst(n);
  	for (int i = 0; i < n; i++) {
      cin >> lst[i].name >> lst[i].ten;
      lst[i].index = i + 1;
    }
  
  	std::sort(lst.begin(), lst.end());

  	for (int i = 0; i < n; i++) {
	  cout << lst[i].index << endl;
    }
  
	return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, K;
	cin >> A >> B >> K;
	int cnt = 0;
	int up = min(A, B);
	for (int i = up; i >= 1; i--) {
		if (A%i == 0 && B%i == 0) cnt++;
		if (cnt == K) {
			cout << i << endl;
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

ll d[1001]={};

int main() {
	int n;
	ll a,b;
	string s;
	cin>>s;
	int i;
	for(i=0;(i<s.size())&&(s[i]!='A');++i);
	int a1=i;
	for(i=s.size()-1;(i>0)&&(s[i]!='Z');--i);

		cout<<i-a1+1<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int maisuu, i, num;
	int S[14], H[14], C[14], D[14];
	char chara;

	//カードを示す配列に1を格納
	for(i=0;i<14;i++){
		S[i] = 1;
		H[i] = 1;
		C[i] = 1;
		D[i] = 1;
	}

	//太郎の持っているカードの枚数を読み取る
	scanf("%d", &maisuu);

	//カード配列の中で太郎の持っているものは0に変更
	for(i=0;i<maisuu*2;i++){
		scanf("%c", &chara);
		scanf("%d", &num);

		switch(chara){
			case 'S': S[num-1] = 0; break;
			case 'H': H[num-1] = 0; break;
			case 'C': C[num-1] = 0; break;
			case 'D': D[num-1] = 0; break;
		}
	}

	//太郎の持っていないカードを小さい順に出力
	for(i=0;i<13;i++){
		if(S[i]==1){
			printf("S %d\n", i+1);
		}
	}
	for(i=0;i<13;i++){
		if(H[i]==1){
			printf("H %d\n", i+1);
		}
	}
	for(i=0;i<13;i++){
		if(C[i]==1){
			printf("C %d\n", i+1);
		}
	}
	for(i=0;i<13;i++){
		if(D[i]==1){
			printf("D %d\n", i+1);
		}
	}

	return 0;

}


Measured memory_bytes: 2120
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
a = [0]*3 + a
for i in range(n):
    i *= 3
    t, x, y = map(lambda j:abs(a[i+3+j]-a[i+j]), [0,1,2])
    d = x+y
    if d>t or d%2-t%2: print("No"); exit()
print("Yes")

Measured memory_bytes: 26632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> A(9);
  vector<bool> a(9);
  for(int i=0;i<9;i++)cin>>A[i];
  for(int i=0;i<9;i++){
    int b;cin>>b;
    for(int j=0;j<9;j++){
      if(A[j]==b)a[j]=true;
    }
  }
  string ans="No";
  if(a[0]&&a[1]&&a[2])ans="Yes";
  if(a[3]&&a[4]&&a[5])ans="Yes";
  if(a[6]&&a[7]&&a[8])ans="Yes";
  if(a[0]&&a[3]&&a[6])ans="Yes";
  if(a[1]&&a[4]&&a[7])ans="Yes";
  if(a[2]&&a[5]&&a[8])ans="Yes";
  if(a[0]&&a[4]&&a[8])ans="Yes";
  if(a[2]&&a[4]&&a[6])ans="Yes";
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int r = scan.nextInt();

	if(r < 1200){
	    System.out.println("ABC");
	}else if(r < 2800){
	    System.out.println("ARC");
	}else{
	    System.out.println("AGC");
	}
    }
}


Measured memory_bytes: 22868
#include <stdio.h>
#define N 500000
#define INF 2000000000
int S[N];
int count=0;
void merge(int[],int,int,int);
void mergeSort(int[],int ,int);
int main()
{
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i =0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n%d\n",S[i],count);
  return 0;
}
void merge(int S[],int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  int L[N],R[N];
  n1= mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=S[left +i];
  }
  for(j=0;j<n2;j++){
    R[j]=S[mid+j];
  }
    L[n1]=INF;
    R[n2]=INF;
    i=0;
    j=0;
  
  for(k=left;k<right;k++){
    count++;
    if(L[i]<R[j]){
      S[k]=L[i];
      i=i+1;
    }
      else {
      S[k]=R[j];
      j=j+1;
      }
  }
}

void mergeSort(int S[],int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}

Measured memory_bytes: 5580
#![allow(unused)]

use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

#[fastout]
fn main() {
    input! {
        n: usize,
        ss: [String; n],
    }

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;
    for s in &ss {
        match s.as_str() {
            "AC" => ac += 1,
            "WA" => wa += 1,
            "TLE" => tle += 1,
            "RE" => re += 1,
            _ => (),
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}


Measured memory_bytes: 7824
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[100010];
bool dp[100010];
signed main(){
    int n,k;
    cin>>n>>k;
    REP(i,n) cin >>a[i];
    for (int i = 0; i <=k; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(i-a[j]>=0){
                if(!dp[i-a[j]]) dp[i]=true;
            }
        }
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

const long long int MOD = 1e9 + 7;

template <typename T>
T modpow(T m, T n, const T &p) {
  if (n == 0) return 1;
  T ret = modpow(m * m % p, n / 2, p);
  if (n % 2) ret *= m;
  return ret % p;
}

int main() {
  long long int m, n;
  cin >> m >> n;
  cout << modpow(m, n, MOD) << endl;

  return 0;
}


Measured memory_bytes: 3096
N = int(input())
mn = 10**9 + 1
mx = -1
mnj = 10**9 + 1
mxj = -1
for i in range(N):
    Ai,Bi = map(int, input().split())
    if mn > Bi:
        mn = Bi
        mnj = Ai
    if mx < Bi:
        mx = Bi
        mxj = Ai
print(mxj + mnj - mxj + mn)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pll >
#define all(x) x.begin(), x.end()
#define M vector<VI >

const ll P = 1e9+7;
const ll INF = 1e10;

using namespace std;

int main(){

	int n, k;
	cin >> n >> k;
	VP a(n);
	for(int i=0; i<n; i++){
		cin >> a[i].S;
		a[i].F = abs(a[i].S);
	}

	sort(a.rbegin(), a.rend());

	int cnt = 0;
	for(int i=0; i<k; i++) if(a[i].S < 0) cnt++;

	ll ans = 1;

	if(cnt&1){
		
		pll nmi, nma, pmi, pma;
		nmi = nma = pmi = pma = {INF, n};
		
		for(int i=0; i<k; i++){
			if(a[i].S < 0) nmi = {a[i].F, i};
			else pmi = {a[i].F, i};
		}
		for(int i=k; i<n; i++){
			if(a[i].S < 0 && nma.F == INF) nma = {a[i].F, i};
			if(a[i].S >= 0 && pma.F == INF) pma = {a[i].F, i};
		}

		bool sw1 = ((nmi.F!=INF)&&(pma.F!=INF));
		bool sw2 = ((pmi.F!=INF)&&(nma.F!=INF));

		if(sw1 && sw2){
			if(nma.F*nmi.F < pma.F*pmi.F){
				swap(a[nmi.S], a[pma.S]);
			} else {
				swap(a[pmi.S], a[nma.S]);
			}
		} else if(sw1){
			swap(a[nmi.S], a[pma.S]);
		} else if(sw2){
			swap(a[pmi.S], a[nma.S]);
		} else {
			int t=0;
			for(int i=n-1; i>=0 && t<k; i--){
				ans = (ans*a[i].S)%P;
				t++;
			}
			cout << (P+ans)%P << '\n';
			return 0;
		}

	}

	for(int i=0; i<k; i++) ans = (ans*a[i].S)%P;

	cout << (P+ans)%P << endl;

	return 0;
}


Measured memory_bytes: 6372
#define SORT(v) sort(v.begin(), v.end())
#include "iostream"
#include "map"
#include "vector"
#include <stack>
#include "cstdlib"
#include <algorithm>
#include <cstdarg>
// #include "ane.cpp"

#define INF 5000
#define NMAX 45
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> P;

int N,M,Ma, Mb, A[NMAX]={}, B[NMAX] = {}, C[NMAX] = {}, dp[NMAX][500][500] = {};

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

int ans = 0;

int  solve(int i, int ma, int mb){
    // printf("solve(%d, %d, %d)\n", i, ma, mb);
    if(dp[i][ma][mb]) return dp[i][ma][mb];
    // 解答アルゴリズム
    if (i >= N)
    {
        return INF;
    }
    if ((ma+A[i]) * Mb == (mb+B[i]) * Ma)
    {
        return dp[i][ma][mb] = min(C[i], solve(i+1, ma, mb));
    }

    return dp[i][ma][mb] = min(solve(i+1, ma, mb), solve(i+1, ma+A[i], mb+B[i]) + C[i]);

}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    if(ans >= INF)cout << "-1\n";
    else cout << ans << endl;
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法
    ios::sync_with_stdio(false);

    // Fill(dp, INF);

    cin >> N >> Ma >> Mb;
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i] >> B[i] >> C[i];
    }
    ans = solve(0,0,0);
    #ifdef DEBUG
    // debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int s;
    cin >> s;
    int a, b, c, d;
    a = s/1000;
    b = (s-a*1000)/100;
    c = (s-a*1000-b*100)/10;
    d = s-a*1000-b*100-c*10;
    int f, t;
    f = a*10+b;
    t = c*10+d;
    int x = 0, y = 0;
    if(f <= 12 && f > 0) x = 1;
    if(t <= 12 && t > 0) y = 1;
    if(x){
        if(y) puts("AMBIGUOUS");
        else puts("MMYY");
    }else{
        if(y) puts("YYMM");
        else puts("NA");
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.List
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Vector.Unboxed as V hiding(map,minimum,maximum,forM,forM_)
import Control.Monad
import Control.Monad.State
import Control.Monad.ST

type DP s = STUArray s (Int,Int) Int
--True == Taro, False == Jiro

dp_i :: DP s -> Bool -> Vector Int -> Int -> Int -> Int -> ST s ()
dp_i dparr human as n i j = do
    left  <- readArray dparr (i+1,j)
    right <- readArray dparr (i,j-1)
    let prior human l r = if human then max (l+(as V.! (i-1))) (r+(as V.! (j-1))) else min (l-(as V.! (i-1))) (r-(as V.! (j-1)))
    writeArray dparr (i,j) $ prior human left right

solve :: Int -> Vector Int -> ST s Int
solve n as = do
  dparr <- newArray ((0,0),(n+1,n+1)) 0
  forM_ [0..n-1] $ \k ->
    forM_ [1..n-k] $ \i -> if (n-k) `mod` 2 == 1 then dp_i dparr True as n i (i+k) else dp_i dparr False as n i (i+k)
  readArray dparr (1,n)

main :: IO ()
main = do
  n  <- read <$> getLine
  as <- map read.words <$> getLine
  putStrLn $ show $ runST $ solve n (V.fromList as)


Measured memory_bytes: 73212
x, y, z, k = map(int, input().split())
*a, = sorted(map(int, input().split()), reverse=True)
*b, = sorted(map(int, input().split()), reverse=True)
*c, = sorted(map(int, input().split()), reverse=True)

ab = [a[i] + b[j] for j in range(y) for i in range(x)]
ab.sort(reverse=True)
ab = ab[:k]

abc = [ab[i] + c[j] for j in range(z) for i in range(len(ab))]

abc.sort(reverse=True)

for i in range(k):
    print(abc[i])


Measured memory_bytes: 160336
def main():
    a, b, k = map(int, input().split())
    s = set()

    for i in range(a, min(a+k, b+1)):
        s.add(i)

    for i in range(b, max(a-1, b-k), -1):
        s.add(i)

    s = sorted(s)

    for i in s:
        print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#define LL long long

using namespace std;

int main(){
	int n,m,x, i, totalLeft=0, totalRight=0;
	std::cin >> n >> m >> x;
	int a[m];
	for(i=0;i<m;i++)std::cin >> a[i];

	for(i=0;i<m;i++){
		if(a[i]==x){
			totalLeft++;
			totalRight++;
		} else if(a[i]<x){
			totalLeft++;
		} else {
			totalRight++;
		}
	}

	std::cout << (totalLeft<totalRight ? totalLeft:totalRight) << std::endl;
	return 0;
}


Measured memory_bytes: 256
H, W, D = $stdin.gets.chomp.split(' ').map(&:to_i)
as = []
H.times do |_|
    arr = $stdin.gets.chomp.split(' ').map(&:to_i)
    as += arr
end

as_inv = []
as.each_with_index do |a, i|
    as_inv[a] = i
end

mps = []
(1..D).each do |i|
    mps[i] = 0
end

((D+1)..(H*W)).each do |i|
    src_idx = as_inv[i - D]
    dst_idx = as_inv[i]
    dist_x = ((src_idx % W) - (dst_idx % W)).abs
    dist_y = ((src_idx / W) - (dst_idx / W)).abs
    mps[i] = mps[i - D] + dist_x + dist_y
end

Q = $stdin.gets.chomp.to_i
ans = []
Q.times do |i|
    l, r = $stdin.gets.chomp.split(' ').map(&:to_i)
    mp = mps[r] - mps[l]
    ans.push(mp)
end

print ans.join("\n")

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

int main()
{
  while(1)
    { int h,w;
      cin >> h >> w;

      if(h==0 && w==0){break;}
      else
	{
	  // Creating chessboard
	  for(int i=1; i <= h; i++)
	    {
	      if(i % 2 == 1)
		{
		  for(int j = 1; j <= w; j++)
		    {    if(j % 2 == 1){cout << "#";}
		      else                  {cout << "."  ;}    }
		}
	      else
		{
		  for(int j = 1; j <= w; j++)
		    {    if(j % 2 == 0){cout << "#";}
		      else                  {cout << "."  ;}    }
		}
	      cout << endl;
	    }//chess end
	}
      cout << endl;
    }
  return 0;
}



Measured memory_bytes: 3104
# AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u

cin = [['' for c in range(1002)] for r in range(1002)]
dp =  [[0 for c in range(1002)] for r in range(1002)]
while 1:
	n = int(input())
	if n == 0: break
	for r in range(n):
		cin[r] = list(input())
	ans = 0
	for r in range(n):
		for c in range(n):
			if cin[r][c] == '*': dp[r][c] = 0
			else :
				t = dp[r-1][c-1]
				if t > 0 and dp[r  ][c-1] < t: t = dp[r  ][c-1];
				if t > 0 and dp[r-1][c  ] < t: t = dp[r-1][c  ];
				t += 1
				dp[r][c] = t
				if t > ans: ans = t
	print(ans)



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

using namespace std;

class SBSChecker {
private:
  unordered_map<int, int> valMap;
  int maxNVal;
  int type;

public:
  SBSChecker(int t) {
    maxNVal = 0;
    type = t;
  }

  int processNewVal() {
    int v;
    cin >> v;
    valMap[v]++;
    maxNVal = max(maxNVal, valMap[v]);
    return v;
  }

  void getNSameMap(multimap<int, int>& nSameMapOut) {
    for(auto itr=valMap.begin(); itr!=valMap.end(); itr++) {
        nSameMapOut.insert(make_pair(itr->second, itr->first));
    }
  }
};

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

  unordered_map<int, int> valMap;
  SBSChecker sbs1(1);
  SBSChecker sbs2(2);

  int d = 0;
  int hn = n / 2;
  for (size_t i = 0; i < hn; i++) {
    valMap[sbs1.processNewVal()]++;
    valMap[sbs2.processNewVal()]++;
  }

  if (valMap.size() == 1) {
    d = hn;
  } else {
    multimap<int, int> nSameMap1;
    multimap<int, int> nSameMap2;
    sbs1.getNSameMap(nSameMap1);
    sbs2.getNSameMap(nSameMap2);

    int maxNSame = 0;
    for(auto itr=nSameMap1.rbegin(); itr!=nSameMap1.rend(); itr++) {
      for(auto itr2=nSameMap2.rbegin(); itr2!=nSameMap2.rend(); itr2++) {
        if (itr->second != itr2->second) {
           maxNSame = max(maxNSame, itr->first + itr2->first);
           break;
        }
      }
    }
    
    d = n - maxNSame;
  }

  cout << d << "\n";
  
  return 0;
}


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

using namespace std;

const int N = 200005;
char s[N];

stack <char> S;

int main()
{
  scanf("%s", s);
  int n = strlen(s);
  
  for (int i = 0; i < n; ++i) {
    if (S.empty()) {
      S.push(s[i]);
    } else {
      if (s[i] == 'T' && S.top() == 'S') {
        S.pop();
      } else {
        S.push(s[i]);
      }
    }
  }
  
  printf("%d\n", (int)S.size());
  return(0);
}

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

int main(){
  int i, j, k;
  int  n, v,  x, y, z, count;
  string s;

  while(1){
    x = 0; y = 0; z = 1, v = 0; count = 0;
    cin>>n;

    if(n == 0) break;

    for(i = 0; i < n; i++){
      cin>>s;
      if(s[0] == 'l'){
	if(s[1] == 'u'){
	  x = 1;
	} else{
	  x = 0;
	}
      } else if(s[0] == 'r'){
	if(s[1] == 'u'){
	  y = 1;
	} else{
	  y = 0;
	}
      }

      if(v == 1 &&x == 0 && y == 0 ){ count++;}
      if(v == 0 &&x == 1 && y == 1 ){ count++;}

	if(x == 1 && y == 1){
	  v = 1;
	}
	if(x == 0 && y == 0){
	  v = 0;
	}
      }

      
   
      cout<<count<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>

void better(){
    int X[5], x[5], i, last = 0;
    int S = 0;
    for(i = 0; i < 5; i++){
        scanf("%d", &X[i]);
        x[i] = X[i]%10;
        if(i == 0) continue;
        last = (x[i] < x[last] || x[last] == 0) && x[i] != 0? i : last;
    }
    //printf("%d\n", last);
    if(last == 4) goto aftSwap;

    int temp = X[4];
    X[4] = X[last];
    X[last] = temp;

    temp = x[4];
    x[4] = x[last];
    x[last] = temp;
    
    aftSwap:
    for(i = 0; i < 4; i++){
        S = x[i] != 0? S+X[i]+10-x[i] : S+X[i];
    }
    S += X[4];
    printf("%d\n", S);
}

int main(){
    better();
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> L(N+1);
  L.at(0) = 0;
  for (int i = 1; i < N + 1; i++){
    cin >> L.at(i);
  }
  int D = 0;
  int ans;
  for (int i = 0; i < N + 1; i++){
    D += L.at(i);
    if (D > X){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int abs(int a){
	if(a>0) return a;
	else return -1*a;
}
int min(int a,int b){
	if(a<b) return a;
	else return b;
}

int main(void) {
	int N=0, K=0;
	scanf("%d%d",&N,&K);
	int step[N];
	for(int i=0;i<N;i++){
		scanf("%d",&step[i]);
	}
	int dp[N];
	int m;
	dp[0] = 0;
	dp[1] = abs(step[0]-step[1]);
	for(int i=2;i<N;i++){
		  m = dp[i-1]+abs(step[i]-step[i-1]);
		//dp[i] = min(dp[i-1]+abs(step[i]-step[i-1]),dp[i-2]+abs(step[i]-step[i-2]));
		for(int j=min(i,K);j>0;j--){
		  m = min(m,dp[i-j]+abs(step[i]-step[i-j]));
		}
		dp[i] = m;
	}
	printf("%d",dp[N-1]);
	/*for(int i=0;i<N;i++){
		printf("%d\n",dp[i]);
	}*/
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int N,M;
int P[10000];
int C[500];
int E[500];
const int INF=1e9;
int solve(){
    int dp[10001];
    fill_n(dp,10001,INF);
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=10000;j>=0;j--){
            if(dp[j]==INF)continue;
            int to=min(j+C[i],10000);
            dp[to]=min(dp[to],dp[j]+E[i]);
        }
    }
    for(int i=9999;i>=0;i--){
        dp[i]=min(dp[i],dp[i+1]);
    }

    int ma=0;
    int sum=0;
    sort(P,P+M,greater<int>());
    for(int i=0;i<M;i++){
        sum+=P[i];
        ma=max(ma,sum-dp[i+1]);
    }

    return ma;
}
int main(){
    cin>>M>>N;
    for(int i=0;i<M;i++)cin>>P[i];
    for(int i=0;i<N;i++)cin>>C[i]>>E[i];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 1256
#include <iostream>

using namespace std;

int main(void) {

	int X;
	cin >> X;

	if (X == 7 || X == 5 || X == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int
main()
{
  string sn;
  cin >> sn;
  int n = 0;
  for (int i = 0; i < sn.length(); ++i) {
    n += sn[i] - '0';
  }
  if (stoi(sn) % n == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int N;
  cin >> N;
  vi p(N);
  REP(i, N) cin >> p[i];

  sort(p.begin(), p.end());

  ll s = 0;
  REP(i, N - 1) { s += p[i]; }

  s += p[N - 1] / 2;

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7
ans = 0

x, y = map(int, input().split())

if (x + y) % 3 == 0:
    k = (2 * x - y) // 3
    l = (2 * y - x) // 3
    if k >= 0 and l >= 0:
        fac = [1] * (k + l + 1)
        for i in range(2, k + l + 1):
            fac[i] = fac[i - 1] * i % mod
        ans = fac[k + l] * (pow(fac[k], mod - 2, mod) * pow(fac[l], mod - 2, mod) % mod) % mod

print(ans)


Measured memory_bytes: 29428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    int n = Integer.parseInt(sl[0]);
    int m = Integer.parseInt(sl[1]);
    int x = Integer.parseInt(sl[2]);
    HashSet<Integer> hs = new HashSet<>();
    s = r.readLine();
    sl = s.split("[\\s]+");
    for(int i = 0; i < m; i++)
    {
      hs.add(Integer.parseInt(sl[i]));
    }
    //System.out.println(hs);

    int a = 0;
    for(int i = 0; i <= x; i++)
    {
      if(hs.contains(i))
      {
        a++;
      }
    }

    int b = 0;
    for(int i = x; i <= n; i++)
    {
      if(hs.contains(i))
      {
        b++;
      }
    }


    System.out.println(Math.min(a, b));

  }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int h, w; scanf("%d%d", &h, &w);
	std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];

	int ans = 0;
	std::vector<int> dx = {0, 1, 0, -1};
	std::vector<int> dy = {1, 0, -1, 0};
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(s[i][j] == '#') continue;
			auto dist = make_v<int>(h, w);
			for(auto & x: dist) for(auto & y: x) y = -1; dist[i][j] = 0;

			std::queue<std::pair<int, int>> qu({{i, j}});
			while(!qu.empty()) {
				auto p = qu.front(); qu.pop();
				int x = p.first, y = p.second;

				for(int k = 0; k < 4; k++) {
					int nx = x + dx[k], ny = y + dy[k];
					if(nx < 0 or ny < 0 or nx >= h or ny >= w or s[nx][ny] == '#') continue;
					if(dist[nx][ny] != -1) continue;

					dist[nx][ny] = dist[x][y] + 1;
					qu.push({nx, ny});
				}
			}
		
			for(auto x: dist) for(auto y: x) ans = std::max(ans, y);
		}
	}
	
	printf("%d\n", ans);
	return 0;
}


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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		int[] a = sc.nextIntArray(n);
		long[][] dp = new long[n][21];
		dp[0][a[0]] = 1;
		for (int i = 1; i < n - 1; i++) {
			for (int j = 0; j <= 20; j++) {
				if (j - a[i] >= 0) {
					dp[i][j] += dp[i - 1][j - a[i]];
				}
				if (j + a[i] <= 20) {
					dp[i][j] += dp[i - 1][j + a[i]];
				}
			}
		}
		System.out.println(dp[n - 2][a[n - 1]]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}
	}
}

Measured memory_bytes: 17148
def yakusu_count_is_8(n):
    count = 0
    for i in range(1, n+1):
        if n % i == 0:
            count += 1
    if count == 8:
        return True
    else:
        return False

N = int(input())

count = 0
for i in range(1, N+1, 2):
    if yakusu_count_is_8(i):
        count += 1
print(count)


Measured memory_bytes: 2940
let () = Scanf.scanf "%d\n" @@ fun k ->
  let as_ = Array.init k @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.fold_right (fun a (minimum, maximum) ->
    (minimum + a - 1 - (minimum + a - 1) mod a, maximum + a - 1 - maximum mod a)) as_ (2, 2)
  |> (fun (minimum, maximum) ->
      if maximum < minimum then print_endline "-1"
      else Printf.printf "%d %d\n" minimum maximum)



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

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  for(int i=0;i<(tx-sx);++i){
    cout<<'R';
  }
  for(int i=0;i<(ty-sy);++i){
    cout<<'U';
  }
  for(int i=0;i<(tx-sx);++i){
    cout<<'L';
  }
  for(int i=0;i<(ty-sy);++i){
    cout<<'D';
  }

  cout<<'D';
  for(int i=0;i<=(tx-sx);++i){
    cout<<'R';
  }
  for(int i=0;i<=(ty-sy);++i){
    cout<<'U';
  }
  cout<<'L';

  cout<<'U';
  for(int i=0;i<=(tx-sx);++i){
    cout<<'L';
  }
  for(int i=0;i<=(ty-sy);++i){
    cout<<'D';
  }
  cout<<'R';

}

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

int main() {
  int N, K;
  std::cin >> N >> K;
  
  std::vector<int> acc(1001, 0);
  for (int i=1; i<=1000; ++i) acc.at(i) = i + acc.at(i-1);
  std::vector<double> expect(1001, 0.0);
  for (int i=1; i<=1000; ++i) expect.at(i) = acc.at(i) / static_cast<double>(i);
  
  std::vector<int> p(N, 0);
  for (int i=0; i<N; ++i) std::cin >> p.at(i);
  
  std::vector<double> acc_ex(N+1, 0.0);
  for (int i=1; i<=N; ++i) acc_ex.at(i) = expect.at(p.at(i-1)) + acc_ex.at(i-1);
  
  double result = 0.0;
  
  for (int i=0; i<=(N-K); ++i) {
    double temp = acc_ex.at(i+K) - acc_ex.at(i);
    if (result < temp) result = temp;
  }
  std::cout << std::fixed << result << "\n";
}

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

class Main {
  public static void main(String[] args) throws Exception {
    int n;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      n = Integer.parseInt(br.readLine());
    }
    System.out.println(n*n*n);
  }
}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using P = pair<int,int>;

// code starts
int main()
{
  ll n,d;
  cin >> n >> d;
  vector<ll> x(n);
  vector<ll> y(n);
  int i;
  int ans = 0;
  rep(i,n) cin >> x[i] >> y[i];
  rep(i,n)
  {
    if(x[i]*x[i]+y[i]*y[i]<=d*d)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6372
s = input()
s1 = s[:1]
for i in range(1, 4):
  if(s[i:i+1] != s1):
    s2 = s[i:i+1]
if(s.count(s1) == 2 and s.count(s2) == 2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int a = 0;
	int b;
	int n;
	int first;
	string s;
	vector<string> bb;
	bool q = false, qq = false;
	int m = 0;
	for (;;) {
		s = "";
		qq = false;
		q = false;
		m++;
		a = -1;
		b = -1;
		cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; i++) {
			b = a;
			cin >> a;
			qq = q;
			q = false;
			if (a == b + 1)
				q = true;
			if (qq && !q) {
				if (s != "")
					s += " ";
				s += to_string(first) + "-" + to_string(b);
			}
			if (!qq && !q && i > 0) {
				if (s != "")
					s += " ";
				s += to_string(b);
			}

			if (!q)
				first = a;
		}
		if (q) {
			if (s != "")
				s += " ";
			s += to_string(first) + "-" + to_string(a);
		}
		if (!q) {
			if (s != "")
				s += " ";
			s += to_string(a);
		}
		bb.push_back(s);
	}

	for (auto w : bb) {
		cout << w << endl;
	}
	return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A%3&&B%3&&(A+B)%3) {
		cout << "Impossible"<<endl;
	}
	else
	{
		cout << "Possible"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3592
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    M = (N - 1) * (N - 2) // 2
    if K > M:
        print(-1)
        return

    ans = []
    for i in range(1, N):
        ans.append((i, N))

    cnt = 0
    for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

    print(len(ans))
    for i, j in ans:
        print(i, j)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> as(n + 1), bs(n);
  rep(i, n + 1) cin >> as[i];
  rep(i, n) cin >> bs[i];
  ll ans = 0;
  rep(i, n) {
    if (as[i] <= bs[i]) {
      ans += as[i];
      ll diff = bs[i] - as[i] <= as[i + 1] ? bs[i] - as[i] : as[i + 1];
      ans += diff;
      as[i + 1] -= diff;
    } else {
      ans += bs[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3964
import math
n = int(input())
count = 0
def isPrime(x):
    if x==2:
        return True
    if x>2 and x%2==0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x%i == 0:
            return False
        i += 1
    return True

for i in range(n):
    ans = int(input())
    if isPrime(ans):
        count += 1
print(count)



Measured memory_bytes: 5676
#include <iostream>
using namespace std;
void solve(int x,int y){
  if((y-2*x)%2==0 and (y-2*x)/2>=0 and (y-2*x)/2<=x){
    cout<<"Yes";
  }else{
     cout<<"No";
  }
  
}
int main(){
  int x;
  int y;
  cin>>x;
  cin>>y;
  solve(x,y);
}

Measured memory_bytes: 3640
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    struct Path { long begin, end; }
    Path[] pathList;
    foreach (i; 0..3) {
        const tmp = readln.split.to!(long[]);
        pathList ~= Path(tmp[0], tmp[1]);
    }
    foreach (start; 1..5) {
        auto routeIndexList = [0,1,2];
        bool[4] flag;
        do {
            long current = start;
            bool ok = true;
            foreach (i; 0..3) {
                const path = pathList[routeIndexList[i]];
                if (path.begin == current) {
                    current = path.end;
                } else if (path.end == current) {
                    current = path.begin;
                } else {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                writeln("YES");
                return;
            }
        } while(routeIndexList.nextPermutation);
    }
    writeln("NO");
}



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

using namespace std;

long long tri(int n)
{
	if(n <= 2)
	{
		return 1;
	}
	else if(n == 3)
	{
		return 2;
	}
	else
	{
		auto table = vector<int>(n+1,0);
		table[0] = 1;
		table[1] = 1;
		table[2] = 2;
		for(int i = 3;i <= n;i++)
		{
			table[i] = table[i-1] + table[i-2] + table[i-3];
		}
		return table[n];
	}
}

int main()
{
	int n;
	cin >> n;
	while(n)
	{
		int s = tri(n);
		int day = (s+9)/10;
		int year = (day+364)/365;
		cout << year << endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1196
n = int(input())
L = sorted(list(map(int, input().split())))

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if i == j or j == k or k == i: continue
            a, b, c = L[i], L[j], L[k]
            if c < a + b and a != b != c:
                cnt += 1
print(cnt)

Measured memory_bytes: 68040
// SeeAlso: https://atcoder.jp/contests/abc144/tasks/abc145_a

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int r;
    cin >> r;
    print(r*r);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>

int main(){
	// freopen("/Users/deepsajeda/Projects/input.txt","r", stdin);
	// freopen("/Users/deepsajeda/Projects/output","w",stdout);
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	float r,g;
	scanf("%f%f", &r,&g);
	printf("%.f\n", 2*g-r);
}


Measured memory_bytes: 256
x = int(input())

ans = 0
# 400 以上 599 以下：8 級
if 400 <= x <= 599:
    ans = 8
# 600 以上 799 以下：7 級
elif 600 <= x <= 799:
    ans = 7
# 800 以上 999 以下：6 級
elif 800 <= x <= 999:
    ans = 6
# 1000 以上 1199 以下：5 級
elif 1000 <= x <= 1199:
    ans = 5
# 1200 以上 1399 以下：4 級
elif 1200 <= x <= 1399:
    ans = 4
# 1400 以上 1599 以下：3 級
elif 1400 <= x <= 1599:
    ans = 3
# 1600 以上 1799 以下：2 級
elif 1600 <= x <= 1799:
    ans = 2
# 1800 以上 1999 以下：1 級
elif 1800 <= x <= 1999:
    ans = 1
    
print(ans)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
long long int adj[1000][1000];
long long int h[100000+10];
map<long long int,long long int>mp;
long long int val;
long long int answe1,res;
vector<lli>vect[400];
//set<lli>s;
/*void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.insert(n);
}
*/
int main()
{

    fast;



    lli INF=1e9+5;

    lli n,W;
    cin>>n>>W;
    vector<lli>dp(W+1);
    lli weight,value;
    for(lli i=0;i<n;i++)
    {
        cin>>weight>>value;
        for(lli w=W-weight;w>=0;w--)
        {
            dp[w+weight]=max(dp[w+weight],dp[w]+value);
        }
    }
    lli ans=0;
    for(lli i=0;i<W+1;i++)
    {
        ans=max(ans,dp[i]);
    }

    cout<<ans;


    return 0;

}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int k,t;
    cin>>k>>t;
    vector<int> a(t);
    rep(i,t) cin >> a[i];
    sort(rall(a));
    int sum=0;
    rep(i,t-1){
        sum+=a[i+1];
    }
    a[0]-=sum;
    cout<<max(0LL,a[0]-1)<<endl;
    
}

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


struct low_link {
public :
	vector<int> articulation;
	vector<pair<int, int>> bridge;
private :
	struct edge {
		int to, idx;
		edge (int to, int idx) : to(to), idx(idx) { }
	};
	int n, edge_index = 0;
	vector<vector<edge>> g;
	vector<int> order, low;
	vector<bool> seen;

	int dfs (int v, int p, int ord) {
		seen[v] = true;
		order[v] = ord++;
		low[v] = order[v];
		int child = 0;
		bool isart = false;
		for (const edge &e : g[v]) if (p != e.idx) {
			if (seen[e.to]) {
				low[v] = min(low[v], order[e.to]);
			} else {
				child++;
				ord = dfs(e.to, e.idx, ord);
				low[v] = min(low[v], low[e.to]);
				if (p != -1) isart |= (order[v] <= low[e.to]);
				if (order[v] < low[e.to]) bridge.push_back(minmax(v, e.to));
			}
		}
		isart |= (p == -1 and child >= 2);
		if (isart) articulation.push_back(v);
		return ord;
	}

public :
	low_link (int n) : n(n), g(n), order(n), low(n), seen(n) { }

	void add_edge (int v, int u) {
		g[v].emplace_back(u, edge_index);
		g[u].emplace_back(v, edge_index);
		edge_index++;
	}

	void build (int r = 0) {
		bridge.clear(); articulation.clear();
		fill(seen.begin(), seen.end(), false);
		for (int s = 0; s < g.size(); s++) {
			if (not seen[s]) dfs(s, -1, 0);
		}
	}

};


int main() {
	int n, m;
	cin >> n >> m;
	low_link g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g.add_edge(a, b);
	}
	
	g.build();
	sort(g.articulation.begin(), g.articulation.end());
	for (int v : g.articulation) cout << v << '\n';
	
	return 0;
}


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

int main() {
	int n,ans=0; cin >> n;
	for(int i = n ; i > 0 ; i--){
		if(i%2 == 0){
			continue;
		}
		int k=0;
		for(int j = i ; j > 0 ; j--){
			if(i%j == 0)k++;
		}
		if(k == 8) ans++;
	}
	cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;

int main() {
	string s;
	cin >> s;
	bool flag = false;
	if (s[0] == s[1]) {
		if (s[2] == s[3]) {
			flag = true;
		}
	}
	else if (s[0] == s[2]) {
		if (s[1] == s[3]) {
			flag = true;
		}
	}
	else if (s[0] == s[3]) {
		if (s[1] == s[2]) {
			flag = true;
		}
	}
	if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
		flag = false;
	}
	if (flag) {
		ps(Yes)
	}
	else {
		ps(No)
	}
	return(0);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   String  s = sc.next();
   char[] leader = s.toCharArray();
   int N = Integer.parseInt(s);
   int sum = 0;
   for(int i = 0; i < leader.length; i++){
     sum = sum + Character.getNumericValue(leader[i]);
   }
   if(N % sum == 0){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }
 }
}


Measured memory_bytes: 23892