akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int k = 0;

            for(int i = 1; i<20; i++)
            {
                if (n <= 1000 * i)
                {
                    k = 1000 * i - n;
                    break;
                }
            }
            Console.WriteLine(k);
        }    
    }
}


Measured memory_bytes: 27412
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}


double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

template<typename T>
T chmin(T& a, const T& b) {
	if (a > b)a = b;
	return a;
}

template<typename T>
T chmax(T& a, const T& b) {
	if (a < b)a = b;
	return a;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	string s;
	scans(s);
	int ans = 0, cnt = 0;
	rep(i, n)if (s[i] == 'R')++cnt;
	ans = min(cnt, n - cnt);
	int r = cnt, w = n - r, rcnt = 0, wcnt = 0;
	rep(i, n) {
		if (s[i] == 'R')++rcnt;
		else ++wcnt;
		ans = min(ans, r - rcnt + wcnt - min(wcnt, r - rcnt));
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 3936
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use std::str::FromStr;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}
impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }
    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }
            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }
    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }
    pub fn next_usize(&mut self) -> usize {
        self.next()
    }
    pub fn next_isize(&mut self) -> isize {
        self.next()
    }
    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
    pub fn next_string(&mut self) -> String {
        self.next()
    }
    pub fn next_char(&mut self) -> char {
        self.next()
    }
    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}
fn main() {
    let mut sc = Scanner::new();
    let l = sc.next_usize();
    let r = sc.next_usize();

    let mut min = U_INF;
    let mut max = 0;

    if r - l < 3000 {
        for i in l..=r {
            min = (min).min(i % 2019);
            max = (max).max(i % 2019);
        }
    } else {
        min = 0;
        max = 2018;
    }

    let mut ans = U_INF;
    for i in min..=max {
        for j in min..=max {
            if i != j {
                ans = (ans).min((i * j) % 2019);
            }
        }
    }

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


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N, M, Q;
vector<vector<ll>> items;

ll dfs(ll now, vector<ll> &tar) {
    ll res = 0;
    if (now == N) {
        ll tmp = 0;
        rep(i, Q) {
            auto x = items[i];
            if (tar[x[1]] - tar[x[0]] == x[2]) {
                tmp += x[3];
            }
        }
        return tmp;
    } else {
        rep2(i, 1, M + 1) {
            if (now != 0 && tar[now-1] > i) continue;
            tar[now] = i;
            res = max(res, dfs(now + 1, tar));
        }
    }
    return res;
}

void solve() {
    cin >> N >> M >> Q;
    items.resize(Q);
    rep(i, Q) {
        vector<ll> x(4);
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        b--;
        x[0] = a;
        x[1] = b;
        x[2] = c;
        x[3] = d;
        items[i] = x;
    }
    vector<ll> tar(N, 1);
    cout << dfs(0, tar) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3668
import sys

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

    sunuke = []
    for _ in range(K):
        _ = input()
        next_sunuke = list(map(int, input().split()))
        for i in next_sunuke:
            sunuke.append(i)
    sunuke = set(sunuke)

    print(N - len(sunuke))

    return

if __name__ == '__main__':
    main()
    sys.exit(0)

Measured memory_bytes: 68316
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;



int main(){
  int n;
  cin >> n;
  int x[100],y[100],h[100];
  rep(i,n)cin >> x[i] >> y[i] >> h[i];
  int cx,cy,H;

  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      int now;
      int last;
        for(int g=0;g<n;g++){
        if(h[g]!=0){
          now = abs(x[g]-i)+abs(y[g]-j) + h[g];
          last=g;
          break;
        }
      }
      bool ok = true;
      for(int k=last+1;k<n;k++){
        if(h[k] != max(now-abs(x[k]-i)-abs(y[k]-j),0)){
          ok = false;
          break;
        }
      }
      if(ok){
        cx=i;
        cy=j;
      }
    }
  }

  for(int i=0;i<n;i++){
    if(h[i]!=0){
      H = abs(x[i]-cx)+abs(y[i]-cy) + h[i];
      break;
    }
  }
  cout << cx << " " << cy << " " << H << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n, m, sum, ans;
  int t[100], p[100], x[100];
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d", &t[i]);
  }
  scanf("%d", &m);
  for(int i=0; i<m; i++){
    scanf("%d", &p[i]);
    scanf("%d", &x[i]);
  }

  sum = 0;
  for(int i=0; i<n; i++){
    sum += t[i];
  }

  for(int i=0; i<m; i++){
    printf("%d\n", sum-t[p[i]-1]+x[i]);
  }

  return 0;
}


