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

public class Main {
    public static void main(String[] args) {
        Scanner inputStr = new Scanner(System.in);
        ArrayList<String> inputWitdhHeights = new ArrayList<String>();
        while (true){
            String inputStrs = inputStr.nextLine();
            if ("0 0".equals(inputStrs)) {
                break;
            }
            inputWitdhHeights.add(inputStrs);
        }
        String space = " ";
        for (String inputNums: inputWitdhHeights) {
            showChessboard(inputNums.split(space));
            System.out.println();
        }
    }

    private static void showChessboard(String[] hw) {
        int h = Integer.parseInt(hw[0]);
        int w = Integer.parseInt(hw[1]);
        if(!isFormatNums(w, h)) {
            throw new NumberFormatException();
        }
        final String sharpStr = "#";
        final String dodStr   = ".";
        StringBuffer[] chessboardPattern = new StringBuffer[] {new StringBuffer(sharpStr), new StringBuffer(dodStr)};
        for(int j = 1; j < w; j++) {
            if (j % 2 == 0) {
                chessboardPattern[0].append(sharpStr);
                chessboardPattern[1].append(dodStr);
            } else {
                chessboardPattern[0].append(dodStr);
                chessboardPattern[1].append(sharpStr);
            }
        }
        for (int i = 0; i < h; i++) {
            System.out.println(chessboardPattern[i % 2]);
        }
    }

    private static boolean isFormatNums(int h, int w) {
        int minNum =   1;
        int maxNum = 300;
        return (minNum <= h && h <= maxNum) && (minNum <= w && w <= maxNum);
    }
}


Measured memory_bytes: 27396
n, k = gets.split().map(&:to_i)
a = gets.split().map(&:to_i)

s = []
ord = Array.new(n+1, -1)
c = 1
l = 0
v = 1


while ord[v] == -1
  ord[v] = s.size()
  s << v
  v = a[v-1]
end
c = s.size - ord[v]
l = ord[v]

if k < l
  puts s[k]
else
  k -= l
  k %= c
  puts s[l+k]
end

Measured memory_bytes: 30588
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

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

    int h = s / 3600;
    int m = (s / 60) - (h * 60);
    int sec = s - (3600 * h) - (60 * m);
    printf("%d:%d:%d\n", h, m, sec);
    return 0;
}



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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = (int)50 + 7;
const int inf = (int)1e9 + 7;

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

bool check(ll mask) {
  for (int i = 1; i <= n; i++) {
    vector < int > can(N, 0);
    can[a[i]] = 1;
    for (int j = 50; j >= 1; j--) {
      if (!can[j]) continue;
      for (int k = 1; k <= j; k++) {
        if (mask & (1LL << k)) {
          can[j % k] = 1;
        }
      }
    }
    if (!can[b[i]]) return false;
  }
  return true;
}

main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  ll mask = (1LL << 51) - 1;
  if (!check(mask)) {
    puts("-1");
    return 0;
  }
  for (int i = 50; i >= 0; i--) {
    if (check(mask ^ (1LL << i))) {
      mask ^= (1LL << i);
    }
  }
  cout << mask;
}


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

int main() {
    int N; 
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    
    int L = vec.at(N/2-1);
    int R = vec.at(N/2);

    if(R-L>0){
        cout << R-L << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string.h>
#define NMMAX 100
using namespace std;
int main(void)
{
  while (1) {
    int n, m, asum = 0, recommend[NMMAX] = {0};
    scanf("%d %d", &n, &m);
    if (n == 0 && m == 0) break;
    for (int i = 0; i < n; i++) {
      int d, v;
      scanf("%d %d", &d, &v);
      if (recommend[d-1] < v) recommend[d-1] = v;
    }
    for (int i = 0; i < m; i++) asum += recommend[i];
    printf("%d\n", asum);
  }
}


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

int ans[100000];

signed main(){
  int n;cin>>n;
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        int a=i*i+j*j+k*k+i*j+j*k+k*i;
        ans[a]++;
      }
    }
  }
  for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
}


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

using namespace std;

int main(){
	
	long long int x;
	cin >> x;
	int nen = 0;
	long long int yen = 100;
	for(;;){
		nen++;
		yen *= 1.01;
		if(yen >= x)break;
	}

	cout << nen << endl;


	return 0;
}

