akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

N=intput()
ans=0
for i in range(1,div10(N)+1):
    for x in product('357',repeat=i):
        if x.count('3')*x.count('5')*x.count('7')>0 and int(''.join(x))<=N:
            ans+=1
print(ans)

Measured memory_bytes: 74948
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let mut n: u64 = itr.next().unwrap().parse().unwrap();
    if n % 2 == 1 {
        println!("0");
    } else {
        n /= 2;
        let mut ans = 0;
        let mut div = 5;
        while n >= div {
            ans += n / div;
            div *= 5;
        }
        println!("{}", ans);
    }
}


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


Measured memory_bytes: 2100
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,c[2000],w[2000],a[2000];
ll W(ll i,ll j) {
	return a[j + 1] - a[i];
}
ll memo[2000][2000];

ll solve(ll i,ll j) {
	if(memo[i][j] >= 0) {
		return memo[i][j];
	}
	if(j - i + 1 <= 2) {
		if(i == j || w[i] <= c[j] || w[j] <= c[i]) {
			return memo[i][j] = 1;
		}
		return memo[i][j] = 2;
	}


	ll ret = 1000000000;

	if((solve(i + 1,j) == 1 && c[i] >= W(i + 1,j)) || (solve(i,j - 1) == 1 && c[j] >= W(i,j - 1))) {
		ret = 1;
	} 
	REP(k,j - i) {
		ret = min(ret,solve(i,i + k) + solve(i + k + 1,j));
	}
	return memo[i][j] = ret;
}

int main(){
	cin >> n;
	REP(i,n) {
		cin >> c[i] >> w[i];
	}
	REP(i,n) {
		REP(j,n) {
			memo[i][j] = -1;
		}
	}

	a[0] = 0;
	REP(i,n) {
		a[i + 1] = a[i] + w[i];
	}

	cout << solve(0,n - 1) << endl;
	return 0;
}



Measured memory_bytes: 14936
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
vector<string> BubbleSort(vector<string> vs, int n)
{
  int i, j, flag;
  for(i=1; i<n; i++)
  {
    flag = 0;
    for(j=0; j<n-i; j++)
    {
      if(vs[j][1] > vs[j+1][1])
      {
        swap(vs[j], vs[j+1]);
        flag = 1;
      }
    }
    if(flag == 0)
      break;
  }
  return vs;
}

vector<string> SelectionSort(vector<string> vs, int n)
{
  int i, j, minv;
  for(i=0; i<n-1; i++)
  {
    minv = i;
    for(j=i+1; j<n; j++)
    {
      if(vs[j][1] < vs[minv][1])
        minv = j;
    }
    swap(vs[i], vs[minv]);
  }
  return vs;
}

int pri(vector<string> vs, int n)
{
  for(int i=0; i<n; i++)
  {
    if(i)
      cout << " ";
    cout << vs[i];
  }
  cout << endl;
}

int isstable(vector<string> vsb, vector<string> vss, int n)
{
  for(int i=0; i<n; i++)
  {
    if(vsb[i] != vss[i])
    {
      printf("Not stable\n");
      return 0;
    }
  }
  printf("Stable\n");
  return 0;
}
int main()
{
  int n;
  scanf("%d", &n);
  vector<string> input, vsb, vss;
  for(int i=0; i<n; i++)
  {
    string temp;
    cin >> temp ;
    input.push_back(temp);
  }
  vsb = vss = input;
  vsb = BubbleSort(vsb, n);
  vss = SelectionSort(vss, n);
  pri(vsb, n);
  printf("Stable\n");
  pri(vss, n);
  isstable(vsb, vss, n);
  return 0;
}



Measured memory_bytes: 3224
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        nums: [u32; n],
    }
    let ans = nums
                .iter()
                .map(|&u| u.trailing_zeros())
                .min()
                .unwrap();
    println!("{}", ans)
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

int N;
int d[100];