Measured memory_bytes: 1700
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int x,n;
	cin>>x>>n;
	int a[n];
	int cnt[105]={0};
	forci(0,n)	cin>>a[i], cnt[a[i]]++;
	int i=x;
	while(cnt[i])
		i++;
	int j=x;
	while(cnt[j])
		j--;
	if(abs(x-i)<abs(x-j))
		cout<<i<<endl;
	else
		cout<<j<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 3648
n,m=map(int,input().split())
town=[]
for i in range(n):
    weather=input()
    c=-1
    t_c=[]
    for j in range(m):
        if weather[j]=="c":c=0
        t_c.append(c)
        if c>-1:c+=1
    town.append(t_c)
for i in town:print(' '.join(map(str,i)))


Measured memory_bytes: 5676
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
from time import time
from random import randint
from copy import deepcopy

start_time = time()

def calcScore(t, s, c):
    scores = [0]*26
    lasts = [0]*26
    for i in range(1, len(t)):
        scores[t[i]] += s[i][t[i]]
        dif = i - lasts[t[i]]
        scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
        lasts[t[i]] = i
    for i in range(26):
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores

def update(socre, day, t, q):
    p = t[day]
    t[day] = q
    scores[p] = 0
    scores[q] = 0
    lasts = [0]*26
    for i in range(1, len(t)):
        if t[i] == p or t[i] == q:
            scores[t[i]] += s[i][t[i]]
            dif = i - lasts[t[i]]
            scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
            lasts[t[i]] = i
    for i in [p, q]:
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2

def greedy(c, s):
    day_lim = len(s)
    socres = [0]*26
    t = [0]*day_lim
    lasts = [0]*26
    for i in range(1, day_lim):
        pls = [v for v in socres]
        mns = [v for v in socres]
        for j in range(26):
            pls[j] += s[i][j]
            mns[j] -= c[j] * (i - lasts[j])
        sum_mns = sum(mns)
        pt = sum_mns - mns[0] + pls[0]
        idx = 0
        for j in range(1, 26):
            tmp = sum_mns - mns[j] + pls[j]
            if pt < tmp:
                pt = tmp
                idx = j
        t[i] = idx
        lasts[idx] = i
        for j in range(26):
            if j == idx:
                socres[j] = pls[j]
            else:
                socres[j] = mns[j]
    return socres, t

D = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(D+1)]
for i in range(1, D+1):
    s[i] = list(map(int, input().split()))

scores, t = greedy(c, s)
sum_score = sum(scores)

while time() - start_time < 1.5:
    day = randint(1, D)
    q = randint(0, 25)
    if q == t[day]:
        continue
    tmp_scores = deepcopy(scores)
    tmp_t = deepcopy(t)
    update(tmp_scores, day, tmp_t, q)
    sum_tmp_score = sum(tmp_scores)
    if sum_score < sum_tmp_score:
        sum_score = sum_tmp_score
        t = tmp_t

for v in t[1:]:
    print(v+1)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a,b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
	
		String S;
		S=sc.next();
		int leng =S.length();
		//boolean x=false;
		Pattern p= Pattern.compile("^A[a-z][a-z]*C[a-z]*[a-z]$");
		Matcher m = p.matcher(S);
		boolean b = m.matches();
		
		if(b){
			System.out.println("AC");
		}else{
			System.out.println("WA");
		}
	
	
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<ll, ll> mpii;
typedef unordered_map<ll, ll> umpii;

#define pb(v) push_back(v)
#define all(v) v.begin(), v.end()
#define upb(v, key) (upper_bound(all(v), key) - v.begin())
#define lob(v, key) (lower_bound(all(v), key) - v.begin())

ll inf = 1e9;
ll INF = inf * 1ll * inf;
ll mod = 1e9 + 7;
double eps = 1e-9;
const ld pi = ld(3.1415926535897932384626433832795);
ll dr[] = {-1, 0, 0, 1};
ll dc[] = {0, 1, -1, 0};

