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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        if (n % 2 == 0) System.out.println(n);
        else System.out.println(n*2);
    }
}


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

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

	int ans = 0;
	for( int i = 0; i < s.size(); i++ ) {
		if( s[ i ] == '+' ) {
			ans += 1;
		}
		if( s[ i ] == '-' ) {
			ans -= 1;
		}
	}

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


Measured memory_bytes: 760
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, T;
    cin >> N >> T;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i] >> B[i]; }

    ll dp1[N + 5][T + 5];
    memset(dp1, 0, sizeof(dp1));
    rep(i, N) {
        rep(j, T) {
            if (j - A[i] >= 0)
                dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j - A[i]] + B[i]);
            dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j]);
        }
    }

    ll dp2[N + 5][T + 5];
    memset(dp2, 0, sizeof(dp2));
    for (int i = N - 1; i >= 1; i--) {
        for (int j = 0; j <= T - 1; j++) {
            if (j - A[i] >= 0)
                dp2[i + 1][j] = max(dp2[i][j], dp2[i + 2][j - A[i]] + B[i]);
            dp2[i + 1][j] = max(dp2[i + 1][j], dp2[i + 2][j]);
        }
    }

    ll ans = 0;
    for (int i = 0; i <= N - 1; i++) {
        for (int j = 0; j < T; j++) {
            ll tmp = dp1[i][T - 1 - j] + dp2[i + 2][j];
            tmp += B[i];
            ans = max(tmp, ans);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 144680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n);
    REP(i,n){
        cin>>vec[i]; 
    }
    sort(all(vec));
    REP(i,n){
        m-=vec[i];
        if(m<0){
            cout<<i<<endl;
            return 0;
        }
    }
    if(!m){
        cout<<n<<endl;
    }else{
        cout<<n-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split().map { |a| a.to_i }
count = 0

200.times do |n|
  odd_flg = a.map { |a| a.odd? }.include?(true)
  next if odd_flg
  a = a.map { |a| a / 2 }
  count += 1
end
puts count

Measured memory_bytes: 2172
from collections import deque

def main():
    H, W = map(int, input().split())

    field = [list(input()) for i in range(H)]

    cnt = 0
    for i in range(H):
        cnt += field[i].count('.')
    
    def bfs():
        d = [[float('inf')] * W for i in range(H)]

        dx = [1,0,-1,0]
        dy = [0,1,0,-1]

        que = deque([])
        que.append((0,0))
        d[0][0] = 1

        while que:
            y,x = que.popleft()
            if y == H - 1 and x == W - 1:
                return d[y][x]

            for i in range(4):
                nx = x + dx[i]
                ny = y + dy[i]

                if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != '#' and d[ny][nx] == float('inf'):
                    que.append((ny,nx))
                    d[ny][nx] = d[y][x] + 1

        return -1

    num = bfs()

    if num == -1:
        print(num)
    else:
        print(cnt - num)

main()

Measured memory_bytes: 40688
#include<iostream>

using namespace std;

int main(){
    //入力
    long n;
    cin>>n;
    long A[n+1],B[n];
    for(long i=0;i<n+1;i++){
        cin>>A[i];
    }
    for(long i=0;i<n;i++){
        cin>>B[i];
    }
    //処理
    long x=0,rest=0;
    for(long i=0;i<n;i++){
        if(A[i]-rest>=B[i]){
            x+=B[i];
            rest=0;
        }
        else{
            if(B[i]>=A[i]-rest+A[i+1]){
                A[i]-rest+A[i+1]>0?x+=A[i]-rest+A[i+1]:x+=0;
                rest=A[i+1];
            }else{
                rest=B[i]-A[i]+rest;
                x+=B[i];
            }
        }
    }
    //出力
    cout<<x<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> ip;

bool ok(string& s, string& t) {
	int c[26] = { 0 };
	for (int i = 0; i < s.size(); i++) {
		c[s[i] - 'a']++;
		c[t[i] - 'a']--;
	}
	for (int i = 0; i < 26; i++) if (c[i]) return false;
	return true;
}

bool rev(string& s, string& t) {
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[s.size() - 1 - i]) return false;
	}
	return true;
}

string a[12];
int h, w;
bool pick[12];
string t[12];

bool pos(vector<ip>& v) {
	int cur = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i].first == v[i].second) {
			t[h / 2] = a[v[i].first];
		}
		else {
			t[cur] = a[v[i].first];
			t[h - 1 - cur] = a[v[i].second];
			cur++;
		}
	}
	vector<string> p;
	for (int j = 0; j < w; j++) {
		string s = "";
		for (int i = 0; i < h; i++)
			s += t[i][j];
		p.push_back(s);
	}
	bool fin[12] = { false };
	if (w % 2) {
		for (int i = 0; i < p.size(); i++) if (rev(p[i], p[i])) {
			memset(fin, 0, sizeof(fin));
			fin[i] = true;
			int rem = p.size() - 1;
			bool ok = true;
			while (rem) {
				bool chg = false;
				for (int i = 0; i < p.size(); i++) if (!fin[i]) {
					bool found = false;
					for (int j = i + 1; j < p.size(); j++) if (!fin[j] && rev(p[i], p[j])) {
						fin[i] = fin[j] = true;
						found = true;
						break;
					}
					if (!found) break;
					else {
						chg = true; rem -= 2;
					}
				}
				if (!chg) break;
			}
			if (!rem) return true;
		}
		return false;
	}
	else {
		int rem = p.size();
		while (rem) {
			for (int i = 0; i < p.size(); i++) if (!fin[i]) {
				bool found = false;
				for (int j = i + 1; j < p.size(); j++) if (!fin[j] && rev(p[i], p[j])) {
					fin[i] = fin[j] = true;
					found = true;
					rem -= 2;
					break;
				}
				if (!found) return false;
			}
		}
		return true;
	}
}