Measured memory_bytes: 3636
function Main(input){
  const [a, b, c] = input.split(' ').map(Number);
  let count = 0;

  for(let i = a; i <= b; i++){
    if( c % i === 0) {
      count++;
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 17204
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

const MOD: u64 = 1000000007;

fn matmul (a: &Vec<Vec<u64>>, b: &Vec<Vec<u64>>) -> Vec<Vec<u64>> {
    let n = a.len();
    let mut c = vec![vec![0; n]; n];
    for i in 0..n {
        for k in 0..n {
            for j in 0..n {
                c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
            }
        }
    }
    c
}

fn run() {
    input! {
        n: usize,
        k: u64,
        a: [[u64; n]; n],
    }
    let mut s = a.clone();
    let mut t = vec![vec![0; n]; n];
    for i in 0..n {
        t[i][i] = 1;
    }
    let mut k = k;
    while k > 0 {
        if (k & 1) == 1 {
            t = matmul (&s, &t);
        }
        s = matmul (&s, &s);
        k >>= 1;
    }
    let mut ans = 0;
    for i in 0..n {
        for j in 0..n {
            ans += t[i][j];
        }
    }
    ans %= MOD;
    println! ("{}", ans);
}

fn main() {
    run();
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll sum = accumulate(a.begin(), a.end(), 0);
    if(sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    int min_v = 1e9+1;
    rep(i, n) {
        if(a[i] % 10 != 0) {
            min_v = min(min_v, a[i]);
        }
    }
    cout << (min_v == 1e9 + 1 ? 0 : sum - min_v ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n, i, j, k, b, f, r, v, nyuukyosya[4][3][10] = { {0} };

    scanf("%d", &n);

    for (i = 0;i < n;i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        nyuukyosya[b - 1][f - 1][r - 1] = nyuukyosya[b - 1][f - 1][r - 1] + v;
    }

    for (i = 0;i < 4;i++)
    {
        for (j = 0;j < 3; j++)
        {
            for (k = 0;k < 10;k++)
            {
                printf(" %d", nyuukyosya[i][j][k]);
            }
            printf("\n");
        }

        if (i != 3)
        {
            printf("####################\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2108
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,x;
	cin>>a>>b;
	x=0;
	while(1){
		x=x+1;
		if(a-x==b-x || (a-x)*(-1)==b-x){
			cout<<x<<endl;
			break;
		}
		if(x==1000000000){
			cout<<"IMPOSSIBLE"<<endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//typedef pair<int ,int> P;
struct tpl{
    int st; int flag; int di;
};

bool comp(tpl &a, tpl &b){
    if(a.st != b.st) return a.st < b.st;
    if(a.flag != b.flag) return a.flag < b.flag;
    return a.di < b.di;
}

int S[200200], T[200200], X[200200];
vector<tpl> event;
int ans[200200];

multiset<int> s;

int main(){
    int N, Q; cin >> N >> Q;
    for(int i=0; i<N; i++){
        int s, t , x;
        cin >> s >> t >> x;
        tpl a;
        a.st=s-x; a.flag=0; a.di=x; event.push_back(a);
        a.st=t-x; a.flag=-1; a.di=x; event.push_back(a);
    }
    for(int i=0; i<Q; i++){
        int d;
        cin >> d;
        tpl a;
        a.st=d; a.flag=1; a.di=i; event.push_back(a);
    }

    sort(event.begin(),event.end(),comp);

    for(auto x : event){
        if(x.flag==0) {s.insert(x.di);}
        if(x.flag==-1) {s.erase(x.di);}
        if(x.flag==1) {
            if(s.size()==0){
                ans[x.di]=-1;
            }
            else ans[x.di]=*s.begin();
        }
    }
    for(int i=0; i<Q; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 19048
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[310][90010];
ll dp2[310][90010];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    ll S = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        S += a[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 90000; j++)
        {
            (dp[i + 1][j + a[i]] += dp[i][j]) %= MOD;
            (dp[i + 1][j] += 2 * dp[i][j]) %= MOD;
        }
    }
    ll res = 0;
    for (int j = (S + 1) / 2; j <= 90000; j++)
    {
        (res += dp[n][j]) %= MOD;
    }
    dp2[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 90000; j++)
        {
            (dp2[i + 1][j + a[i]] += dp2[i][j]) %= MOD;
            (dp2[i + 1][j] += dp2[i][j]) %= MOD;
        }
    }
    if (S % 2 == 0)
    {
        (res += MOD - dp2[n][S / 2]) %= MOD;
    }
    res = (res * 3) % MOD;
    ll ans = 1;
    for (ll i = 0; i < n; i++)
    {
        (ans *= 3) %= MOD;
    }
    ans = (ans + MOD - res) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 425600
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	rep(i,0,sz(s)){
		if(i==0 or s[i]!=s[i-1]) ++cnt;
	}  
	cout<<cnt<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 512
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    s = S()
    t = S()
    if len(s)+1!=len(t):
        print('No')
        exit()
    for i in range(len(s)):
        if s[i]!=t[i]:
            print('No')
            exit()
    print('Yes')
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9288
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
typedef long long ll;
static const int mod=1e9;
using namespace std;

int main() {
	int n,k;
  cin>>n>>k;
  	cout<<n-k+1<<endl;return 0;
}


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

int main(){
    int a;string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
#define MAX_V 110
#define MAX_E 10000
#define INF 10000
int d[MAX_V][MAX_V];
typedef struct edge{
  int f;
  int s;
  int c;
}edge;

edge e[MAX_E];

int main(void)
{
  int n, m;
  cin>>n>>m;
  for(int i=0; i<MAX_V; i++)
    for(int j=0; j<MAX_V; j++)
      if(i==j)
	d[i][j]=0;
      else
	d[i][j]=INF;
  
  for(int i=0; i<m; i++)
    {
      int a, b, c;
      cin>>a>>b>>c;
      edge x;
      x.f=a;
      x.s=b;
      x.c=c;
      e[i]=x;
      d[a][b]=c;
      d[b][a]=c;
    }

  for(int k=0; k<=n; k++)
    for(int i=0; i<=n; i++)
      for(int j=0; j<=n; j++)
	d[i][j]=min(d[i][j], d[i][k]+d[k][j]);

  int cnt=0;
  for(int i=0; i<m; i++)
    {
      bool shortest=false;
      for(int j=1; j<=n; j++)
	{
	  if(d[j][e[i].f]+e[i].c==d[j][e[i].s])
	    shortest=true;
	}
      if(!shortest)
	cnt++;
    }

  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int sum = a + b + c;
    int mx = max({a, b, c});
    if (sum % 2 != mx % 2) mx++;
    mx *= 3;
    cout << (mx - sum) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
# C
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

res = 0
diff = 0
D_list = [0]*N


for i in range(N):
    if A_list[i] < B_list[i]:
        diff += B_list[i] - A_list[i] 
        res += 1
    else:
        D_list[i] = B_list[i] - A_list[i]

D_list_s = list(sorted(D_list))

for i in range(N):
    if diff <= 0:
        break
    else:
        res += 1
        diff += D_list_s[i]
        
if diff > 0:
    print(-1)
else:
    print(res)

Measured memory_bytes: 18524
while (h, w = gets.chomp.split.map(&:to_i)) != [0, 0] do
  count = 1; board = ""
  h.times do
    board += (count % 2 == 1) ? "#." * (w / 2) : ".#" * (w / 2)
    board += (w % 2 == 0) ? "" : ((count % 2 == 1) ? "#" : ".")
    board += "\n"
    count += 1
  end
  puts board + "\n"
end


Measured memory_bytes: 20372
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
string s,t,l;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	t=s;
	reverse(t.begin(),t.end());
	if(t!=s){
		cout<<"No"<<endl;
		return 0;
	}
	int n=s.size();
	t=s.substr(0,(n-1)/2);
	l=t;
	reverse(l.begin(),l.end());
	if(l!=t){
		cout<<"No"<<endl;
		return 0;
	}
	t=s.substr((n+1)/2);
	l=t;
	reverse(l.begin(),l.end());
	if(l!=t){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    # ansはtを含む
    # tをいれられる場所を探す
    ans = []
    for i in range(len(s)-len(t)+1):
        tmp = s[:i]
        flag = False
        for j in range(i,i+len(t)):
            if s[j]==t[j-i]:
                tmp += t[j-i]
                pass
            elif s[j]=='?':
                tmp += t[j-i]
                pass
            else:
                flag = True
                break
        if not flag:
            tmp += s[i+len(t):]
            tmp = tmp.replace('?','a')
            ans.append(tmp)
    if ans:
        ans.sort()
        print(ans[0])
    else:
        print('UNRESTORABLE')

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    int n;
    cin >> n;
    int ans = 1;
    rep1(i, n) {
        rep1(j, n) {
            if(j!=1)if(pow(i, j) <= n) ans = max(ans, (int)pow(i, j));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4176
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			ll a = 0, b = 0;
			bool flg = 0;
			cnt = 0;
			REP(i, n)
			{
				cin >> s;
				if (s == "lu") {
					a = 1;
				} else if (s == "ru") {
					b = 1;
				} else if (s == "ld") {
					a = 0;
				} else if (s == "rd") {
					b = 0;
				}
				if (flg == 0) {
					if (a == 1 && b == 1) {
						cnt++;
						flg = 1;
					}
				}
				if (flg == 1) {
					if (a == 0 && b == 0) {
						cnt++;
						flg = 0;
					}
				}
			}
			cout << cnt << endl;
		}
	}
}

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

#define endl '\n'
#define M 1000000007
#define pb push_back
#define ii pair<int,int>
#define vii vector< ii >
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN
#define ff first
#define ss second
#define int long long

using namespace std;
using namespace __gnu_pbds;

//////////////////////////////////////////////STL - Ordered Set////////////////////////////////////////////
typedef tree<
int, //change for pair<int,int> to use like multiset
null_type,
less<int>, //change for pair<int,int> to use like multiset
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int differ = 0;
//////////////////////////////////////////////EXTRAS///////////////////////////////////////////////////////

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	pair<int,int> v[n];
	int a[n];
	for(int i=0; i<n; i++){
	  cin >> v[i].ff;
	  v[i].ss = i;
	}
	sort(v, v+n);
	int ans[n];
	int median = n/2-1;
	for(int i=0; i<n; i++){
	  if(i > median) ans[v[i].ss] = v[median].ff;
	  else ans[v[i].ss] = v[median+1].ff;
	}
	for(int i=0; i<n; i++){
	  cout << ans[i] << endl;
	}
}

Measured memory_bytes: 6912
l = list()
mod = list()

for a in range(0, 5):
    num = int(input())
    l.append(num)
    mod.append(num % 10)

sm = 0

for a in range(0, 5):
    if 0 in mod:
        indx = mod.index(0)
        mod.pop(indx)
        sm += l.pop(indx)
    else:
        indx = mod.index(max(mod))
        mod.pop(indx)
        sm += l.pop(indx)

    while 1:
        if a == 4:
            break
        if sm % 10 == 0:
            break
        else:
            sm += 1


print(sm)


Measured memory_bytes: 3064
from collections import defaultdict, deque

#入力⇒V：頂点の数、E：辺の数
V,E = map(int,input().split())
#入力⇒s：開始点、e：終了点
se_list = [list(map(int,input().split())) for _ in range(E)]

#定義⇒{s1:[end1,end2,...],s2:[],...}
s_dic = {}

#定義⇒[頂点0に入ってくる矢印の数,頂点1に入ってくる矢印の数,.....]
e_list = [0 for _ in range(V)]

#s_dic,e_listを作成
for s,e in se_list:
    if s in s_dic:
        s_dic[s].append(e)
    else:
        s_dic[s] = [e]
    e_list[e] += 1

#キューの初期化（入ってくる矢印が0のものをキューに追加）
dfs_q = deque()
for v in range(V):
    if e_list[v] == 0:
        dfs_q.append(v)

#トポロジカルソートされた配列（今回の答え）
topological_sort = []

#キューがなくなるまで実行
while dfs_q:
    v_from = dfs_q.pop()
    topological_sort.append(v_from)
    if v_from in s_dic:
        for v_to in s_dic[v_from]:
            e_list[v_to] -= 1
            if e_list[v_to] == 0:
                dfs_q.append(v_to)

#答えの出力
for v in topological_sort:
    print(v)


Measured memory_bytes: 15736
#include<stdio.h>
#include<string.h>
 
#define N 20000
 
typedef struct Data{
  int area,pos;
} Data;
 
Data t[N];
int u[N]; 
int n,i;
char str[N];
int T,U;
int ans,A;
Data B,X;
 
void D_push(Data );
Data D_pop();
void push(int);
int pop();
void init();
Data makeData(int,int);
 
 int main(){
     init();
   
  scanf("%s",str);
   
  n = strlen(str);
   
  for(i = 0;i < n;i++){    
    if(str[i] == '/'){
      if(U == 0)continue;
      A = pop();
      X = makeData(i-A,A);
      ans = ans + i - A;
      while(T > 0){
    B = D_pop();
    if(B.pos < A){
      D_push(B);
      break;
    }
    X.area = X.area + B.area;
    if(B.pos < X.pos)X.pos = B.pos;
      }
      D_push(X);
    }else if(str[i] == '\\'){
      push(i);
    }
     
  }
   
  printf("%d\n%d", ans, T);
  for(i = 0;i < T;i++){
    printf(" %d",t[i].area);
  }
  printf("\n");
  return 0;
}
 
void D_push(Data data){
  t[T++]=data;
}
 
Data D_pop(){
  return t[--T];
}
void push(int x){
  u[U++]=x;
}
 
int pop(){
  return u[--U];
}

void init(){
   
  ans=0;
  T=0;
  U=0;
   
}
 
Data makeData(int x,int y){
   
  Data res;
   
  res.area=x;
  res.pos=y;
   
  return res;
} 


Measured memory_bytes: 2112
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <algorithm>
using namespace std;

#define N 250
#define CLAMP(X,A,B) \
  max ( 0, min ( (X), (B) ) )

static int d[ N + 2 ];
static int n;
static int m;

static int
dp (
  int *r,
  int  b
  )
{
  queue<int> lis;
  int i;

  fill ( r, r + n + 2, 0 );
  lis.push ( b );
  while ( !lis.empty ( ) )
  {
    const int t = lis.front ( );
    lis.pop ( );

    if ( r[ t ] ) continue ;
    r[ t ] = 1;

    for ( i = 1; i <= m; ++i )
      lis.push ( CLAMP( d[ CLAMP( t + i, 0, n + 1 ) ], 0, n + 1 ) );
  }

  return ( r[ n + 1 ] );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int v[ N + 2 ];

    scanf ( "%d", &m );
    if ( m == 0 ) break ;
    scanf ( "%d", &n );
    for ( i = 1; i <= n; ++i )
      scanf ( "%d", &d[ i ] );
    d[ 0 ] = d[ n + 1 ] = 0;
    for ( i = 1; i <= n + 1; ++i )
      d[ i ] = i + d[ i ];

    dp ( v, 0 );
    for ( i = 0; i <= n + 1; ++i )
    {
      int t[ N + 2 ];

      if ( !v[ i ] ) continue ;
      if ( !dp ( t, i ) ) break ;
    }
    if ( i > n + 1 )
      puts ( "OK" );
    else
      puts ( "NG" );
  }


  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 1036
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int A, B;
  cin >> A >> B;
  cout << max(A+B, max(A-B, A*B))<<endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

string S;
int d = 1;
ll cnt[3000];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> S;
    reverse(S.begin(), S.end());
    int rest = 0;
    for(int i = 0; i < S.size(); i++){
        rest += (S[i] - '0') * d;
        rest %= 2019;
        cnt[rest]++;
        d = d * 10 % 2019;
    }
    ll ans = 0;
    cnt[0]++;
    for(int i = 0; i < 2019; i++){
        ans += cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
n = int(input())
words = []
for i in range(n):
    word = input()
    words.append(word)
    if i != 0:
        if last != word[0]:
            print('No')
            exit()
    last = word[-1]

if n == len(set(words)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <deque>

typedef long double ld;
typedef long long ll;

using namespace std;

deque<char> d;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		d.push_back(s[i]);
	}
	int q;
	cin >> q;
	int flag = 0;
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			flag = 1 - flag;
			continue;
		}
		cin >> t;
		t--;
		char c;
		cin >> c;
		if (flag ^ t) {
			d.push_back(c);
		} else {
			d.push_front(c);
		}
	}
	string ret;
	while (!d.empty()) {
		ret += d.front();
		d.pop_front();
	}
	if (flag) {
		reverse(ret.begin(), ret.end());
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }

const int MAXN = 212345;

int n, m, k;
int s[MAXN];

int main (){
	scanf("%d", &n);
	int ux = 0, uy  =0;
	int ok = 1;
	for(int a=0;a<n;a++){
		int t, x, y;
		scanf("%d %d %d", &t, &x, &y);
		if((abs(ux - x) + abs(uy - y)) <= t && (t-(abs(ux - x) + abs(uy - y)))%2 == 0)
			continue;
		else{
			ok = 0;	
		}
	}

	if(ok)
		puts("Yes");
	else
		puts("No");
}


Measured memory_bytes: 256
// 8/2 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
    ll N, D;
    cin >> N >> D;

    ll ans = 0;
    while (N--) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D) {
            ans += 1;
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int diff =  b - a;
  int t_b = 0;
  for(int i=diff; i>=0; i--){
    t_b += i;
  }
  cout << t_b - b << endl;
}


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

char str[100060];
int main()
{
    scanf("%s", str);
    int score = 0;
    int paper, rock;
    paper = rock = 0;
    for(int i = 0; str[i]; ++i)
    {
        if(str[i] == 'g')
        {
            if(paper < rock)
            {
                ++paper;
                ++score;
            }
            else
                ++rock;
        }
        else
        {
            if(paper < rock)
                ++paper;
            else
            {
                --score;
                ++rock;
            }
        }
    }
    printf("%d\n", score);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int a, b, c;
	std::cin >> a >> b >> c;
	a = std::min(a, c);
	int ans = a;
	c -= a;
	c = std::min(c, b + 1);
	ans += c + b;
	std::cout << ans << '\n';
}

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

int N, L;
string S[100];

int main(){
    cin >> N >> L;
    for(int i = 0; i < N; i++) cin >> S[i];
    sort(S, S+N);

    for(int i = 0; i < N; i++) cout << S[i];
    return 0;
}

Measured memory_bytes: 256
N = int(input())
dic = {}
for i in range(N):
    word = input()
    if word in dic:
        dic[word] +=1
    else:
        dic[word] = 1
M = int(input())
for i in range(M):
    word = input()
    if word in dic:
        dic[word] -= 1
    else:
        dic[word] = -1

ans = 0#-float('inf')
for i in dic:
    ans = max(ans, dic[i])
print(ans)

Measured memory_bytes: 9096
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 29);
ll h, m, n; string s;
const ll MOD= 1000000007;
const ld PI = acos(-1);
ll sum = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}int a[110][101];
int prim() {
    vector<int> d(110, INF), p(110, -1),co(110,0);
    d[0] = 0; int u, miv = 0;
    while (1) {
        miv = INF;
        u = -1;
        rep(i, n) {
            if (miv > d[i] && co[i] != 2) {
                u = i; miv = d[i];
            }
        }
        if (u == -1) break;
        co[u] = 2;
        rep(v, n) {
            if (co[v] != 2 && a[u][v] != INF) {
                if (d[v] > a[u][v]) {
                    d[v] = a[u][v];
                    p[v] = u; co[v] = 1;
                }
            }
        }
    }
    rep(i, n) {
        if (p[i] != -1) sum += a[i][p[i]];
    }return sum;
}
int main() {
    cin >> n; 
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
            if (a[i][j] == -1) {
                a[i][j] = INF;
            }
        }
    }
    cout << prim() << endl;
}


Measured memory_bytes: 3168
n,a,b=map(int,input().split())
mod=10**9+7
def comb_mod(N,r,mod):
    r=min(n-r,r)
    X=1
    Y=1
    for i in range(r):
        X*=N-i
        Y*=i+1
        X%=mod
        Y%=mod
    return X*pow(Y,mod-2,mod)%mod

ans=(pow(2,n,mod)-1-comb_mod(n,a,mod)-comb_mod(n,b,mod)) % mod
print(int(ans))

Measured memory_bytes: 3064
class Node(object):
    def __init__(self, num, prv = None, nxt = None): 
        self.num = num
        self.prv = prv
        self.nxt = nxt
        
class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None 
 
    def insert(self, num):
        new_elem = Node(num)
        
        if self.start is None: 
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem
 
    def delete_num(self, target): 
        it = self.start
        
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None: 
                    self.start = self.last = None
                else:
                    if it.prv is not None: 
                        it.prv.nxt = it.nxt
                    else: # [target, a, b,]
                        self.start = self.start.nxt
 
                    if it.nxt is not None: 
                        it.nxt.prv = it.prv
                    else: 
                        self.last = self.last.prv
                break
            it = it.nxt
 
    def delete_start(self): 
        if self.start is self.last: 
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt
 
    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv
 
    def get_content(self):
        ret = [] 
        it = self.start
 
        while it is not None:
            ret.append(it.num)
            it = it.nxt
 
        return ' '.join(ret)

def _main():
    from sys import stdin
    n = int(input())
    lst = DoublyLinkedList()
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()
 
    print(lst.get_content())
    
if __name__ == '__main__': 
    _main()


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long K, std::vector<long long> p) {
  vector<double> E(N);
  rep(i,N){
    E[i] = (p[i]+1) / 2.0 ;
  }
  //vector<double> cum(N+1);
  vector<double> cum(N+1);
  cum[0] = 0.0;
  rep(i,N){
    cum[i+1] = E[i] + cum[i];
  }

  double ret = 0;
  for(int i=0;i<N-K+1;++i){
    if(ret<cum[i+K]-cum[i]) ret = cum[i+K]-cum[i];
  }
  cout << ret << endl;

}

int main() {
  cin.tie(0); cout.precision(12);
  ios::sync_with_stdio(false); // Magic for faster cin
  long long N;
  std::cin >> N;
  long long K;
  std::cin >> K;
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    std::cin >> p[i];
  }
  solve(N, K, std::move(p));
  return 0;
}


Measured memory_bytes: 7944
while True:
    N=int(input())
    if N==0:
        break
    a=list(map(int,input().split()))
    m=0
    s=0
    for i in range(N):
        m+=a[i]
    m=m/N
    for i in range(N):
        s+=(a[i]-m)**2
    s=s/N
    s=s**(1/2)
    print(round(s,6))


Measured memory_bytes: 5672
N, W = map(int, input().split())
ITEM = []
vmax, wmax = 0,0
for _ in range(N):
  w,v = map(int, input().split())
  ITEM.append((v,w))
  vmax = max(vmax,v)
  wmax = max(wmax,w)

INF = 10**18
    
def solve1():
  #dp[i][v] i個めまで選んで、価値Vを実現するための最小の重量
  # TLEしたらiを消す。
  dp = [INF] * (vmax*N+1)
  dp[0] = 0
  for i in range(1,N+1):
    v1,w1 = ITEM[i-1]
    # dp[i]消すなら、vは大きい方から探索する
    for v in range(vmax*i,-1,-1):
      if v-v1>=0:
        dp[v] = min(dp[v], dp[v-v1]+w1)
  ret = 0
  for i in range(len(dp)):
    if dp[i] <= W:
      ret = max(ret, i)
  #print(dp[:30])
  return ret

ans = solve1()
  
print(ans)

Measured memory_bytes: 69360
# include <stdio.h>
int main()
{
    double a,b,c,d;
    scanf("%lf",&a);
    b=3.1415926535897932384626433*a*a;
    c=2*3.1415926535897932384626433*a;
    printf("%.6lf %.6lf\n",b,c);
    return 0;
}




Measured memory_bytes: 2044
#coding: utf-8
S = input()
year = 99
month = 12
mae, ushiro = int(S[:2]), int(S[2:])
if 0 < mae <= month and 0 < ushiro <= month:
	print("AMBIGUOUS")
elif 0 < mae <= month and 0 <= ushiro <= year:
	print("MMYY")
elif 0 <= mae <= year and 0 < ushiro <= month:
	print("YYMM")
else:
	print("NA")


Measured memory_bytes: 2940
import sys
import bisect

inf = 10**15
mod = 10**9+7

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse = True)
    return divisors


n,m = map(int, input().split())
kouho = make_divisors(m)
for num in kouho:
    if m//num >= n:
        print(num)
        sys.exit()

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

int main(int argc, const char * argv[]) {
    int n, cnt = 0;
    cin >> n;
    ll x;
    //vector<ll> v(n);
    for (int i = 0; i< n; i++) {
        cin >> x;
        //v[i] = x;
        while (x > 0 && x % 2 == 0) {
            if (x % 2 == 0) {
                cnt++;
                x /= 2;
            }else{
                break;
            }
        }
    }
    cout << cnt << endl;
    
}


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

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int yen = -1;
  if(A+B >= C*2){
    int cn = min(X,Y);
    for(int a = 0; a <= X-cn; a++){
      for(int b = 0; b <= Y-cn; b++){
        int c = max(X-cn-a,Y-cn-b)*2;
        int cost = A*a+B*b+C*(c+cn*2);
        if(yen == -1 || yen > cost){
          yen = cost;
        }
      }
    }
  }else{
    int cn = min(X,Y);
    for(int a = cn; a <= X; a++){
      for(int b = cn; b <= Y; b++){
        int c = max(X-a,Y-b)*2;
        int cost = A*a+B*b+C*c;
        if(yen == -1 || yen > cost){
          yen = cost;
        }
      }
    }
  }
  cout << yen << endl;
}

Measured memory_bytes: 256
n, c = map(int, input().split())
arrD = list(list(map(int, input().split())) for i in range(c))
arrC = list(list(map(int, input().split())) for i in range(n))

##剰余r=0,1,2で、
    ##色の出現数を確認する -> いずれかの色に統一する
        ##どの色に統一するか全パターンを実施して、違和感を算出
##和を取る

arrCCnt = []
for r in range(3):
    d = dict()
    for i in range(1, c + 1):
        d[i] = 0
    arrCCnt += [d]

ret = 1000 * 500 * 500
for r in range(3):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if (i + j) % 3 == r:
                arrCCnt[r][arrC[i - 1][j - 1]] += 1##色の出現数を確認

##print(arrCCnt)
for c0 in range(1, c + 1):
    for c1 in range(1, c + 1):
        for c2 in range(1, c + 1):
            if c0 != c1 and c1 != c2 and c2 != c0:
                buf = 0
                ##print(c0,c1,c2)
                for i0 in range(1, c + 1):
                    ##print(i0)
                    buf += arrD[i0 - 1][c0 - 1] * arrCCnt[0][i0]##数
                for i1 in range(1, c + 1):
                    buf += arrD[i1 - 1][c1 - 1] * arrCCnt[1][i1]##数
                for i2 in range(1, c + 1):
                    buf += arrD[i2 - 1][c2 - 1] * arrCCnt[2][i2]##数
                ret = min(ret, buf)
print(ret)
                        
                    
            


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r;
  int ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    ans += (r - l + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  vector<pair<int, int>>  red, blue;
  rep(i, 0, n){
    int a, b; cin >> a >> b;
    red.push_back(make_pair(a, b));
  }
  rep(i, 0, n){
    int c, d; cin >> c >> d;
    blue.push_back(make_pair(c, d));
  }
  int ans = 0;
  sort(all(red));
  sort(all(blue));
  vector<int> use(n, 0);
  rep(i, 0, n)  {
    int rymax=-1;
    int rp=-1;
    rep(j, 0, n){
      if(use[j]!=0) continue;
      if(red[j].first<blue[i].first and red[j].second<blue[i].second){
        if(rymax<red[j].second){
          rymax=red[j].second;
          rp=j;
        }
      }
    }
    if(rp!=-1){
      ans++;
      use[rp]=1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		//??????????????°?¨????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str, reverse;
		int num;

		while ((str = br.readLine()) != null){
			//????????????????????°????????????
			reverse = "";
			num = str.length();
			char[] word = new char[num];
			//??????
			for (int i = 0; i < num; i++) {
				word[i] = str.charAt(i);
			}
			//?????????
			for (int i = num-1; i >=0; i--) {
				reverse = reverse + word[i];
			}
			//??????
			System.out.println(reverse);
		}

	}

}

Measured memory_bytes: 23920
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ll k, a, b;
	scanf("%lld%lld%lld", &k, &a, &b);
	ll biscuits = 1;
	if (b - a <= 2)
		return cout << k + 1, 0;

	while (k > 0) {
		if (biscuits >= a) {
			if (k >= 2){
				biscuits = biscuits -a + b;
				k-=2;
			}else
				biscuits++, k--;
		} else {
			biscuits++;
			k--;
		}
	}
	cout << biscuits << endl;
	return 0;
}


Measured memory_bytes: 3772
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for (i = 0; i < N; i++){
    if (i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int i, j, v;
  for (i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

int main(){
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

ll pow1(ll a, ll b, ll m = mod)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2, m);
		x *= x;
		x %= m;
		if (b%2)
		{
			x *= a;
			x %= m;
		}
		return x;
	}
}

template <class avgType>
avgType avg(avgType a, avgType b) {
	return (a + b)/2;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());

int randInt() {
	return rng() % INT_MAX;
}

ll randLL() {
	return rng64() % LLONG_MAX;
}

vector< int > hashmods = {1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093};

int n, k, l[110000], r[110000], u, v, p[110000], ok = 1, val[110000];
vector< vi > tree(110000);

void dfs(int index, int par) {
	int odd = 0, ev = 0;
	if (p[index] != -1) {
		l[index] = r[index] = p[index];
		if (p[index] % 2) odd++;
		else ev++;
	} else {
		l[index] = -1e9;
		r[index] = 1e9;
	}

	for (int neigh : tree[index]) {
		if (neigh == par)
			continue;
		dfs(neigh, index);
		if (l[neigh] == -1e9 and r[neigh] == 1e9) continue;
		if (l[neigh]-1 > r[index] or r[neigh]+1 < l[index]) {
			ok = 0;
		} else {
			if ((r[neigh]+1) % 2) odd++;
			else ev++;

			l[index] = max(l[index], l[neigh]-1);
			r[index] = min(r[index], r[neigh]+1);
		}
	}

	if (odd > 0 and ev > 0) {
		ok = 0;
	}
}

void solve(int index, int par, int a, int b) {
	val[index] = max(a, l[index]);
	for (int neigh : tree[index]) {
		if (neigh == par)
			continue;
		solve(neigh, index, val[index]-1, val[index]+1);
	}
}

int main() {
	fastio;
	memset(p, -1, sizeof(p));
	cin>>n;
	for (int i = 0; i < n-1; i++) {
		cin>>u>>v;
		tree[u].pb(v);
		tree[v].pb(u);
	}

	cin>>k;
	for (int i = 1; i <= k; i++) {
		cin>>u>>v;
		p[u] = v;
	}

	dfs(1, -1);

	cout<<(ok ? "Yes\n" : "No\n");
	if (!ok) return 0;

	solve(1, -1, l[1], r[1]);

	for (int i = 1; i <= n; i++)
		cout<<val[i]<<endl;

	return 0;
}

Measured memory_bytes: 16128
function Main(input) {
   
    var tmp = input[0].split(' ');
    var a= tmp[0];
    var b= tmp[1];
    var x= tmp[2];

    var v = a*a*b;
   if(x>=v/2){
      var h=2*(b-(x/(a*a)))

  //    console.log("h:%s",h);

      var c = Math.atan(h/a)

  //    console.log("c:%s",c);

  //  console.log("pi:%s",Math.PI);


      var result = (c * 180 )/Math.PI
      console.log("%s",result);

    }else{
      var h=(2*x)/(a*b)

      var c = Math.atan(b/h)
     
      var result = (c * 180 )/Math.PI
      
      console.log("%s",result);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 7372