template <class TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a)
{
  while (*sdbg != ',')
    cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
  os << "[";
  for (auto vv : V)
    os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
  return os << "(" << P.st << "," << P.nd << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

/*...................................................*/

main()
{
  int n, i, j, ans;
  cin >> n;
  vvi a(n, vi(3));
  for(i = 0; i < n; i++)
  for(j = 0; j < 3; j++)
  cin >> a[i][j];

  vvi dp(n, vi(3));
  for(i = 0; i < 3; i++)
  dp[0][i] = a[0][i];
  for(i = 1; i < n; i++)
  for(j = 0; j < 3; j++)
  for(int k = 0; k < 3; k++)
  if(j != k)
  dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);

  cout << *max_element(all(dp[n - 1]));
}

Measured memory_bytes: 11136
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    b = [0] * (10**5 +1)
    for i in range(N):
        b[d[i]] += 1
    t = 0
    f = False
    ans = 0
    for i in range(1, 10 ** 5 + 1):
        if not f:
            t += b[i]
            if t == N / 2:
                f = True
            elif t > N / 2:
                ans = 0
                break
        else:
            ans += 1
            if b[i] != 0:
                break
    print(ans)



    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 81132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<fstream>
#define rep(i,start,n) for(int i=start;i<n;i++)                 //??????????????????

using namespace std;

int main(){

int check=0;                                                    //????????¨????????°
string sentence_s,sentence_p,sentence_total;                    //???????????????????????§??????

cin >> sentence_s >>sentence_p;                                 //???????????§?????????????????????

sentence_total = sentence_s + sentence_s;                       //??????????????£??????????¨????????????????????????????

rep(i , 0 , sentence_s.size()){                                  // ???????????????
  if(sentence_p == sentence_total.substr(i , sentence_p.size())){
    /*
    ??????URL???http://kaworu.jpn.org/cpp/std::string::substr
    ?????????total????????????p?????????????????????????????????????????????total???????????????p????????????????????????p???
    ?????????????????§????????????????????????
    */
    check = 1;
    break;
  }
}

//std::cout << sentence_total << std::endl;

if(check == 1){
  cout << "Yes" << endl;                  //??¨???
}
else if(check == 0){
  cout << "No" << endl;                   //??¨???
}

return 0;

}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(ll i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N, K;
    cin >> N >> K;
    ll A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N);
    //解は[l,r]に存在
    ll l = -1e18, r = 1e18;
    while(l < r){
        ll n = (l+r)/2;
      	if(l+r < 0 && 2*n != l+r) n--;
        //n以下になるものが何個あるか判定
        ll sum = 0;
        rep(i, N){
            if(A[i] < 0){
                ll x = n/A[i];
                rep2(j, x-1, x+1){
                    if(A[i]*j <= n){
                        sum += A+N - lower_bound(A, A+N, j);
                        break;
                    }
                }
            }
            elif(A[i] == 0){
                if(n >= 0) sum += N;
            }
            else{
                ll x = n/A[i];
                rep3(j, x+1, x-1){
                    if(A[i]*j <= n){
                        sum += upper_bound(A, A+N, j)- A;
                        break;
                    }
                }
            }
            if(A[i]*A[i] <= n) sum--;
        }
        sum /= 2;
        if(sum < K) l = n+1;
        else r = n;
    }
    cout << l << endl;
}