bool dfs(vector<ip>& v) {
	if (v.size() == (h + 1) / 2) {
		return pos(v);
	}
	for (int i = 0; i < h; i++) if (!pick[i]) {
		for (int j = i + 1; j < h; j++) if (!pick[j] && ok(a[i], a[j])) {
			v.push_back(ip(i, j));
			pick[i] = pick[j] = true;
			if (dfs(v)) return true;
			pick[i] = pick[j] = false;
			v.pop_back();
		}
		break;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		cin >> a[i];
	vector<ip> v;
	if (h % 2) {
		for (int i = 0; i < h; i++) {
			v.push_back(ip(i, i));
			pick[i] = true;
			if (dfs(v)) {
				cout << "YES\n";
				return 0;
			}
			pick[i] = false;
			v.pop_back();
		}
		cout << "NO\n";
	}
	else {
		if (dfs(v)) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
n, m, x, y = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

a.sort!
b.sort!

if a.last < b[0] && x < b[0] && y > b[0]
	puts "No War"
else
	puts "War"
end


Measured memory_bytes: 1788
import sys


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, m = map(int, read().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b,  = [int(i) - 1 for i in read().split()]
        uf.union(a, b)
    print(-min(uf.parents))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14700
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

map<ll,ll> dp;
ll INF = 1e18;
ll a,b,c,d;
ll dfs(ll n){
    if(n==0) return 0;
    if(n==1) return d;
    if(dp.count(n)) return dp[n];
    __int128 tmp = __int128(d)*n;
    ll res = min(__int128(INF),tmp);
    auto baw=[&](ll x,ll piyo){
        if(n%x){
            res = min(res,piyo+dfs(n/x)+(n%x)*d);
            if(n/x+1!=n) res = min(res,piyo+dfs(n/x+1)+(x-n%x)*d);
        }
        else{
            res = min(res,piyo+dfs(n/x));
        }
    };
    baw(2,a);
    baw(3,b);
    baw(5,c);
    return dp[n] = res;
}
void solve(){
    dp.clear();
    ll n;
    cin>>n>>a>>b>>c>>d;
    cout<<dfs(n)<<endl;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 4436
mod = 10**9+7
n = int(input())
a = [int(i) for i in input().split()]

sum_a = [0]*(n-1)
sum_a[0] = a[n-1]

for i in range(1,n-1):
    sum_a[i] = sum_a[i-1] + a[n-1-i]
    
ans = 0

for i in range(n-1):
    #print(n-1-i)
    ans += a[i]*sum_a[n-2-i]
    ans %= mod
    
print(ans)

Measured memory_bytes: 94168
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    string s;
    ll K;
    cin >> s >> K;
    vector<vector<ll>> ch(26,vector<ll>());
    for(int i=0;i<(ll)s.size();i++){
        ch[s[i]-'a'].push_back(i);
    }
    vector<string> strs;
    set<string> st;
    for(int i=0;i<26;i++){
        string tmp="";
        if(strs.size()>K) break;
        for(ll e : ch[i]){
            for(int l=e;l<e+K;l++){
                tmp=s.substr(e,l-e+1);
                if(st.count(tmp)==0){
                    st.insert(tmp);
                    strs.push_back(tmp);
                }
            }
        }
    }
    sort(strs.begin(),strs.end());
    cout << strs[K-1] << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

        int n = sc.nextInt();
        String s = sc.next();
        if (s.substring(0, n / 2).equals(s.substring(n / 2))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
int tree[(1<<18)];

void add(int i,int x){
  i+=((1<<17)-1);
  tree[i]+=x;
  while(i){
    i=(i-1)/2;
    tree[i]=tree[i*2+1]+tree[i*2+2];
  }
}

int getsum(int a,int b,int n,int l,int r){
   if(r<=a || b<=l) return 0;
   if(a<=l && r<=b)return tree[n];
    int m=(l+r)/2;
   return getsum(a,b,n*2+1,l,m)+getsum(a,b,n*2+2,m,r);
}


int main(){
  int n,q,a,b,c;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    cin>>a>>b>>c;
    if(a==1){
      cout<<getsum(b-1,c,0,0,(1<<17))<<endl;
    }
    else add(b-1,c);
  }
  return 0;
}

Measured memory_bytes: 1960
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  int a,d=0,e,f,g;
  cin>>a;
  vector<int> b(a+2,0);
  for(int i=1;i<=a;i++)
    cin>>b.at(i);
  for(int i=0;i<a+1;i++)
    d+=abs(b.at(i)-b.at(i+1));
  for(int i=1;i<a+1;i++){
    e=b.at(i-1);
    f=b.at(i);
    g=b.at(i+1);
    if((e<=f&&f<=g)||(e>=f&&f>=g))
      cout<<d<<endl;
    else
      cout<<d-min(2*abs(e-f),2*abs(f-g))<<endl;
  }
}

Measured memory_bytes: 2048
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars,
    }
    let mut ans = n;
    let mut w2r = 0;
    let mut r2w = s.iter().filter(|&&c| c == 'R').count();
    for i in 0..=n {
        ans = cmp::min(ans, cmp::max(w2r, r2w));
        if i == n {
            break;
        }
        if s[i] == 'W' {
            w2r += 1;
        } else {
            r2w -= 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 3084
#include <stdio.h>
int main(void) {
    int num,score,sum,min,max,i;
    while (1) {
        scanf("%d",&num);
        if (num==0) break;
        sum=0;
        for (i=0; i<num; i++) {
            scanf("%d",&score);
            sum+=score;
            if (i==0) {
                max=score;
                min=score;
            } else if (score>max) {
                max=score;
            } else if (score<min){
                min=score;
            }
        }
        printf("%d\n",(sum-max-min)/(num-2));
    }
    return 0;
}

Measured memory_bytes: 600
#include <cstdlib>
#include <iostream>

using namespace std;

long gcd(long x, long y){
  long t;
  if(x < y){
    long tmp = x;
    x = y;
    y = tmp;
  }
  t = x%y;
  if(t==0){
    return y;
  } else {
    return gcd(y, t);
  }
}

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

  cout << (a*b)/gcd(a,b) << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int a1,a2,a3;cin>>a1>>a2>>a3;
  if(a1+a2+a3>=22)cout<<"bust"<<endl;
  else cout <<"win"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
   int yahho()
    {
      
      int cnt=0,nn;
      
      for(int i=0;i<r.size();i++)
      {
        if(0>r[i]){cnt++;}
      }
      return cnt;
    }
};
 
 
int main() {
    int N, M;
    cin >> N >> M;
 
    //友達集合を作る
    UnionFind UF(N);
    for (int i = 0; i < M; i++)
    {
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
    }
   
  cout<<UF.yahho()-1<<endl;
    //最大の友達集合を求める
  
 
    
}

Measured memory_bytes: 3788
<?php

$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$num = range('0', '25');
$alp = range('A', 'Z');
$l = [];
for($i=0; $i<=25; $i++){
  $l[$alp[$i]] = $num[$i];
}

for($i=0; $i<strlen($s); $i++){
  $ln = ($l[$s[$i]]+$n)%26;
  echo $alp[$ln];
}

?>

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

int main(){
  using namespace std;
  int num;
  int line[1000][3];

  cin>>num;
  for(int i=0;i<num;i++){
    cin>>line[i][0]>>line[i][1]>>line[i][2];
    sort(line[i],line[i]+3);
  }
  for(int i=0;i<num;i++){
    if(((line[i][0]*line[i][0])+(line[i][1]*line[i][1]))==(line[i][2]*line[i][2]))cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

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


int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u) {cout << a-1 << " " << b << endl;}
  if (t == u) {cout << a << " " << b-1 << endl;}
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String[] args)
    
  {
    Scanner sc=new Scanner(System.in);
    
    String s=sc.next();
    
   
    
    String s1="Sunny",s2="Cloudy",s3="Rainy";
    if(s.equals(s1))
    {
    	System.out.println(s2);
    }
    else if(s.equals(s2))
    {
    	System.out.println(s3);
    }
    else
    {
      System.out.println(s1);
    }
  }
}

Measured memory_bytes: 20948
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N;
    string W[100];
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> W[i];
    }
    for (int i=0;i<N;i++){
        for (int j=0;j<N;j++){
            if (i!=j){
                if (W[i]==W[j]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    for (int i=1;i<N;i++){
        if(W[i-1][W[i-1].size()-1]!=W[i][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
vote = [1, 1]

for i in range(N):
    T, A = map(int, input().split())
    t = vote[0] // T + min(1, vote[0] % T)
    a = vote[1] // A + min(1, vote[1] % A)
    if t > a:
        vote[0] = T * t
        vote[1] = A * t
    else:
        vote[0] = T * a
        vote[1] = A * a

print(sum(vote))

Measured memory_bytes: 3064
//In The Name Of Godd
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vii> vvii;

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forr(i, n) for (ll i = n; i >= 0; i--)
#define fore(i, x, n) for (ll i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define inf 100000000000
#define eps 1e-9

const int maxk = 1e5 + 10;
const int maxn = 110;
bool dp[maxk];
int n, k;

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    vi nms(n);
    forn(i, n) cin >> nms[i];
    forn(i, k + 1) {
        dp[i] = false;
        forn(j, n) if(i - nms[j] >= 0) {
            dp[i] |= !dp[i - nms[j]];
        }
    }
    cout << (dp[k] == 1 ? "First" : "Second") << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int list[] = new int[S + 1];
		long ans = 0;
		for (int i = 1; i < S + 1; i++) {
			if (i % 3 == 0 || i % 5 == 0) {
			} else {
				ans = ans + i;
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

struct Edge {
	Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
	int to, cap, rev;
};

class MaxFlow {
public:
	explicit MaxFlow(int n) : g(n), level(n), iter(n) {}
	vector< vector<Edge> > g;
	vector<int> level;
	vector<int> iter;
	void addEdge(int src, int dst, int cap){
		g[src].emplace_back(Edge(dst, cap, g[dst].size()));
		g[dst].emplace_back(Edge(src, 0, g[src].size()-1));
	}
	int dfs(int pos, int dst, int f){
		if(pos == dst) return f;
		for(int& i=iter[pos];i<g[pos].size();++i){
			Edge& e = g[pos][i];
			if(e.cap == 0 || level[e.to] <= level[pos]) continue;
			int d = dfs(e.to, dst, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}
	int maxFlow(int s, int t){
		int res = 0;
		int n = g.size();
		while(true){
			for(int i=0;i<n;i++) level[i] = -1;
			level[s] = 0;
			queue<int> qu; qu.push(s);
			while(!qu.empty()){
				int p = qu.front(); qu.pop();
				for(const Edge& e : g[p]){
					if(e.cap > 0 && level[e.to] == -1){
						level[e.to] = level[p]+1;
						qu.push(e.to);
					}
				}
			}
			if(level[t] == -1) break;
			for(int i=0;i<n;i++) iter[i] = 0;
			for(int f;(f=dfs(s,t,1000000007)) > 0;res+=f);
		}
		return res;
	}
};

int main(){
	int H, W;
	while(cin >> H >> W){
        MaxFlow f(2*H*W+2);
        int sx, sy, tx, ty;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                for(int k=0;k<H;k++){
                    if(i == k) continue;
                    f.addEdge(H*W+i*W+j, k*W+j, 1);
                }
                for(int k=0;k<W;k++){
                    if(j == k) continue;
                    f.addEdge(H*W+i*W+j, i*W+k, 1);
                }
            }
            string S; cin >> S;
            for(int j=0;j<W;j++){
                if(S[j] == '.') continue;
                f.addEdge(i*W+j, H*W+i*W+j, 1);
                if(S[j] == 'S'){ sx = i; sy = j; f.addEdge(2*H*W, H*W+i*W+j, 10000); }
                if(S[j] == 'T'){ tx = i; ty = j; f.addEdge(i*W+j, 2*H*W+1, 10000);}
            }
        }
        if(sx == tx || sy == ty){
             cout << -1 << endl;
        } else {
            cout << f.maxFlow(2*H*W, 2*H*W+1) << endl;
        }
	}
}


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

using ll = long long;
const int MAXN  = 2e5+10;
const int MAXM  = 1e5+10;

int N, M;

struct edge {
    int to, w;
};
vector<edge> G[MAXN];
int in[MAXN];
int d[MAXN];
bool vis[MAXN];

void add(int u, int v, int w) {
    G[u].push_back({v, w});
}
int bfs(int s) {
    queue<int> que;
    que.push(s);
    vis[s] = true;
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i=0; i<G[u].size(); i++) {
            int v = G[u][i].to;
            if(d[v]<d[u]+1) {
                que.push(v);
                vis[v] = true;
                d[v] = d[u] + 1;
            }
        }
    }

    int ret = 0;
    for(int i=1; i<=N; i++) {
        ret = max(ret, d[i]);
    }    
    return ret;
}
int solve(int s) {
    queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i = 0; i<G[u].size(); i++) {
            int v = G[u][i].to;
            --in[v];
            if(in[v]==0) {
                if(d[v] < d[u]+1) {
                    d[v] = d[u] + 1;
                }
                que.push(v);
            }
        }
    }

    int ret = 0;
    for(int i=1; i<=N; i++) {
        ret = max(ret, d[i]);
    }    
    return ret;
}
int main() {
    cin >> N >> M;
    int a, b;
    for(int i=1; i<=M; i++) {
        cin >> a >> b;
        in[b]++;
        add(a, b, 1);
    }
    /*
    // TLE
    int ans = 0;
    for(int i=1; i<=N; i++) {
        if(in[i] == 0) {
            d[i] = 0;
            ans = max(ans, bfs(i));
        }
    }
    cout << ans << endl;
    */
    
    queue<int> que;
    for(int i=1; i<=N; i++) {
        if(in[i] == 0) {
            d[i] = 0;
            que.push(i);
        }
    }
    while(!que.empty()) {
        int u = que.front(); que.pop();
        for(int i = 0; i<G[u].size(); i++) {
            int v = G[u][i].to;
                if(d[v] < d[u]+1) {
                    d[v] = d[u] + 1;
                }
            --in[v];
            if(in[v]==0) {
                /*
                if(d[v] < d[u]+1) {
                    d[v] = d[u] + 1;
                }
                */
                que.push(v);
            }
        }
    }

    int ans = 0;
    for(int i=1; i<=N; i++) {
        ans = max(ans, d[i]);
    }    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8832
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long double n,d,c=0;
    cin>>n>>d;
    while(n--){
        long double x,y;
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d){
            c++;
        }
    }
    cout<<c;

    return 0;
}


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

using namespace std;

int main(){
   
   string a, b;
   int ans = 0;
   cin >> a >> b;
   
   for(int i = 0; i < a.size(); i++){
      if (a[i] != b[i]) ans++;
   }
   cout << ans;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n),b(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b.rbegin(),b.rend());
  for(ll i=0;i<n;i++) {
    if(a[i]!=b[0]) cout << b[0] << endl;
    else cout << b[1] << endl;
  }
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;

ll s = 0;

ll ans(vector<int> a){
	ll at =0;
	REP(i,SZ(a)){
		at += a[i];
		if (at * 2 >= s) {
			return at*2-s;
		}
	}
}

main(){
    IOS();
    int n; cin>>n;
    vector<int> a(n);
    REP(i,n){
    	cin>>a[i];
    	s += a[i];
    }
    ll re = ans(a);
    reverse(ALL(a));
    MN(re, ans(a));
    cout<<re<<endl;

} 


Measured memory_bytes: 3428
#include<bits/stdc++.h>
using namespace std;
#define int long
#define mod (1000000007)
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
main(){
  int n,s,x,r;
  cin>>n>>s;
  while(cin>>x,n--)r=gcd(r,abs(s-x));
  cout<<r;
}

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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

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

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
            
    ll n;
    cin >> n;
    vll x(n);
    vll y(n);
    FOR(i, n) cin >> x[i];
    FOR(i, n) cin >> y[i];
    FOR(i, n) x[i] -= y[i];
    ll s = 0;
    FOR(i, n) s += max(0LL, x[i]);
    cout << s << '\n';
}



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

double dp[310][310][310];

int main(){
fast;
int n;
cin>>n;
int cnt[4];
cnt[1]=cnt[2]=cnt[3]=0;

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

dp[0][0][0]=0;
double N = cnt[1]+cnt[2]+cnt[3];
for(int total=1;total<=N;total++) {
    for(int i=total;i>=0;i--) {
        for(int j=total-i;j>=0;j--) {
            int k = total - (i+j);
            dp[i][j][k]=0;
            double num=0;
            double den = i+j+k;
            if(den==0)
            continue;

            if(i>0) num += i*dp[i-1][j][k];
            if(j>0) num += j*dp[i+1][j-1][k];
            if(k>0) num += k*dp[i][j+1][k-1];
            num+=N;
            dp[i][j][k]=num/den;
        }
    }
}

cout<<setprecision(12)<<dp[cnt[1]][cnt[2]][cnt[3]]<<endl;
return 0;
}

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

object Main extends App {
  var l = readLine.split(",").map(_.toDouble);
  var x=l(0);var y=l(1);var e = 0D;var n = 0D;var angle = 90D
  while(x!=0 || y!=0) {
    e += x*Math.cos(Math.toRadians(angle))
    n += x*Math.sin(Math.toRadians(angle))
    angle = angle - y
    l = readLine.split(",").map(_.toDouble);
    x = l(0);y = l(1)
  }

  println(e.toInt)
  println(n.toInt)
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, X;
    cin >> N >> X;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];
    ll times = 1;
    ll now = 0;
    REP(i, N){
    	now += L[i];
    	if(now <= X) times++;
    }
    cout << times << endl;
    return 0;
}

Measured memory_bytes: 256
def f(x):
    res = 0
    while x > 0:
        res += x % 10
        x /= 10
    return res

def solve(n):
    return min([f(a) + f(n-a) for a in range(1,n)])

assert solve(15) == 6
assert solve(100000) == 10, solve(100000)
n = input()
print solve(n)

Measured memory_bytes: 6668
lr=list(map(int,input().split()))
if lr[1]-lr[0]>=2019:
    print(0)
else:
    l=lr[0]%2019
    r=lr[1]%2019
    if l>r:
        print(0)
    else:
        m=2018
        for i in range(l,r+1):
            for k in range(i+1,r+1):
                if (i*k)%2019<m:
                    m=(i*k)%2019
        print(m)
                    

Measured memory_bytes: 3064
N = int(input())
h = list(map(int,input().split()))

dp = [float('inf')]*N
dp[0]=0

dp[1] = dp[0]+abs(h[1]-h[0])
for i in range(2,N):
    if dp[i] > dp[i-1]+abs(h[i]-h[i-1]):
        dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    if dp[i] > dp[i-2] + abs(h[i]-h[i-2]):
        dp[i]=dp[i-2] + abs(h[i]-h[i-2])

print(dp[N-1])


Measured memory_bytes: 13928
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

//linear time algorithm
int main(){
    cpp();
    ll n, m, k;
    cin>>n>>m>>k;
    vector<ll> a(n);
    vector<ll> b(m);
    for(ll& ele: a) cin>>ele;
    for(ll& ele: b) cin>>ele;
    a.insert(a.begin(), 0ll);
    b.insert(b.begin(), 0ll);
    for(ll i=1; i<a.size(); i++){
        a[i]+=a[i-1];
    }
    for(ll i=1; i<b.size(); i++){
        b[i]+=b[i-1];
    }
    ll ans = 0;
    ll j = b.size()-1;
    for(ll i=0; i<a.size(); i++){
        while((j>0)&&(b[j]+a[i]>k)){
            j--;
        }
        if(a[i]+b[j]<=k){
            ans = max(ans, i+j);
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 8000
#include <iostream>
#include <string>
#include <set>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
    int an = 0;
    string s;
    cin >> s;
    if(s[0] == 'A') {
        int count = 0;
        for (int i = 2; i < s.length() - 1; i++)if(s[i] == 'C') count++;
        if(count == 1){
            count = 0;
            for(int i = 0; i < s.length(); i++){
                if(s[i] >= 'A' && s[i] <= 'Z') count++;
            }
            if(count == 2) an++;
        }
    }

    if(an == 1) cout << "AC" << endl;
    else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <string>

typedef  long long ll;

using namespace std;

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

    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'B'){
            if(!ans.empty()){//文字列が空でないなら
                ans.pop_back();
            }
        }else{
            ans += s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<ll> prime_table(int n) {
  vector<ll> prime(n + 1, 1);
  if (n >= 0) prime[0] = 1;
  if (n >= 1) prime[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (prime[i]!=1) continue;
    prime[i] *= 2;
    for (int j = i*2; j <= n; j += i) {
      int t=j,k=0;
      while(t%i==0){
        t/=i;
        k++;
      }
      prime[j] *= (k+1);
    }
  }
  return prime;
}

int main(){
  int n;
  cin>>n;
  auto p=prime_table(n);
  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=p[i]*i;
  }
  cout<<ans<<endl;
  return(0);
}

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

using namespace std;

double d[3333][3333];
int main() {
	int n;
	cin >> n;
	d[0][0] = 1;
	for (int i = 0; i < n; i++) {
		double p;
		cin >> p;
		d[i + 1][0] = (1 - p)*d[i][0];
		for (int j = 1; j < i + 2; j++)
			d[i + 1][j] = p * d[i][j - 1] + (1 - p)*d[i][j];
	}
	auto r = 0.;
	for (int i = n / 2 + 1; i < n + 1; i++)
		r += d[n][i];
	cout.precision(18);
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 78464
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def cc(x1, y1, x2, y2):
    xd = x2 - x1
    yd = y2 - y1
    xc = (x1 + x2) / 2
    yc = (y1 + y2) / 2
    k = pow(1.0 / (xd**2 + yd**2) - 0.25, 0.5)
    xd *= k
    yd *= k
    return [[xc - yd, yc + xd], [xc + yd, yc - xd]]

def main():
    rr = []
    eps1 = 1 + eps

    def f(n):
        a = sorted([LF() for _ in range(n)])
        r = 1
        for i in range(n):
            ax, ay = a[i]
            for j in range(i+1,n):
                bx, by = a[j]
                if bx - ax > 2:
                    break
                if pow(ax-bx, 2) + pow(ay-by, 2) > 4:
                    continue
                for x, y in cc(ax, ay, bx, by):
                    t = 0
                    for k in range(n):
                        if x - a[k][0] > 1:
                            continue
                        if a[k][0] - x > 1:
                            break
                        if pow(x-a[k][0], 2) + pow(y-a[k][1], 2) < eps1:
                            t += 1
                    if r < t:
                        r = t

        return r

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 9164
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem092c(n, a))
}

fun problem092c(n: Int, a: List<Int>): String {
    val array = IntArray(n + 1) { 0 }
    array[0] = Math.abs(a[0])
    for (i in 1 until n) {
        array[i] = Math.abs(a[i] - a[i - 1])
    }
    array[n] = Math.abs(0 - a[n - 1])

    val sum = array.sum()
    val ans = mutableListOf<Int>()
    for (i in 0 until n) {
        val 引いたやつ = sum - (array[i] + array[i + 1])
        val 代わり = Math.abs((if (i == 0) 0 else a[i - 1]) - (if (i == n - 1) 0 else a[i + 1]))
        ans.add(引いたやつ + 代わり)
    }
    return ans.joinToString("\n")
}

Measured memory_bytes: 55100
from itertools import combinations
while True:
    n, x = [int(i) for i in input().split()]
    if n == 0 and x == 0:
        break
    ans = 0
    for i, j in combinations(range(1, n+1), 2):
        k = x - i - j
        if j < k <= n and k not in (i, j):
            ans += 1
    print(ans)



Measured memory_bytes: 5640
S=str(input())
A=int(S[0]+S[1])
B=int(S[2]+S[3])

if 0<A<=12 and 0<B<=12:
  print('AMBIGUOUS');exit()
elif (A>12 or A==0) and 0<B<=12:
  print('YYMM');exit()
elif 0<A<=12 and (B>12 or B==0):
  print('MMYY');exit()
else:
  print('NA');exit()

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  // もし余りが0の時
  if (N % X == 0) {
  	cout << (N / X) * T << endl;
  }
  // 余りがあるとき
  else {
  	cout << (N / X + 1) * T << endl;
  }
}

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

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

  map<int, int> cnt;

  ll ans = 0;
  rep(i,n){
    ans += cnt[i - a[i]];
    cnt[a[i] + i]++;
  }

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

Measured memory_bytes: 21132
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
# import bisect

N = INT()
A = LIST()
B = LIST()
C = LIST()

A.sort()
B.sort()
C.sort()

def binsearch(lst, th, ud="up"):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if ud == "up":
            if lst[mid] > th:
                right = mid
            else:
                left = mid
        else:
            if lst[mid] >= th:
                right = mid
            else:
                left = mid
        
    return right if ud == "up" else left


ans = 0
# for ai in A:
#     i = bisect.bisect_right(B, ai)
#     for bi in B[i:]:
#         j = bisect.bisect_right(C, bi)
#         ans += len(C[j:])

for bi in B:
    i = binsearch(A, bi, "down")
    j = binsearch(C, bi, "up")
    ans += (i+1) * (N-j)


print(ans)

Measured memory_bytes: 24052
#include <iostream>
#include <queue>

typedef long long ll;
int N;

int main() {
  std::cin >> N;
  ll rem = (1LL << 60), asum = 0;
  bool all_same = true;

  for (int i = 0; i < N; ++i) {
    ll a, b; std::cin >> a >> b;
    asum += a;
    if (a != b) all_same = false;
    if (a > b)  rem = std::min(rem, b);
  }
  if (all_same) rem = asum;
  std::cout << asum - rem << "\n";

  return 0;
}


Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readInt()
    val a = readInt()
    val b = n % 500
    println(if (b <= a) "Yes" else "No")
}

fun readIntList(): List<Int> = readLine()!!.split(' ').map { it.toInt() }

fun readInt(): Int = readLine()!!.toInt()

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 31616
#include <stdio.h>
#define SIZE 105
#define MAX  200005
  int a[SIZE],dp[MAX];

  int main(void) {
        int n,k;
        scanf("%d %d",&n,&k);
        for(int i=0; i<n; i++) scanf("%d",&a[i]);

        for(int i=0; i<=k; i++) {
                if(dp[i]) continue;

                for(int j=0; j<n; j++) if(i+a[j] <= k) dp[i+a[j]] = 1;
        }

        if(dp[k] == 1) printf("First");
        else printf("Second");
        return 0;
  }






Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

typedef long long ll;

int po[353531];
int main(){
	int k,n;
	cin>>k>>n;
	int center = (k+1)/2;
	if(k%2==0){
		printf("%d",center);
		REP(i,n-1)printf(" %d",k);
		puts("");
		return 0;
	}
	int tail = n;
	REP(i,n)po[i] = center;
	int tm = n/2;
	while(tm--){
		po[tail-1]--;
		if(po[tail-1]==0){
			tail--;
		}else{
			while(tail < n){
				po[tail] = k;
				tail++;
			}
		}
	}
	REP(i,tail)printf("%d%c",po[i],i==tail-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 3456
import queue

q = queue.Queue()

h, w = map(int, input().split())
sx, sy = 0, 0
gx, gy = w - 1, h - 1
board = [[i for i in list(str(input()))] for i in range(h)]
hist = [[False] * w for i in range(h)]

q.put((sx, sy))
step = 0
count = 1
next_count = 1
ans = 0
while not q.empty():
    x, y = q.get()
    count -= 1
    if count == 0:
        step += 1
        count = next_count
        next_count = 0
    if x == gx and y == gy:
        ans = step
        break
    for (i, j) in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        if not(0 <= x+i <= w - 1) or not(0 <= y+j <= h - 1):
            continue
        if board[y+j][x+i] == "#":
            continue
        if hist[y+j][x+i]:
            continue
        hist[y+j][x+i] = True
        q.put((x+i, y+j))
        next_count += 1
count_black = 0
for y in range(h):
    for x in range(w):
        if board[y][x] == "#":
            count_black += 1

if ans == 0:
    print("-1")
else:
    print(h * w - ans - count_black)


Measured memory_bytes: 43368
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)

	for i := range a {
		a[i] = nextInt()
	}

	mod := int(1e9) + 7

	sum := a[0]
	ans := 0
	for i := 1; i < n; i++ {
		ans += (sum * a[i]) % mod
		ans %= mod
		sum += a[i]
		sum %= mod
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 5860
#include <iostream>

using namespace std;

class Dice{
public:
    int mFaces[6];
    void roll_n(){
        int tmp = mFaces[0];
        mFaces[0] = mFaces[1];
        mFaces[1] = mFaces[5];
        mFaces[5] = mFaces[4];
        mFaces[4] = tmp;
    }
    void roll_e(){
        int tmp = mFaces[0];
        mFaces[0] = mFaces[3];
        mFaces[3] = mFaces[5];
        mFaces[5] = mFaces[2];
        mFaces[2] = tmp;
    }
    void roll_s(){
        for(int i = 0; i < 3; ++i){
            roll_n();
        }
    }
    void roll_w(){
        for(int i = 0; i < 3; ++i){
            roll_e();
        }
    }
    void printTop(){
        cout << mFaces[0] << endl;
    }
};

int main()
{
    Dice dice;

    for(int i = 0; i < 6; ++i){
        cin >> dice.mFaces[i];
    }

    char ord;
    while(cin >> ord){
        switch(ord){
            case 'N':
                dice.roll_n();
                break;
            case 'E':
                dice.roll_e();
                break;
            case 'S':
                dice.roll_s();
                break;
            case 'W':
                dice.roll_w();
                break;
        }
    }

    dice.printTop();
}

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

#define MAX 10000000000

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k, aux;
    vector<int> h;
    vector<long long> min_cost;
    long long m;

    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> aux;
        h.push_back(aux);
    }

    min_cost.assign(n, 0);

    for(int i = 1; i < n; ++i){
        aux = 1;
        m = MAX;
        while(i - aux >= 0 && aux <= k){
            m = min(m, abs(h[i] - h[i - aux]) + min_cost[i - aux]);
            ++aux;
        }
        min_cost[i] = m;
    }

    cout << min_cost[n - 1] << '\n';

    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;

    for (int i = 0; i < 26; i++)
    {
        for (int j = 0; j < 15; j++)
        {
            if (4 * i + 7 * j == N)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256