int main(){
    int cnt = 1;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> d[i];
    sort(d, d+N, greater<int>());
    for(int i = 0; i < N-1; i++){
        if(d[i] > d[i+1])cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    cin >> n;
    if(n/100 == 7 || n%100/10 == 7 || n%100%10 == 7) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
str = gets
gets.to_i.times do
    q, a, b, c = gets.split
    a = a.to_i
    b = b.to_i
    case q
    when "print"
        puts str[a..b]
    when "reverse"
        str[a..b] = str[a..b].reverse
    when "replace"
        str[a..b] = c
    end
end

Measured memory_bytes: 8616
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (register int i = (n); i < (m); ++i)
#define _rep(n,m,i) for (register int i = (n); i <= (m); ++i)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
const int N = 2e5+5;
int a[N];
int main() {
  int ans = 0, t, n, k; read(n); read(k);
  for(int i = 1; i <= k; i++) {
    read(a[i]); ans += a[i];
  }t = ans;
  for(int i = k + 1; i <= n; i++) {
    read(a[i]); t -= a[i-k]; t += a[i];
    ans = max(ans, t);
  }
  ans += k;
  printf("%.13lf", ans*1.0/2);
}

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

int main()
{

    vector<int>a(3);

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

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

   /* for (int i=0;i<3;++i){
        cout << a[i];

    }*/
    cout << a[2]*10+a[1]+a[0];

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int a,b,n;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> a >> b;
    cout << min(n*a,b);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] as = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            as[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int iLikeToNo = as[i];
            int jLikeToNo = as[iLikeToNo];
            if (iLikeToNo > i && jLikeToNo == i) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 51108
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var B = make([]int, N-1)
	for i := range B {
		fmt.Scan(&B[i])
	}
	var res int
	for i := 1; i < N-1; i++ {
		if B[i] > B[i-1] {
			res += B[i-1]
		} else {
			res += B[i]
		}
	}
	res += B[0] + B[N-2]
	fmt.Println(res)
}


Measured memory_bytes: 512
"use strict";

function Main(input) {
  let line = input;
  let min = Infinity;
  for(let i = 0; i < input.length-2; i++){
  	let num = line.slice(i,i+3)*1;
    let diff = Math.abs(num - 753);
    if(min > diff) {
      min = diff;
    }
  }
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> as(m);
    for (int i = 0; i < m; i++) {
        cin >> as[i];
    }
    vector<int> maxgap(m);
    sort(as.begin(), as.end());
    REP(i, m - 1) { maxgap[i] = as[i + 1] - as[i]; }
    sort(maxgap.rbegin(), maxgap.rend());
    int ans = as[m - 1] - as[0];
    REP(i, n - 1) {
        if (i == m - 1) {
            break;
        }
        ans -= maxgap[i];
        // cout << ans << " " << maxgap[i] << endl;
    }
    cout << ans << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w,a,b; cin>>h>>w>>a>>b;
  ll ans=0;
  rep(i,w-b){
    ans+=(comb(h-a-1+b+i,h-a-1)*comb(a-1+w-b-i-1,a-1))%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	for (char ch='a'; ch<='z'; ch++) {
		s+=ch;
		if(s==t) { cout<<"Yes\n"; return 0; }
		s.pop_back();
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3612
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] freq = new int[(int)(2*(1e5)+1)];
		for (int i = 0; i < N-1; i++) {
			int x = input.nextInt();
			freq[x]++;
		}
		for (int i = 1; i <= N; i++) {
			System.out.println(freq[i]);
		}
	}
}

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

int main(){
    string S;
    cin>>S;
    long long int sum=0;
    reverse(S.begin(),S.end());
    for(unsigned int i=0;i<(1 << S.size()-1);++i){
        bitset<15> B(i);
        long long int bin=1;
        sum += S.at(0) - '0';
        for(int j=0;j<S.size()-1;j++){
            if(!B.test(j)){
                bin*=10;
            }else{
                bin =1;
            }
            //cout<<bin*(S.at(j+1) - '0')<<endl;
            sum += bin*(S.at(j+1) - '0');
        }   
    }
    cout<<sum<<endl;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int c = b - a;
    int at = 0, bt = 0;
    for (int i = 1; i <= c; i++)
    {
        if (i != c)
        {
            at += i;
        }
        bt += i;
    }
    cout << at - a << endl;
}

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

int main() {
	int n; 
	int k;
	cin>>n>>k;
	vector<int> a;
	for(int i = 0 ; i < n ; i++){
		int temp;
		cin>>temp;
		a.push_back(temp);
	}
	sort(a.begin(),a.end());
	vector<int> dp(k+1,0);
	dp[0] = 0;
	for(int i = 1 ; i <=k ;i++){
		for(int j = 0  ; j <  n ; j++){
			if(i-a[j]>=0 && dp[i]==0){
				if(dp[i-a[j]] == 0){
					dp[i] = 1;
				}
			}
		}
	}
	if(dp[k]==1){
		cout<<"First";
	}
	else{
		cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

map<in,in> soin(in n){
    map<in,in> ret;
    for(in i=2;i*i<=n;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}

bool jud(in x,in b){
    in y=x*(x+1ll)/2ll;
    return b>=y;
}

in nibu(in t){
    in mini=0,maxi=10000000ll;
    in half=(mini+maxi)/2ll;
    while(maxi-mini>1){
        if(jud(half,t)){
            mini=half;
            half=(mini+maxi)/2ll;
        }
        else{
            maxi=half;
            half=(mini+maxi)/2ll;
        }
    }
    if(jud(maxi,t)) return maxi;
    else return mini;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    auto x=soin(n);
    in ans=0ll;
    for(auto y:x){
        in s,t;
        tie(s,t)=y;
        ans +=nibu(t);
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3656
(defun solve (n x y)
  (labels ((calc-min-distance (start end x y)
             (assert (< start end))
             (min
              (abs (- end start))
              (+ (abs (- start y))
                 (abs (- end x))
                 1)
              (+ (abs (- start x))
                 (abs (- end y))
                 1))))
    (let ((res (make-array n)))
      (loop for i from 1 to (1- n)
         do (loop for j from (1+ i) to n
               do (incf (aref res (calc-min-distance i j x y)))))
      res)))


(defun main ()
  (let ((n (read))
        (x (read))
        (y (read)))
    (let ((ans (solve n x y)))
      (dotimes (i (1- n))
        (fresh-line)
        (princ (aref ans (1+ i))))
      (fresh-line))))


(main)


Measured memory_bytes: 24432
<?php

while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$args[] = $value;
		if (count($args) >= 1) {
			break;
		}
	}
	if (count($args) >= 1) {
		break;
	}
}

$str = $args[0];
$len = strlen($str);
if ($str[0] != "A") {
	echo "WA";
	exit();
}
$c_count = 0;
for ($i=2; $i < $len-1; $i++) { 
	$tmp = $str[$i];
	if (ctype_lower($tmp)) {
		continue;
	}elseif ($tmp == "C") {
		++$c_count;
	}else{
		echo "WA";
		exit();
	}
}

if ($c_count == 1 && ctype_lower($str[$len-1]) && ctype_lower($str[1])) {
	echo "AC";
}else{
	echo "WA";
}

Measured memory_bytes: 4856
#include <stdio.h>

int main(void)
{
	int a[3];
	int i, j;
	int min;

	scanf("%d %d %d", &a[0], &a[1], &a[2]);

	for (i = 0; i < 3; i++){
		for (j = 1; j < 3; j++){
			if (a[j - 1] > a[j]){
				min = a[j];
				a[j] = a[j - 1];
				a[j - 1] = min;
			}
		}
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);

	return (0);
}

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

const int M=1e5+5;
const int INF=0x3f3f3f3f;

struct TN
{
	int mi,p;
	TN(int mi=0,int p=0)
		:mi(mi),p(p){}
	bool operator<(const TN &B) const
	{
		return mi==B.mi?p<B.p:mi<B.mi;
	}
};
struct SegT
{
	TN tn[M*2];
	void init(int n)
	{
		for(int i=0;i<n*2;i++)
			tn[i]=TN(INF,INF);
	}
	int X,V,P;
	TN unite(const TN &u,const TN &v)
	{
		TN ans=u<v?u:v;
		return ans;
	}
	void pull(int o,int ls,int rs)
	{
		tn[o]=unite(tn[ls],tn[rs]);
	}
	void update(int o,int l,int r)
	{
		if(l==r)
		{
			tn[o]=TN(V,P);
			return;
		}
		int m=(l+r)>>1;
		int ls=o+1,rs=o+((m-l+1)<<1);
		if(X<=m) update(ls,l,m);
		else update(rs,m+1,r);
		pull(o,ls,rs);
	}
	int L,R;
	TN query(int o,int l,int r)
	{
		if(L<=l&&r<=R)
			return tn[o];
		int m=(l+r)>>1;
		int ls=o+1,rs=o+((m-l+1)<<1);
		TN ans(INF,-1);
		if(L<=m) ans=unite(ans,query(ls,l,m));
		if(m<R) ans=unite(ans,query(rs,m+1,r));
		return ans;
	}
}segt;

char s[M];
TN ans[M];
int st[M];

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	scanf("%s",s);
	segt.init(n);
	segt.X=segt.V=segt.P=0;
	segt.update(0,0,n);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='1') continue;
		segt.L=max(0,i-m); segt.R=i-1;
		
		ans[i]=segt.query(0,0,n);
		ans[i].mi++;

		segt.X=i;
		segt.V=ans[i].mi;
		segt.P=i;
		segt.update(0,0,n);
		//cout<<i<<" "<<ans[i].mi<<" "<<ans[i].p<<endl;
	}
	//cout<<ans[n].mi<<endl;
	if(ans[n].mi>=INF)
	{
		printf("-1\n");
		return 0;
	}
	int x=n;
	for(int i=ans[n].mi;i>0;i--)
	{
		st[i]=x-ans[x].p;
		x=ans[x].p;
	}
	for(int i=1;i<=ans[n].mi;i++)
		printf("%d%c",st[i],i==ans[n].mi?'\n':' ');
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main()
{   
    string s;
    cin >> s;
    int N = s.size();
    string ans;
    for(int i = 0; i < N; i+=2)
    {
        ans += s[i];
    }
    cout << ans << endl;    
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
  
  
namespace io{
    const int L = (1 << 20) + 1;
     
    char buf[L], *S , *T, c;
      
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
     
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
         
        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
         
        if(x)
            *--outs = x;
         
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};
  
using io :: print;
using io :: inp;
using io :: inp_ll;
const int maxM = 110;
const int maxN = 20;
int n,m;

char s[maxM][maxN];
bool same(char A[maxN],char B[maxN])
{
	int lena = strlen(A);
	int lenb = strlen(B);
	if(lena != lenb)
	{
		return false;
	}
	else
	{
		for(int i=0;i<lena;i++)
		{
			if(A[i] != B[i])
			{
				return false;
			}
		}
		return true;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]);

		if(i!=1)
		{
			int len1 = strlen(s[i-1]);
			int len2 = strlen(s[i]);
			if(s[i][0] != s[i-1][len1-1])
			{
				puts("No");
				return 0;
			}
			else
			{
				for(int j=1;j<i;j++)
				{
					if(same(s[j],s[i]))
					{
						puts("No");
						return 0;
					}
				}
			}
		}
	}
	puts("Yes");
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  val Array(a, b, c) = readLine.split(" ").map(_.toInt)
  var coin = 0
  var login = 0
  while (coin < c) {
    coin += a
    login += 1
    if (login % 7 == 0) {
      coin += b
    }
  }
  println(login)
}



Measured memory_bytes: 44080
#include<bits/stdc++.h>
    using namespace std;
    long int n=100,c=100000;
    long int solve(long int i,long int cap,vector<vector<long int>> &dp,vector<long int> &w,vector<long int> &v){
    	if(i==n)
    		return 0;
    	if(dp[i][cap]!=-1)
    		return dp[i][cap];
    	if(cap>=w[i])
    		dp[i][cap]=v[i]+solve(i+1,cap-w[i],dp,w,v);
    	dp[i][cap]=max(solve(i+1,cap,dp,w,v),dp[i][cap]);
    	return dp[i][cap];	
    }
     
    int main(){
    	cin>>n>>c;
    	vector<long int> w(n);
    	vector<long int> v(n);
    	for(long int i=0;i<n;i++){
    		cin>>w[i]>>v[i];
    	}
    	vector<vector<long int>> dp(n);
    	vector<long int> z(c+1);
    	for(long int i=0;i<c+1;i++)
    		z[i]=-1;
    	for(long int i=0;i<n;i++)
    		dp[i]=z;
    	cout<<solve(0,c,dp ,w,v);
    	return 0;
    }

Measured memory_bytes: 79488
//g++でビルド

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>

using namespace std;

int main(){
    int N, M;
    int result = 0;
    
    cin >> N >> M;
    int ints[M];
    for(int i = 0; i < M; i++){
        ints[i] = 0;
    }

    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        for(int j = 0; j < K; j++){
            int A;
            cin >> A;
            ints[A - 1]++;
        }
    }

    for(int i = 0; i < M; i++){
        if(ints[i] == N){
            result++;
        }
    }
    
    cout << result << endl;
}



Measured memory_bytes: 256
parseInput input = map read $ words input :: [Int]

solve :: [(Int, Int)] -> Int
solve [] = 0
solve ((a, b) : xs) = a - b + solve xs

main = do
    n <- readLn :: IO Int
    input <- getLine
    let xs = parseInput input
    line <- getLine
    let ys = parseInput line

    let lst = zip xs ys
    print $ solve (filter(\(x, y) -> (x - y) > 0) lst)
    
    


Measured memory_bytes: 764
n=int(input())

mod=10**9+7

#初期値が0の辞書
from collections import defaultdict
pp = defaultdict(lambda: 0) 
pm = defaultdict(lambda: 0) 

def seiki(x,y):
    tmp=gcd(x,y)
    return (x//tmp,y//tmp)

from math import gcd
zero=0
for _ in range(n):
    a,b=map(int,input().split())

    if a==0 and b==0:
        zero+=1
    elif a*b>0:
        tmp=seiki(abs(a),abs(b))
        pp[tmp]+=1
    elif a==0:
        pp[(1,0)]+=1
    elif b==0:
        pm[(1,0)]+=1
        pp[(1,0)]+=0
    else:
        tmp=seiki(abs(b),abs(a))
        pm[tmp]+=1
        pp[tmp]+=0
#print(pm)
#print(pp)
result=1
for key in pp.keys():
    pp_v=pp[key]
    pm_v=pm[key]
    result*=(pow(2,pm_v,mod)+pow(2,pp_v,mod)-1)
    result%=mod

print((result-1+zero)%mod)


    

    

Measured memory_bytes: 62724
<?php
fscanf(STDIN, '%d', $cnt);
for ($i=0; $i < $cnt; $i++) { 
    fscanf(STDIN, '%s', $strings[]);
}
$acvs = array_count_values($strings);
arsort($acvs);
$keyCnt = count($acvs);
$max = $acvs[array_keys($acvs)[0]];
foreach ($acvs as $key => $value) {
    if ($value < $max) {
        break;
    }
    $answers[] = $key;
}
sort($answers);
$ansCnt = count($answers);
for ($i=0; $i < $ansCnt; $i++) { 
    echo $answers[$i]."\n";
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 2e5 + 5;
int n, a[mxn], b[mxn];
set <int> oa[mxn], ob[mxn];
int cnt[mxn], ans[mxn];
set <int> aa, ab;
set <pair <int, int> > st;

void Rua(int x, int y) {
	int px = *oa[x].begin();
	int py = *ob[y].begin();
	ans[px] = y;
	oa[x].erase(px);
	if (oa[x].empty()) aa.erase(x);
	ob[y].erase(py);
	if (ob[y].empty()) ab.erase(y);
	st.erase(mp(cnt[x], x));
	-- cnt[x];
	if (cnt[x]) st.insert(mp(cnt[x], x));
	st.erase(mp(cnt[y], y));
	-- cnt[y];
	if (cnt[y]) st.insert(mp(cnt[y], y));
}

void testA(pair <int, int> p) {
	if (oa[p.second].empty()) throw 0;
	if (ab.empty()) throw 0;
	if (*ab.begin() != p.second)
		Rua(p.second, *ab.begin());
	else {
		if (ab.size() == 1) throw 0;
		Rua(p.second, *++ ab.begin());
	}
}

void testB(pair <int, int> p) {
	if (*aa.begin() != p.second)
		Rua(*aa.begin(), p.second);
	else
		Rua(*++ aa.begin(), p.second);
}

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]), -- a[i];
	rep(i, n) scanf("%d", &b[i]), -- b[i];
	rep(i, n) cnt[a[i]] ++, cnt[b[i]] ++;
	rep(i, n) oa[a[i]].insert(i), ob[b[i]].insert(i);
	rep(i, n) if (cnt[i] > n) { puts("No"); return 0; }
	rep(i, n) if (cnt[i]) st.insert(mp(cnt[i], i));
	rep(i, n) if (oa[i].size()) aa.insert(i);
	rep(i, n) if (ob[i].size()) ab.insert(i);
	rep(tc, n) {
		pair <int, int> p = *st.rbegin();
		try { testA(p); }
		catch(int x) { testB(p); }
	}
	puts("Yes");
	rep(i, n) printf("%d ", ans[i] + 1);
	puts("");
	return 0;
}


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