//tokusakurai


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
int N, X, Y;
int head[200001], next[399999], to[399999], lon[399999], E;
int dep[200001], dep2[200001], fa[200001];
int au[200000], av[200000], al[200000];
int q[200001];
int main()
{
	scanf("%d%d%d", &N, &X, &Y);
	for (int i = 1; i < N; i++)
		scanf("%d%d", au + i, av + i);
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		next[++E] = head[u], to[E] = v, head[u] = E;
		next[++E] = head[v], to[E] = u, head[v] = E;
	}
	int H = 0, T = 1, u;
	q[1] = Y;
	while (H < T)
		for (int e = head[u = q[++H]]; e; e = next[e])
			if (to[e] != fa[u])
			{
				fa[q[++T] = to[e]] = u;
				dep[to[e]] = dep[u] + 1;
			}
	for (int i = 1; i < N; i++)
		al[i] = !(fa[au[i]] == av[i] || fa[av[i]] == au[i] || fa[fa[au[i]]] == av[i] || fa[fa[av[i]]] == au[i] || fa[au[i]] == fa[av[i]]);
	for (int i = 1; i <= N; i++)
		head[i] = 0;
	E = 0;
	for (int i = 1; i < N; i++)
	{
		next[++E] = head[au[i]], to[E] = av[i], lon[E] = al[i], head[au[i]] = E;
		next[++E] = head[av[i]], to[E] = au[i], lon[E] = al[i], head[av[i]] = E;
	}
	H = 0, T = 1;
	q[1] = X;
	fa[X] = 0;
	for (int i = 1; i <= N; i++)
		dep2[i] = 1000000000;
	dep2[X] = 0;
	while (H < T)
		for (int e = head[u = q[++H]]; e; e = next[e])
			if (to[e] != fa[u] && dep2[u] + 1 < dep[to[e]])
			{
				fa[q[++T] = to[e]] = u;
				dep2[to[e]] = dep2[u] + 1;
			}
	int O = 0;
	for (int i = 1; i <= N; i++)
		if (dep2[i] < dep[i])
		{
			int Inf = 0;
			for (int e = head[i]; e; e = next[e])
				if (lon[e])
					Inf = 1;
			if (Inf)
			{
				puts("-1");
				return 0;
			}
			O = std::max(O, dep[i]);
		}
	printf("%d\n", O << 1);
	return 0;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string ans;
    ffor(i,0,sz(s))
    {
        ans.pb(s[i]);
        ans.pb(t[i]);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
 
using namespace std;
 
int main(){
    int n;
    cin>>n;

    vector<int> even(n/2), odd(n/2);
    int i_even = 0, i_odd = 0;
    for(int i = 0; i < n; i++) {
        if(i%2 == 0) cin>>even[i_even++];
        else cin>>odd[i_odd++];
    }

    sort(even.begin(), even.end());
    sort(odd.begin(), odd.end());

    vector<pair<int, int> > even_count(n/2 + 1), odd_count(n/2 + 1);

    i_even = 0;
    i_odd = 0;
    int same_even_count = 0, same_odd_count = 0;
    for(int i = 1; i < n/2; i++){
        if(even[i] == even[i-1]) same_even_count++;
        if(even[i] != even[i-1] || i == n/2 - 1){
            even_count[i_even++] = make_pair(same_even_count + 1, even[i-1]);
            same_even_count = 0;
        }

        if(odd[i] == odd[i-1]) same_odd_count++;
        if(odd[i] != odd[i-1] || i == n/2 - 1){
            odd_count[i_odd++] = make_pair(same_odd_count + 1, odd[i-1]);
            same_odd_count = 0;
        }
    }

    sort(even_count.begin(), even_count.end(), greater<pair<int, int> >());
    sort(odd_count.begin(), odd_count.end(), greater<pair<int, int> >());
    int count = 0;
    if(even_count[0].second == odd_count[0].second) count = max(even_count[1].first + odd_count[0].first, even_count[0].first + odd_count[1].first);
    else count = even_count[0].first + odd_count[0].first;

    cout<<n-count<<endl;

  return 0;
}

Measured memory_bytes: 1408
import collections
n, k = map(int, input().split())
*a, = map(int, input().split())

c = collections.Counter(a)
c = sorted(c.items(), key=lambda x: x[1])

ans = 0
if len(c) - k > 0:
    for i in range(len(c)-k):
        ans += c[i][1]

print(ans)


Measured memory_bytes: 39344
import collections
n = int(input())
b = []
a = input().split()
a = list(collections.Counter(a).items())
for i in a:
  if i[1] >= 4:
    b.append(i[0])
    b.append(i[0])
  elif i[1] >= 2:
    b.append(i[0])
b = list(map(int,b))
b.sort(reverse = True)
if len(b) >= 2:
  print(int(b[0])*int(b[1]))
else:
  print(0)


Measured memory_bytes: 24612
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vs s(n);
    vvi a(n);
    int cri = 0;
    rep(i,n){
        cin >> s[i];
        a[i] = vi(len(s[i]));
        rep(j,len(s[i])){
            if(s[i][j] == '('){
                a[i][j] = 1;
            }else{
                a[i][j] = -1;
            }
        }
        // svec(a[i]);
        cri += accumulate(all(a[i]),0);
    }
    if(cri != 0){
        cout << "No\n";
        return 0;
    }
    vp pl,mn;
    rep(i,n){
        vi sm(len(s[i])+1,0);
        rep(j,len(s[i])){
            sm[j+1] = sm[j] + a[i][j];
        }
        if(sm[len(s[i])] > 0){
            pl.pb(P(*min_element(all(sm)),sm[len(s[i])]));
        }else{
            mn.pb(P(sm[len(s[i])],*min_element(all(sm))));
        }
    }
    int aa = len(pl),bb = len(mn);
    sort(all(pl),greater<P>());
    int nw = 0;
    // rep(i,aa){
    //     spair(pl[i]);
    // }
    // rep(i,bb){
    //     spair(mn[i]);
    // }
    rep(i,aa){
        if(nw + pl[i].fi < 0){
            cout << "No\n";
            return 0;
        }
        nw += pl[i].se;
    }
    vp vec(bb);
    rep(i,bb){
        vec[i] = P(mn[i].fi-mn[i].se,i);
    }
    sort(all(vec),greater<P>());
    rep(i,bb){
        if(nw + mn[vec[i].se].se < 0){
            cout << "No\n";
            return 0;
        }
        nw += mn[vec[i].se].fi;
    }
    cout << "Yes\n";
    return 0;
}