int k,t,ma;
signed main(){
	cin>>k>>t;
	rep(i,t){
		int a;
		cin>>a;
		ma=max(ma,a);
	}
	if((k+1)/2>=ma)cout<<0<<endl;
	else{
		if(k%2)cout<<(ma-(k+1)/2)*2<<endl;
		else cout<<(ma-(k+1)/2)*2-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m), n + m){
		int array_a[200];
		int array_b[200];
		int sum_a = 0;
		int sum_b = 0;
		
		for (int i = 0; i < n; i++){
			scanf("%d", &array_a[i]);
			sum_a += array_a[i];
		}
		for (int i = 0; i < m; i++){
			scanf("%d", &array_b[i]);
			sum_b += array_b[i];
		}
		
		int min = 1145141919;
		int min_a;
		int min_b;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				if (sum_a - array_a[i] + array_b[j] == sum_b - array_b[j] + array_a[i]){
					if (array_a[i] + array_b[j] < min){
						min = array_a[i] + array_b[j];
						min_a = i;
						min_b = j;
					}
				}
			}
		}
		
		if (min != 1145141919){
			printf("%d %d\n", array_a[min_a], array_b[min_b]);
		}
		else {
			printf("-1\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1044
#define _USE_MATH_DEFINES
#include <iostream> 
using namespace std; 
int main(){
	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	if(1000 <= c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500){
		cout << 1 << endl; 
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
import math
a,b,x=map(int,input().split())

S=x/a

if S<=a*b/2:
    A=S/b*2
    B=b
    print(math.degrees(math.atan2(B,A)))
    
else:
    S=a*b-S
    A=a
    B=S/a*2
    print(90-math.degrees(math.atan2(A,B)))

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int n=sz(s);
	
	bool ng=false;
	int psc=-1;
	if(s[0] !='A') ng=true;
	rep2(i, 1, n){
		if(s[i]=='C' && psc==-1){psc=i;}
		else if(s[i]=='C' && psc !=-1){ng=true;}
		if(s[i]!='C' && (s[i] <'a' || s[i]>'z')) ng=true;
	}
	if(psc <2 || psc >n-2) ng=true;
	
	puts(ng? "WA": "AC");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  char c;
  std::cin >> c;

  char vowel[5] = { 'a', 'e', 'i', 'o', 'u' };
  bool is_vowel = false;
  for (int i = 0; i < 5; ++i) {
    if ( c == vowel[i] ) {
      is_vowel = true;
      break;
    }
  }
  if ( is_vowel ) {
    std::cout << "vowel" << std::endl;
  } else {
    std::cout << "consonant" << std::endl;
  }

  return 0;
}


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

X = len(str(N))

if X == 1:
    print(N)
elif X == 2:
    print(9)
elif X == 3:
    print(9 + (N - 100 + 1))
elif X == 4:
    print(909)
elif X == 5:
    print(9 + 900 + (N - 10000 + 1))
elif X == 6:
    print(90909)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	int x;
	cin >> x;
	int h = x / 3600;
	int m = (x % 3600) / 60;
	int s = (x % 3600) % 60;
	cout << h<< ":" << m<< ":"<<s<< endl;
	return 0;
}

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

using namespace std;

using ll = long long;

bool check(int n, vector<string>& a) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i][j] == '#') return false;
        }
    }
    return true;
}

void change(int n, vector<string>& a, int idx) {
    for (int j = 0; j < n; j++) {
        if (a[idx][j] == '#') continue;
        if (j == idx) continue;
        string s = a[idx];
        for (int i = 0; i < n; i++) {
            a[i][j] = s[i];
        }
    }

    if (a[idx][idx] == '#') return;

    string s = a[idx];
    for (int i = 0; i < n; i++) {
        a[i][idx] = s[i];
    }
}

int solve(int n, vector<string> a, int idx, int minv) {
    for (int j = 0; j < n; j++) {
        if (a[idx][j] == '#') continue;
        for (int i = 0; i < n; i++) {
            a[i][j] = (i == idx ? '#' : '.');
        }
    }
    
    int ans = minv + n;
    for (int j = 0; j < n; j++) {
        bool f = true;
        for (int i = 0; i < n; i++) {
            if (i == idx) continue;
            if (a[i][j] == '.') {
                f = false;
                break;
            }
        }

        ans -= f;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (check(n, a)) {
        cout << -1 << endl;
        return 0;
    }

    int minv = n + 1;
    vector<int> idxs;
    for (int i = 0; i < n; i++) {
        bool f = false;
        for (int ii = 0; ii < n; ii++) {
            if (a[ii][i] == '#') {
                f = true;
                break;
            }
        }
        
        int cnt = !f;
        for (int j = 0; j < n; j++) {
            cnt += (a[i][j] == '.');
        }

        if (minv > cnt) {
            minv = cnt;
            idxs.clear();
            idxs.push_back(i);
        } else if (minv == cnt) {
            idxs.push_back(i);
        }
    }

    if (minv > n) {
        cout << -1 << endl;
        return 0;
    }

    int ans = minv + n;
    for (int idx : idxs) {
        ans = min(ans, solve(n, a, idx, minv));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    string s,t; cin >> s >> t;

    set<string> st;
    int t_pos = 0;
    int s_pos = 0;
    int start_pos = s_pos;
    while(s_pos < s.size()) {
//        cout << s_pos << endl;
//        cout << t_pos << endl;
//        cout << "___" << endl;
        if(t_pos >= t.size()) {
            string tmp = s;
            tmp.replace(s_pos-t.size(), t.size(), t);
            replace(tmp.begin(), tmp.end(), '?', 'a');
            st.insert(tmp);
            s_pos -= t.size()-1;
            t_pos = 0;
            continue;
        }
        if(t[t_pos] == s[s_pos] || s[s_pos] == '?') {
            if(t_pos == 0) start_pos = s_pos;
            t_pos++;
        } else if(t_pos != 0) {
            t_pos = 0;
            if(t[t_pos] == s[s_pos]) {
                start_pos = s_pos;
                t_pos++;
            } else {
                s_pos = start_pos;
            }
        }
        s_pos++;
    }
    if(t_pos >= t.size()) {
        string tmp = s;
        tmp.replace(s_pos-t.size(), t.size(), t);
        replace(tmp.begin(), tmp.end(), '?', 'a');
        st.insert(tmp);
    }
    if(st.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << *st.begin() << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
long long power[64];
std::vector<int> tmpRes, res;

int main() {
	
	//freopen("test.inp", "r", stdin);
	int n;
	scanf("%d", &n);
 
	int t = 1, sum = 0;

	while (sum < n) {
		sum +=t;
		t ++;
	}
	
	for (int i = 1; i <= t-1; i++){
		if (i != sum - n) {
			printf("%d\n", i);
		}
	}
}

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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

signed main(){

	int N, C;
	cin >> N >> C;
	int D[31][31];
	for (int i = 1; i <= C; i++)
		for (int j = 1; j <= C; j++)
			cin >> D[i][j];

	int c[501][501];
	int color[3][31] = { 0 };
	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= N; j++){
			cin >> c[i][j];
			color[(i + j) % 3][c[i][j]]++;
		}
	}

	int nc[3];
	int ans = INF;
	for (nc[0] = 1; nc[0] <= C; nc[0]++)
		for (nc[1] = 1; nc[1] <= C; nc[1]++){
			if (nc[1] == nc[0]) continue;
			for (nc[2] = 1; nc[2] <= C; nc[2]++){
				if (nc[2] == nc[0] || nc[2] == nc[1]) continue;

				int t = 0;
				for (int i = 1; i <= C; i++){
					// color[0]をnc[0]に塗り替える
					t += D[i][nc[0]] * color[0][i];
					t += D[i][nc[1]] * color[1][i];
					t += D[i][nc[2]] * color[2][i];
				}
//				cerr << nc[0] << nc[1] << nc[2] << " " << t << endl;
				ans = min(ans, t);
			}
		}

			cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
n, k = gets.split.map(&:to_i)
sum = 0
(k..n+1).each do |j|
  min = j * (j-1) / 2
  max = (n + n - j + 1) * j / 2
  sum = (sum + (max - min + 1) % 1000000007 ) % 1000000007
end
puts sum

Measured memory_bytes: 14328
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  string S;
  cin>>S;
  if(S.at(0)==S.at(1) || S.at(2)==S.at(1) || S.at(2)==S.at(3)) cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;

    int count = 0;
    for(int i = 0; i < 4; ++i){
        if('2' == s.at(i)){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

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

string N;
unsigned int dp[2][2];

template<typename T> void minUpdate(T& a, T b) { a = min(a, b); }

int main() {
	cin >> N;
	
	int n = N.size();
	reverse(N.begin(), N.end());
	N += '0';
	
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	for (int i=0; i<=n; ++i) {
		for (int f=0; f<2; ++f) {
			if (i == 0 and f == 1) continue;
			int x = int(N[i] - '0') + f;
			if (x == 10) {
				minUpdate(dp[1][1], dp[0][f]);
			}
			else {
				minUpdate(dp[1][1], dp[0][f] + 10 - x);
				minUpdate(dp[1][0], dp[0][f] + x);
			}
		}
		swap(dp[0], dp[1]);
		memset(dp[1], -1, sizeof(dp[1]));
	}
	
	cout << min(dp[0][0], dp[0][1]) << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
long long v[2][N];
int S[2];

long long closest(long long x, int w, int depth) {
  if (!depth) return 0;
  long long *s = lower_bound(v[w], v[w]+S[w], x);
  long long ret = 1e15;
  if (s-v[w] < S[w]) {
    ret = *s-x + closest(*s, !w, depth-1);
  }
  if (s-v[w] > 0) {
    ret = min(ret, abs(*--s-x)+closest(*s, !w, depth-1));
  }
  return ret;
}

void solve() {
  int q; scanf("%d%d%d", S, S+1, &q);
  for (int i = 0; i < S[0]; ++i) {
    scanf("%lld", v[0]+i);
  }
  for (int i = 0; i < S[1]; ++i) {
    scanf("%lld", v[1]+i);
  }
  for (int i = 0; i < q; ++i) {
    long long x; scanf("%lld", &x);
    printf("%lld\n", min(closest(x, 0, 2), closest(x, 1, 2)));
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5384
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
const int N=2e5;
char stk[N];
int p=0;
int main(){
	char c;
	stk[0]='T';
	while(cin>>c){
		if(p==0){
			stk[++p]=c;
			continue;
		}
		if(c=='T'&&stk[p]=='S'){
			p--;
			continue;
		}
		stk[++p]=c;
	}
	cout<<p;
} 

Measured memory_bytes: 384
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = s()

alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(len(s)):
	for j in range(26):
		if s[i] == alf[j]:
			print(alf[j+n],end="")
			continue

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

int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  vector<int> seq;
  if(s[0] == '0') seq.push_back(0);
  for(int i = 0; i < s.size();){
    int j = i;
    while(j < s.size() && s[j] == s[i]) j++;
    seq.push_back(j-i);
    i = j;
  }
  if(s.back() == '0') seq.push_back(0);
  vector<int> sum((int)seq.size()+1, 0);
  for(int i = 0; i < seq.size(); i++){
    sum[i+1] = sum[i] + seq[i];
  }
  int ans = 0;
  for(int i = 0; i < sum.size(); i += 2){
    int tmp = i + 2*k + 1;
    if(tmp >= sum.size()) tmp = sum.size() - 1;
    ans = max(ans, sum[tmp] - sum[i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 1272
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long a = nl();
		long b = nl();
		long c = nl();
		long k = nl();

		if (k <= a) {
			out(k);
		} else if (k <= a + b) {
			out(a);
		} else {
			out(a + a + b - k);
		}

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

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

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


Measured memory_bytes: 35836
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
    #define FOR(n) for(int i=0;i<n;i++)
    #define PRS(s) cout<<s
    int main(void){
      int n,cnt=0;
      cin>>n;
      FOR(n){
        int a;
        cin>>a;
        if(a!=i+1)cnt++;
      }
      if(cnt<3){
        PRS("YES");
      }else
        PRS("NO");
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int w,n,m[100009],ans=1e8,x,y;
main(){
  cin>>w>>n>>n;
  r(i,n){
    cin>>x>>y;
    m[x]=max(m[x],y);
  }
  r(i,w)m[w-i-1]=max(m[w-i-1],m[w-i]);
  r(i,w)ans=min(ans,i+m[i+1]);
  cout<<ans<<endl;
}

Measured memory_bytes: 3464
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
struct trie {
    trie *son[2];
    inline trie() { son[0] = son[1] = NULL; }
} * root;
int n, l, ans = 0;
char buf[100010];
inline void Insert() {
    trie *p = root;
    for (int i = 0; buf[i]; i++) {
        const int x = buf[i] - '0';
        if (p->son[x])
            p = p->son[x];
        else
            p = (p->son[x] = new trie());
    }
}
void DFS(trie *node, int d) {
    if (!node || (!node->son[0] && !node->son[1])) return;
    if (node->son[0] && node->son[1]) {
        DFS(node->son[0], d + 1);
        DFS(node->son[1], d + 1);
        return;
    }
    int now = l - d, cnt = 1;
    while (now && !(now & 1)) cnt++, now >>= 1;
    ans ^= cnt;
    if (node->son[0])
        DFS(node->son[0], d + 1);
    else
        DFS(node->son[1], d + 1);
}
int main() {
    scanf("%d%d", &n, &l);
    root = new trie();
    for (int i = 1; i <= n; i++) {
        scanf("%s", buf);
        Insert();
    }
    DFS(root, 0);
    puts(ans ? "Alice" : "Bob");
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {

int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
if(a==0){

    cout<<1<<endl;
}
if(b==0){
    
    cout<<2<<endl;
}if(c==0){
    
    cout<<3<<endl;
}if(d==0){
    
    cout<<4<<endl;
}if(e==0){
    
    cout<<5<<endl;
}
}

Measured memory_bytes: 3636
A, B, C = list(map(int, input().split()))

if A <= B and B <= C:
    a = A
    b = B
    c = C
elif A <= B and C <= A:
    a = C
    b = A
    c = B
elif A <= C and C <= B:
    a = A
    b = C
    c = B
elif B <= A and A <= C:
    a = B
    b = A
    c = C
elif B <= C and C <= A:
    a = B
    b = C
    c = A
else:
    a = C
    b = B
    c = A

max_num = int(str(c) + str(b)) + a

print(max_num)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
int H,N,P,s=0;
cin>>H>>N;
for(int i=1;i<=N;i++)
{
	cin>>P;
	s=s+P;
}
if(s>=H)
{
	cout<<"Yes";
}
else
{
	cout<<"No";
}
return 0;
} 

Measured memory_bytes: 3612