Measured memory_bytes: 3304
import java.util.Scanner;
 
public class Main {
    static long gcd(long ai, long aj) {
        if (aj == 0)
            return ai;
        else
            return gcd(aj, ai % aj);
    }
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        long A = sc.nextLong();
        long B = sc.nextLong();
        long gcd = gcd(A, B);
        int count = 1;
 
        for (int i = 2; i <= Math.sqrt(gcd); i++) {
            if (gcd % i == 0) {
                count++;
            }
            while (gcd % i == 0) {
                gcd /= i;
            }
        }
 
        if(gcd >1)
            count++;
 
        System.out.println(count);
 
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n-1] - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 100010
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
int n, a[maxn];
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	bool ok = 1;
	int max0 = -1;
	n = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	if (n == 1) {
		printf("Yes\n");
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		max0 = max(max0, a[i]);
		if ((max0 - a[i]) >= 2) ok = 0;
	}
	if (ok == 0) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		double b = sc.nextDouble();
		BigDecimal a1 = new BigDecimal(a);
		BigDecimal ans = a1.multiply(BigDecimal.valueOf(b));
		System.out.println(ans.longValue());
	 }
}

Measured memory_bytes: 37220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X[2];
    ll ans = 0;
    for(ll i = 0; i <= 1; i++) {
        cin >> X[i];
        for(ll j = 1; j <= 3; j++) {
            if(X[i] <= j) ans += 1e5;
        }
    }
    if(X[0] == 1 && X[1] == 1) ans += 4e5;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
const int M=1e9+7;
const int N=1e5+5;
ll n,a[N],x=1,b[N],res=0;

ll quick_pow(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
        {
            res=(res%M*a%M)%M;
        }
        a=(a%M*a%M)%M;
        b>>=1;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        x=(x%M*i%M)%M;
        b[i]=quick_pow(i,M-2);
        cin >> a[i];
    }
    for(int i=1;i<=n;i++)
        b[i]=(b[i]%M+b[i-1]%M)%M;
    for(int i=1;i<=n;i++)
        res=(res%M+a[i]*(b[i]+b[n-i+1]-1)%M)%M;
    cout << (res%M*x%M)%M << endl;
    return 0;
}


Measured memory_bytes: 5212
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std; 
int main()
{
    int a[100+10];
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    	scanf("%d",&a[i]);
	sort(a,a+N);
	int sum=0;
	for(int i=1;i<N;i++)
		sum+=a[i]-a[i-1];
	printf("%d\n",sum);
	
    return 0;
 }

Measured memory_bytes: 128
n,m=map(int,input().split())
a=list(map(lambda x: -int(x),input().split()))
import heapq
heapq.heapify(a)
for i in range(m):
    i=-heapq.heappop(a)
    i//=2
    heapq.heappush(a,-i)
print(-sum(a))

Measured memory_bytes: 72216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

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

    int a;
    bool f = true;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a % 2 == 0)
        {
            if (a % 3 != 0 && a % 5 != 0)
            {
                f = false;
                break;
            }
        }
    }

    if (f)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

int main() {
    // source
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }

    ll sum[n];
    ll sum_temp = 0;
    rep(i, n) {
        sum_temp += a[i];
        sum[i] = sum_temp;
    }

    ll min_diff = sum_temp;
    rep(i, n) { min_diff = min(min_diff, abs((sum_temp - sum[i]) - sum[i])); }

    cout << min_diff << endl;
    return 0;
}



Measured memory_bytes: 3328
N, C, K = [int(_) for _ in input().split()]
T = [int(input()) for i in range(N)]

T.sort()

result = 0
i = 0
j = 0
while i < N:
    if j == N or T[j] - T[i] > K:
        n = max(min(C, j - i), 1)
        if n == 0: raise
        # print(T[i:i+n], i, j)
        i += n
        result += 1
        continue
    if j >= i + C:
        # print(T[i:i+C])
        i += C
        result += 1
        continue
    j += 1

print(result)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

ll n, m;
vector<ll> to[100000];
vector<ll> to_n;
bool dfs(ll v, ll p = -1){
  if(v == n-1){
    to_n.emplace_back(v);
    return true;
  }

  for(ll u : to[v]){
    if(u == p) continue;
    if(dfs(u, v)){
      to_n.emplace_back(v);
      return true;
    }
  }
  return false;
}

ll count(ll v, ll t, ll p = -1){
  if(v == t) return 0;
  ll num = 1;
  for(ll u : to[v]){
    if(u == p) continue;
    num += count(u, t, v);
  }
  return num;
}

int main(void){
  cin >> n;
  REP(i, n-1){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }
  dfs(0);
  reverse(ALL(to_n));
  m = to_n.size();
  ll t = (m-1)/2;
  ll a = count(0, to_n[t+1]);
  ll b = count(n-1, to_n[t]);
  if(a > b) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}

Measured memory_bytes: 11512
integer K
integer mae,ushiro
read*,K
mae=K/100
ushiro=mod(K,100)
if(check(mae).and.check(ushiro))then
  print"(A)","AMBIGUOUS"
else if(check(mae))then
  print"(A)","MMYY"
else if(check(ushiro))then
  print"(A)","YYMM"
else
  print"(A)","NA"
end if

contains
function check(x)
integer x
logical check
check=.true.
if(x==0.or. x>12)check=.false.
end function
end

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
s = ""
for i in range(N):
    if i == K - 1:
        if S[i] == "A":
            s += "a"

        elif S[i] == "B":
            s += "b"

        else:
            s += "c"

    else:
        s += S[i]

print(s)

Measured memory_bytes: 2940
s = list(map(int, input().split()))
n = s[0]
m = s[1]

h = list(map(int, input().split()))

a = []
for i in range(m):
    road = list(map(int, input().split()))
    a.append(road)

good = []
for i in range(n):
    good.append(0)

for i in range(m):
    if h[a[i][0] - 1] > h[a[i][1] - 1]:
        good[a[i][1] - 1] = 1
        if good[a[i][0] - 1] != 1:
            good[a[i][0] - 1] = 2
    elif h[a[i][0] - 1] < h[a[i][1] - 1]:
        good[a[i][0] - 1] = 1
        if good[a[i][1] - 1] != 1:
            good[a[i][1] - 1] = 2
    else:
        good[a[i][1] - 1] = 1
        good[a[i][0] - 1] = 1

count = 0
for i in range(n):
    if good[i] == 0 or good[i] == 2:
        count = count + 1

print(count)


Measured memory_bytes: 31952
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}


int a[111111];
int n;
int main()
{
#ifdef JCVB
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	int _time_jc=clock();
#endif
	gn(n);
	rep(i,1,n+1)gn(a[i]);
	int su=0;
	rep(i,1,n+1)if(i<a[i] && a[a[i]]==i)su++;
	cout<<su<<endl;


#ifdef JCVB
	debug("time: %d\n",int(clock()-_time_jc));
#endif
	return 0;
}




Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const int MAX=100001;
const double EPS=1e-10;
int main() {
    ll n;
    cin>>n;
    ll p[20010];
    for(int i=1;i<=n;i++){
        int c;
        cin>>c;
        p[c]=i;
    }
    ll a[20010],b[20010];
    for(int i=1;i<=n;i++){
        a[i]=i*20010;
        b[i]=(n-i)*20010+p[i];
    }
    for(int i=1;i<=n;i++){
        cout<<a[i];
        if(i!=n){
            cout<<" ";
        }
    }
    cout<<endl;;
    for(int i=1;i<=n;i++){
        cout<<b[i];
        if(i!=n){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




int N;

int main () {
  cin >> N;

  map<ll, int> ret;

  for (int n=2;n<=N;++n) {
    int tmp = n;

    for(ll i = 2; i * i <= tmp; i++) {
      while(tmp % i == 0) {
        ret[i]++;
        tmp /= i;
      }
    }
    if(tmp != 1) ret[tmp]++;
  }

  ll ans = 1;

  for (int k=2;k<=1000;++k) {
    //cout << k << " " << ret[k] << "\n";
    if (ret[k] > 0) {
      ans *= (ret[k]+1);
      ans %= MOD;
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 3636
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        int n = s.length();
        int m = t.length();
        int min = 1001;
        for(int i = 0; i < n - m + 1; i++){
            int out = 0;
            if(s.substring(i, i + m).equals(t)){
                System.out.println(0);
                return;
            }
            for(int j = i; j < i + m; j++){
                if(s.charAt(j) != t.charAt(j - i)) out++;
            }
            min = Math.min(out, min);
        }
        System.out.println(min);
    }

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


Measured memory_bytes: 36704
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;
int main(){ 
	int A,B,C;
	cin>>A>>B>>C;
	if(C<=A+B){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
open Batteries
let n = read_int ()

let a = int_of_char 'a'


let get_char i = if i = 0 then 'z' else char_of_int @@ a - 1 + i

let rec loop now result_lst =
  if now <= 26 then (get_char now) :: result_lst else (
    let i = if get_char (now mod 26) = 'z' then (now / 26)-1 else now/26 in loop i (get_char (now mod 26) :: result_lst)
  )

(* charのlistをstringに *)
let string_of_chars chars = 
  let buf = Buffer.create 16 in
  List.iter (Buffer.add_char buf) chars;
  Buffer.contents buf
let _ = print_endline @@ string_of_chars @@ loop n []

Measured memory_bytes: 5260
#include <stdio.h>

int main(){

    long int a,b,i;
    int k;

    scanf("%ld %ld %d",&a,&b,&k);

    if(b-a>k){
        for(i=0;i<k;i++){
            if(b-k+1>a+i)printf("%ld\n",a+i);
        }   
        for(i=k-1;i>=0;i--){
            if(a+k-1<=b-i)printf("%ld\n",b-i);
        }
    }else{
        for(i=a;i<=b;i++){
            printf("%ld\n",i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n,m,c;
	
	scanf("%d %d %d",&n,&m,&c);
	
	int b[m];
	int a[n][m];
	
	int i,j;
	
	for(i = 0; i < m; i++){
		scanf("%d",&b[i]);
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	
	int count = 0;
	
	for(i = 0; i < n; i++){
		int suuti = c;
		for(j = 0; j < m; j++){
			suuti = suuti + a[i][j] * b[j];
			
			if(j == m - 1 && suuti > 0){
				count = count + 1;
				}
		}
	}
	
	printf("%d",count);
	
	return 0;
}
		
	
	
	

Measured memory_bytes: 128
def xy(a):
    if a % 4 == 1:
        return 1
    elif a % 4 == 2:
        return a + 1
    elif a % 4 == 3 or a == 0:
        return 0
    else:
        return a

a, b = map(int, input().split())
ans = xy(b) ^ xy(a - 1)
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    if(x<100)
    {
        if(x<10)
            cout<<x<<endl;
        else
            cout<<'9'<<endl;
    }
    else if(x>=100 && x<10000)
    {
        if(x<1000)
            cout<<9+(x-100)+1<<endl;
        else
            cout<<"909"<<endl;
    }
    else if(x>=10000 && x<1000000)
    {
        if(x<100000)
            cout<<909+(x-10000)+1<<endl;
        else
            cout<<"90909"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int N;
	cin >> N;
	vector<int> T(N + 1);
	for (int i = 1; i <= N; i++)
	{
		cin >> T[i];
	}

	int M;
	cin >> M;
	vector<int> P(M + 1);
	vector<int> X(M + 1);

	for (int i = 1; i <= M; i++)
	{
		cin >> P[i] >> X[i];
	}

	int sum = 0;
	for (int i = 1; i <= N; i++)
	{
		sum += T[i];
	}

	for (int i = 1; i <= M; i++)
	{
		cout << sum - T[P[i]] + X[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256