akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
using namespace std;

void show( int arr[], unsigned int size )
{
	cout<<arr[0]<<flush;
	for( unsigned int i=1; i<size; i++ ){
		cout<<' '<<arr[i]<<flush;
	}
	cout<<endl;
}
long long merge( int arr[], unsigned int arr_s, unsigned int lft, unsigned int md, unsigned int rgt )
{
//??????????????????????????????lft??\???md?????????md??\???rgt???????????????
	long long cntInv=0;

//?????????????????????????????????( ???????????????????????????????????????????????????????????? )
	int left_s=md-lft+1, right_s=rgt-md+1, *left=new int[left_s], *right=new int[right_s];
	for( int i=0; i<left_s-1; i++ ){
		left[i]=arr[lft+i];
	}
	left[left_s-1]=INT_MAX;
	for( int i=0; i<right_s-1; i++ ){
		right[i]=arr[md+i];
	}
	right[right_s-1]=INT_MAX; //???????????????????????±???????????¨???????????????????????????


//??????????????????????????????????????±???,??????
	for( int i=0, left_i=0, right_i=0; i<left_s+right_s-2; i++ ){
		if( left[left_i] <= right[right_i] ){ //?????????????????\?????´?????????????????????????????????????????????????°?????????????????????????
			arr[lft+i]=left[left_i];
			++left_i;
		}else{
			arr[lft+i]=right[right_i];
			++right_i;

			if( left[left_i] != INT_MAX ){
				cntInv+= left_s - left_i -1;
			}
		}
	}

	delete[] right;delete[] left;
	return cntInv;

	/*
	3 5 2 1 4
	3 - 2, 1
	5 - 2, 1, 4
	2 - 1
	1 - ???
	4 - ???
	*/

}

long long mergeSort( int arr[], unsigned int arr_s, unsigned int lft, unsigned int rgt ) 
{
	static long long cntInv=0;
	unsigned int md=(lft + rgt)/2;
	if( rgt - lft >=2 ){ //???????????¶???????????????????????\??????????????¨???! ??? lft????????????????´????????¬???????????????????  ?????????????????????????????????????????????merge????????°??????????????????!

//??????????????????mergeSort???????????¨???????????¨?????????????????????????????????
		mergeSort(arr, arr_s, lft, md);  
		mergeSort(arr, arr_s, md, rgt);
//??????(????????????)! ?????§?????????????????????????????????????????°?????????????????????????????????????????????????????§????????????
		cntInv+= merge(arr, arr_s, lft, md, rgt); 
	
	}
	return cntInv;
}

int main()
{
	int arr_s;
	cin>>arr_s;
	int *arr=new int[arr_s];
	for( int i=0; i<arr_s; i++ ){
		cin>>arr[i];
	}

	long long cntInv=mergeSort(arr, arr_s, 0, arr_s);
//	show(arr, arr_s);
	cout<<cntInv<<endl;

	delete[] arr;
}

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
string s[110];
bool cmp(string a,string b){
   return a<b;
}
int main(){
   int n,l;
   scanf("%d%d",&n,&l);
   for (int i=0;i<n;i++) cin >> s[i];
   sort(s,s+n,cmp);
   for (int i=0;i<n;i++) cout << s[i] ;
   cout << endl;
}


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

int main() {
	int a;
	while (cin >> a, a) {
		map<int, int>U;
		for (int b = 0; b < a; b++) {
			int c; scanf("%d", &c);
			U[c]++;
		}
		for (auto b = U.begin(); b != U.end(); b++) {
			if (b->second * 2 > a) { cout << b->first << endl; goto l; }
		}
		puts("NO COLOR");
	l:;
	}
}

Measured memory_bytes: 4668
// https://atcoder.jp/contests/abc081/tasks/abc081_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

bool divide(vector<int> &v)
{
  for (auto itr = v.begin(); itr != v.end(); ++itr)
  {
    if (*itr % 2 == 0)
      *itr = *itr >> 1;
    else
      return false;
  }
  return true;
}

int main()
{
  int n, cnt = 0;

  cin >> n;
  vector<int> a;

  REP(i, n)
  {
    int ai;
    cin >> ai;
    a.push_back(ai);
  }

  while (divide(a))
    cnt++;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    string s;
    cin>>s;
    ll ans=0;
    ll cnt=0;
    int n=s.size();
    rep(i,s.size()){
        if(s[i]=='0')continue;
        ans+= powmod(2,cnt)*powmod(3,n-i-1)%mod;
        ++cnt;
    }
    ans+= powmod(2,cnt);
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define PI 3.141592653589

int main(){
	float a,b,d;
	char c;
	
	while(1){
	scanf("%f", &a);
	fflush(stdin);
	scanf(" %c", &c);
	scanf("%f", &b);
	
	switch(c){
		case '+':
			printf("%.0f\n", a+b);
			break;
		case '-':
			printf("%.0f\n", a-b);
			break;
		case '*':
			printf("%.0f\n", a*b);
			break;
		case '/':
			printf("%d\n", (int)(a/b));
			break;
		case '?':
			return 0;
			break;
	}
}
	return 0;
}

Measured memory_bytes: 1072
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int x = nextInt();

    int ans = 0;

  if(x==2){
    ans = 2;
  }
  else{
    while(true){
      int flag = 0;
      for(int i=2;i<x;i++){
        if(x%i==0){
          flag = 1;
          break;
        }
      }
      if(flag==0){
        break;
      }
      x++;
    }
  }

  System.out.println(x);


  }

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

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;

  bool tf = false;

  for (int i = 0; i <= b; i++) {
    if (i*a%b == c) tf = true;
  }
  if (tf) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[22][1<<21]={};//dp[i][j]:男性i人目まで読んだときに婚約済の男性の集合がjであるときの場合の数
vint bitcountset[22];//bitcountset[j]:2進数表記でN桁で1の数がj個である数の集合
int main(){
	ll MOD=1e+9+7;
	int N;
	scan(N);
	ll kumi=(1<<N);
	int a[22][22];
	dp[0][0]=1;
	rep(bit,kumi){
		int now=bit;
		int bitcount=0;
		rep(i,N){
			bitcount+=(now&1);
			now>>=1;
		}
		bitcountset[bitcount].push_back(bit);
	}
	rep(i,N){
		rep(j,N){
			scan(a[i][j]);
			if(a[i][j]==1){
				rep(k,bitcountset[i].size()){
					if(((bitcountset[i][k]>>j)&1)==0){
						dp[i+1][bitcountset[i][k]|(1<<j)]+=dp[i][bitcountset[i][k]];
						dp[i+1][bitcountset[i][k]|(1<<j)]%=MOD;
					}
				}
			}
		}
	}
	prin(dp[N][kumi-1]);
	return 0;
}


Measured memory_bytes: 318908
from collections import deque
import numpy as np

h,w=list(map(int,input().split()))
graph=[input() for _ in range(h)]#graph初期化

def f(x,y):#start地点(x,y)
  x-=1;y-=1
  dist=[[-1 for j in range(w)] for i in range(h)]#distance設定
  dist[x][y]=0#スタート地点は初期値0
  que = deque([(x,y,0)])#スタート地点とdist初期値を入力 

  while que:#queの中身がある限り
    r,s,t = que.popleft()
    for i,j in [(-1,0),(0,-1),(1,0),(0,1)]:#これでi,jとれるの
      if not (0<=r+i<h and 0<=s+j<w):#座標がh,w内でなければ探索しない
        continue
      if dist[r+i][s+j]>=0:#すでに訪れていたら探索しない。>=
        continue
      if graph[r+i][s+j]=="#":#壁なら探索しない
        continue
      dist[r+i][s+j]=t+1#距離を前回の＋1
      que.append([r+i,s+j,t+1])#訪れてないのでqueに今の地点を追加する
  return np.amax(dist)#2次元配列の最大値を返す
ans=0
for i in range(1,h+1):#全探索（indexのため1~h+1まで）
  for j in range(1,w+1):
    if graph[i-1][j-1]=="#":#壁なら探索しない
      continue
    ans=max(ans,f(i,j))
print(ans)

Measured memory_bytes: 12456
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long q = in.nextLong(), h = in.nextLong(), s = in.nextLong(), d = in.nextLong(), n = in.nextLong();
        long one = Math.min(Math.min(q * 4, h * 2), s);
        long a = n * one;
        long b = n / 2 * d + (n % 2 == 0 ? 0 : one);
        System.out.println(Math.min(a, b));
    }
}

Measured memory_bytes: 23124
use std::cmp::min;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(x: usize, y: usize) -> usize {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(dead_code)]
fn main() {
    //let a = u32::max_value();
    //println!("{}", a + a);

    let a = read::<usize>();
    let b = read::<usize>();
    let mut g = gcd(a, b);
    let end = (g as f64).sqrt().ceil() as usize;

    let mut ans: usize = 0;
    for k in 2..end + 1 {
        let mut c = 0;
        while g % k == 0 {
            c += 1;
            g /= k
        }
        if c > 0 {
            ans += 1
        }
    }

    if g != 1 { // g == old g
        ans += 1;
    }
    println!("{}", ans + 1)
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll N = nextLong();

  if (N == 1) {
    cout << "a" << endl;
    return 0;
  }

  vector<ll> bs, ss;
  bs.push_back(1);
  for (; bs.back() < N;) {
    bs.push_back(bs.back() * 26);
  }
  // pv(ALL(bs));

  ss.push_back(bs[0]);
  for (int i = 1; i < (int)bs.size(); i++) {
    ss.push_back(ss.back() + bs[i]);
  }
  // pv(ALL(ss));

  int l = 0;
  while (ss[l] <= N) l++;
  // cout << "l=" << l << endl;

  ll r = N - ss[l-1];
  string ans;
  REP(k, l) {
    ans = (char)((r % 26)+'a') + ans;
    r /= 26;
  }

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3696
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(s: chars);
    let mut c = 0;
    let mut m = 0;
    for i in 0..3 {
        if s[i] == 'R' {
            c += 1;
        } else {
            c = 0;
        }
        m = max(m, c);
    }
    puts!("{}\n", m);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2212
import java.util.Scanner;

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

        int cnt = x/100;
        int amr = x%100;

        String ans = "1";
        if(cnt < 20 && amr > 5*cnt) {
            ans = "0";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,a,b) for(int i=a;i<=int(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

struct Edge
{
	int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

/*.....................DEFINE FUNCTIONS ......................*/
	//次に見る点  親の色   親
void dfs(int v,int c=-1 ,int p = -1) {
	int k=1;
	for (auto u : g[v]) {
		if (u.to == p)continue;
		if(k==c)k++;
		ans[u.id]=k; k++;

		dfs(u.to,ans[u.id],v);
	}

}
/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	int N;
	cin >> N;
	VPII in(N);
	g.resize(N);
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].PB( (Edge){b, i});
		g[b].PB( (Edge){a, i});
	}
	int K=0;
	REP(i,N){
		K=max((int)g[i].size(),K);
	}
	ans.resize(N);
	dfs(0);
	cout<<K<<endl;
	REP(i,N-1){
		cout<<ans[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 11544
// ABC176B - Multiple of 9

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	string N;
	cin >> N;

	ull sum = 0;
	for (int i = 0; i < N.size(); i++) {
		sum += (N[i] - '0');
	}

	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        int sum = 0;
        double Sqsum = 0.0;
        int s;
        
        int i;
        while(true){
            n = sc.nextInt();
            if(n==0) break;

            for(i=0;i<n;i++){
                s = sc.nextInt();
                sum += s;
                Sqsum += s*s;
            }
            double ave;
            ave = (double)sum/n;
            double x;
            x = (double)Sqsum/n - ave*ave;
            double stdev;
            stdev = Math.sqrt(x);
            System.out.println(stdev);
            sum = 0;
            Sqsum = 0;
        }
        sc.close();
    }
}


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

int main()
{
	int n;
	
	scanf("%d", &n);
	while (n-- > 0){
		char str[2048] = {0};
		scanf("%s", str);
		
		deque<char> train;
		train.push_back(*str);
		bool v[26] = {false};
		v[*str - 'a'] = true;
		for (int i = 3; str[i] != 0; i += 3){
			if (!v[str[i] - 'a']){
				if (str[i - 1] == '>') train.push_back(str[i]);
				else train.push_front(str[i]);
				v[str[i] - 'a'] = true;
			}
		}
		
		while (!train.empty()){
			putchar(train.front());
			train.pop_front();
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{	

public static void main(String[] args) {
	Queue<String> name = new LinkedList<String>();
	Queue<Integer> time = new LinkedList<Integer>();
	
	Scanner in = new Scanner(System.in);
	
	int elems = in.nextInt();
	int timer = in.nextInt();
	int timePassed = 0;
	in.nextLine();
	
	String eName = "";
	int eTime = 0;
	
	for (int i = 0; i < elems; i++) {
		eName = in.next();
		name.add(eName);
		eTime = in.nextInt();
		time.add(eTime);
	}
	
	while(!name.isEmpty()) {
		String str = name.poll();
		int remainingTime = time.poll();
		if (remainingTime <= timer) {
			timePassed += remainingTime;
			System.out.println(str + " " + timePassed);
		}
		else {
			remainingTime -= timer;
			name.add(str);
			time.add(remainingTime);
			timePassed += timer;
		}
	}
}
}


Measured memory_bytes: 72004
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
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;
}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    string s;cin >> s;
    rev(all(s));
    vl v(s.size());
    ll tmp=0;
    rep(i,s.size()){
        tmp+=modpow(10,i,2019)*(s[i]-'0');
        //cout << tmp <<endl;
        tmp%=2019;
        v[i]=tmp;
    }
    //rep(i,s.size())cout << v[i] <<endl;
    vl count(2019,0);
    count[0]++;
    rep(i,s.size())count[v[i]]++;
    ll ans=0;
    rep(i,2019){
        ans+=count[i]*(count[i]-1)/2;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 5204
import numpy as np

N, M = map(int, input().split())

result = [0] * N
wa = [0] * N



for i in range(M):
    p, s = input().split()
    p = int(p)

    if s == 'AC':
        result[p-1] = 1
    elif s == 'WA' and result[p-1] == 0:
        wa[p-1] += 1

ac = np.sum(np.array(result))
wa = np.sum(np.array(result)*np.array(wa))

print(int(ac), int(wa))


Measured memory_bytes: 21536
import sys
N = int(input())
H = list(map(int, input().split()))
for i in range(N - 1):
    if H[i] < H[i + 1]:
        H[i + 1] -= 1
    elif H[i] > H[i + 1]:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 20708
#include <stdio.h>

int     main(void)
{
    int length;
    int width;
    int area;
    int perimeter;
    
    scanf("%d %d",&length,&width);
    area = length*width;
    perimeter = 2*(length + width);
    printf("%d %d\n",area,perimeter);
    return (0);
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int INF = 1234567890;
constexpr int MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    string s;
    cin >> s;
    const int n = s.size();
    int ans = 0;
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[n - i - 1])
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp42 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Console.WriteLine(st.Sum() - st.Max());

        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int disx[100005]={0},disy[100005]={0},vis[100005]={0};
vector<int> a[100005];
void dfs(int i,int d,int *dis)
{
	vis[i]=1;
	for(int x:a[i])
		if(vis[x]==0)
		{
			dis[x]=d;
			dfs(x,d+1,dis);
		}
}
int main(){
	int i,n,p,q;
	cin>>n>>p>>q;
	for(i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	disx[p]=0;
	dfs(p,1,disx);
	disy[q]=0;
	memset(vis,0,sizeof(vis));
	dfs(q,1,disy);
	int ans=0;
	/*for(i=1;i<=n;i++)
		cout<<disx[i]<<" ";
	cout<<endl;
	
	for(i=1;i<=n;i++)
		cout<<disy[i]<<" ";
	cout<<endl;*/
	for(i=1;i<=n;i++)
		if(disy[i]>disx[i])
			ans=max(disy[i],ans);
	cout<<ans-1<<endl;
}


Measured memory_bytes: 10752
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N,K;
ll a[15];

int main(){
    cin>>N>>K;
    rep(i,N) cin>>a[i];

    ll ans=LINF;
    rep(n,1<<(N-1)){
        ll cnt=0;
        rep(i,N-1) cnt+=n>>i&1;
        if(cnt!=K-1) continue;

        ll sup=a[0];
        ll res=0;
        rep(i,N-1){
            if(n>>i&1){
                if(a[i+1]<=sup){
                    sup++;
                    res+=sup-a[i+1];
                }else{
                    sup=a[i+1];
                }
            }else{
                sup=max(sup,a[i+1]);
            }
        }
        //cout<<' '<<res<<endl;
        ans=min(ans,res);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
/*
c = 0.5 * sinC * de
sinC = c / (0.5 * de)
C = asin(c / (0.5 * de)))
 */
double Calc(int a, int b, int x){
  double c, d, e, f;
  c = (double) x / a;
  if(a * b * 0.5 >= c){
    d = b;
    f = 2 * c / d;
    e = sqrt(f * f + d * d);
    return 90 - asin(c / (0.5 * d * e)) / M_PI * 180;
  }else{
    d = 2 * c / a - b;
    f = b - d;
    e = sqrt(a * a + f * f);
    c -= 0.5 * a * b;
    return 90 - asin(c / (0.5 * d * e)) / M_PI * 180;
  }
}

int main(void){
  int a, b, x;
  scanf("%d %d %d", &a, &b, &x);
  printf("%f\n", Calc(a, b, x));
  return 0;
}


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

using namespace std;

int n;

int main() {
  cin >> n;
  int a[n], b[n];
  rep(i,n-1) {
    cin >> b[i];
  }
  
  a[0] = b[0];
  long long int counter = a[0]; 
  rep1(i, n-1) {
    a[i] = min(b[i], b[i-1]);
    counter += a[i];
  }
  a[n-1] = b[n-2];
  counter += a[n-1];
  
  cout << counter;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll h,w,k;
  cin>>h>>w>>k;
  ll dp[111][11]={};
  dp[0][0]=1;
  for(int i=0;i<h;i++){
	for(int j=0;j<1<<(w-1);j++){
	  int f=0;
	  for(int k=1;k<w-1;k++){
		if(j>>(k-1)&1&&j>>k&1)f=1;
	  }
	  if(f)continue;
	  for(int k=0;k<w;k++){
		int nw=k;
		if(k!=0&&j>>(k-1)&1)nw=k-1;
		if(k!=w-1&&j>>k&1)nw=k+1;
		dp[i+1][nw]+=dp[i][k];
		dp[i+1][nw]%=MOD;
	  }
	}
  }
  cout<<dp[h][k-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
s[2],a[20];main(i,j,n,N,m){for(;scanf("%d",&n),n;printf("%d\n",m)){for(i=0;i<n;i++)scanf("%d",a+i);for(i=0,m=9999,N=1<<n;i<N;j=abs(*s-s[1]),m=m<j?m:j,i++)for(*s=s[1]=j=0;j<n;j++)s[(i>>j)&1]+=a[j];}exit(0);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll L;
    cin >> L;
    ll N = 0, path_cnt = 1;

    vl U, V, C;
    while(path_cnt*2<=L){
        N++;
        path_cnt *= 2;
        U.eb(N), U.eb(N);
        V.eb(N + 1), V.eb(N + 1);
        C.eb(0), C.eb(path_cnt/2);
    }

    ll now = N - 1, now_cnt = path_cnt / 2;
    ll d = L - path_cnt;

    repr(i, N){
        if(d>=now_cnt){
            U.eb(i + 1), V.eb(N+1), C.eb(path_cnt);
            path_cnt += now_cnt;
            d -= now_cnt;
        }
        now_cnt /= 2;
    }

    cout << N + 1 << " " << U.size() << endl;
    rep(i,U.size()){
        cout << U[i] << " " << V[i] << " " << C[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int arr[3];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for (int i=0;i<3;i++) cin>>arr[i];
    sort(arr,arr+3);
    if (arr[0]==arr[1] && arr[1]!=arr[2]){
        cout<<"Yes";
        return 0;
    }
    if (arr[0]!=arr[1] && arr[1]==arr[2]){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 10;
const int mod = 2019;
char s[N];
int dig[N], a[2562];
int mul(int x, int y){
	return 1LL * x * y % mod;
}
int add(int x, int y){
	x = (x + y) % mod;
	if(x < 0) x += mod;
	return x;
}
int main(){
	int n = 0, now, sum = 0;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; s[i] != '\0'; i++){
		dig[i] = s[n - i + 1] - '0';
	}
	now = 1;
	a[0] = 1;
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		if(i != 1) now = mul(now, 10);
		sum = add(sum,  mul(now, dig[i]));
		ans += a[sum];
		a[sum]++;
		//printf("sum = %d\n", sum);
	}
	printf("%lld", ans);


}

Measured memory_bytes: 4744
#include <stdio.h>
#include <string.h>
#include <math.h>

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

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

  for (i = 0; i < N; i++)
  {
    if (A[i] % 2 == 0)
    {
      if (A[i] % 3 == 0 || A[i] % 5 == 0)
      {
        // 何もしない
      }
      else
      {
        printf("DENIED");
        return (0);
      }
    }
  }

  printf("APPROVED");
  return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = int(1e5) + 100;

char s[N];
vi pos[30];

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; ++i) {
        pos[s[i] - 'a'].pb(i);
    }
    for (int i = 0; i < 26; ++i) {
        pii best(inf, -1);
        for (int j = 0; j < sz(pos[i]); ++j) {
            if (best.fs < 2 * j - pos[i][j] + 1) {
                cout << best.sc + 1 << " " << pos[i][j] + 1 << endl;
                return 0;
            }
            best = min(best, mp(2 * j - pos[i][j], pos[i][j]));
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int main(){
  int n,i;
  double x1,y1,x2,y2,x3,y3,a1,b1,c1,a2,b2,c2,x,y,r,dst;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
 
  a1=2*(x2-x1),b1=2*(y2-y1),c1=(x1*x1)-(x2*x2)+(y1*y1)-(y2*y2);
  a2=2*(x3-x1),b2=2*(y3-y1),c2=(x1*x1)-(x3*x3)+(y1*y1)-(y3*y3);
 
  x=((b1*c2)-(b2*c1))/((a1*b2)-(a2*b1));
  y=((c1*a2)-(c2*a1))/((a1*b2)-(a2*b1));
 
  r=sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
   
  printf("%.3f %.3f %.3f\n",x,y,r);
  }
  return 0;
  }


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int A, B;
	cin >> A >> B;
	B--;
	A--;
	cout << (B + A - 1) / A << endl;
	return (0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>

using LL = long long;

int get_phi(int n)
{
    int result = n;
    for (int d = 2; d * d <= n; ++ d) {
        if (n % d == 0) {
            result = result / d * (d - 1);
            while (n % d == 0) {
                n /= d;
            }
        }
    }
    if (n > 1) {
        result = result / n * (n - 1);
    }
    return result;
}

int pow(int a, LL n, int m)
{
    int result = 1;
    while (n) {
        if (n & 1) {
            result = 1LL * result * a % m;
        }
        a = 1LL * a * a % m;
        n >>= 1;
    }
    return result;
}

void ext_gcd(int a, int b, LL& x, LL& y)
{
    if (b == 0) {
        x = 1, y = 0;
    } else {
        ext_gcd(b, a % b, y, x);
        y -= a / b * x;
    }
}

LL solve(int a, int m, int lb = 0)
{
    if (m == 1) {
        return 40;
    }
    if (!lb) {
        int pw = 1;
        for (int i = 0; i < 40; ++ i) {
            if (pw == i % m) {
                return i;
            }
            pw = 1LL * pw * a % m;
        }
    }
    int phi = get_phi(m);
    int g = std::__gcd(m, phi);
    __int128 s = solve(a, g, 1);
    int pw = pow(a, s, m);
    LL x, y;
    ext_gcd(phi, m, x, y);
    if (x < 0) {
        x += ((-x + (m - 1)) / m) * m;
    }
    // s + k * phi = pw
    int t = (pw + m - s % m) % m;
    assert(t % g == 0);
    s += (__int128)x * (t / g) * phi;
    LL mod = 1LL * phi * m;
    s %= mod;
    if (s < 40) {
        s += mod;
    }
    return s;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("F.in", "r", stdin);
#endif
    int T;
    scanf("%d", &T);
    while (T --) {
        int a, m;
        scanf("%d%d", &a, &m);
        auto x = solve(a, m);
        // assert();
        printf("%lld\n", x);
    }
}

Measured memory_bytes: 128
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};

// [NOTE] つかうときには trim() 入れないと RE になるので注意
// abcde
fn read_as_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_as_line();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_as_line();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_as_line();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_as_line();
    let mut it = s.trim().split_whitespace();
    (
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_as_line();
    let mut it = s.trim().split_whitespace();
    (
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
        it.next().unwrap().parse().ok().expect("failed to parse"),
    )
}

fn main() {
    let (n, m): (usize, usize) = read_as_pair();
    let mut bag = HashMap::new();

    for i in 0..m {
        let (p, y): (usize, usize) = read_as_pair();
        bag.entry(p).or_insert(vec![]).push((y, p, i));
    }

    let mut ans = vec![String::from(""); m];
    for p in 1..n+1 {
        if bag.contains_key(&p) {
            let mut xs = bag.get_mut(&p).unwrap();
            xs.sort();
            let it = xs.iter().map(|&(y, p, i)| (p, i)).enumerate();
            for (k, (p, i)) in it {
                ans[i] = format!("{:06}{:06}", p, k + 1);
            }
        }   
    }
    for i in 0..m {
        println!("{}", ans[i]);
    }

}

Measured memory_bytes: 26032
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char c[H][W];
  bool h[H],w[W];
  FOR(i,0,H)h[i] = 1;
  FOR(j,0,W)w[j] = 1;
  FOR(i,0,H)FOR(j,0,W)cin >> c[i][j];
  FOR(i,0,H){
    bool flag = 1;
    FOR(j,0,W)if(c[i][j] == '#')flag = 0;
    if(flag)h[i] = 0;
  }
  FOR(j,0,W){
    bool flag = 1;
    FOR(i,0,H)if(c[i][j] == '#')flag = 0;
    if(flag)w[j] = 0;
  }
  FOR(i,0,H){
    FOR(j,0,W)if(h[i]&&w[j])cout << c[i][j];
    if(h[i])cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int MAX_S = 100100;
const int ALPHA = 30;
//const int ALPHA = 3;
 
int cnt[MAX_S][ALPHA];
int main(){
    string S;
    cin >> S;
    int L = S.length();
    REP(i,L){
        char s = S[i];
        cnt[i][s - 'a'] = 1;
    }

    char table[3];
    table[0] = 'Z';
    table[1] = 'Y';
    table[2] = 'X';
    int left = -1, right = -1;
    for(int i = 0; i < L; i++){
        table[2] = table[1];
        table[1] = table[0];
        table[0] = S[i];
        if(table[0] == table[1]){
            right = i+1;
            left = i;
            break;
        }else if(table[0] == table[2]){
            right = i+1;
            left = i-1;
            break;
        }else if(table[1] == table[2]){
            right = i;
            left = i-1;
            break;
        }
    }
    printf("%d %d\n", left, right);
    return 0;
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],sum,k;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n;i>=n-k+1;i--)
		sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]);

    bool ok = true;

    foreach (i ; 0 .. N) {
        if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
            ok = false;
        }
    }

    writeln(ok ? "APPROVED": "DENIED");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
program agc005_a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,n,ans
    integer(int32), allocatable:: cnt(:)
    character(200000):: x

    read*, x
    n = len_trim(x)
    allocate(cnt(0:n), source=0)
    ans = n
    do i=1, n
        if (x(i:i) == 'S') then
            cnt(i)=cnt(i-1)+1
        else
            cnt(i)=max(cnt(i-1)-1,0)
            if (cnt(i-1) >= 1) ans=ans-2
        end if
    end do
    ! print'(*(i0,1x))', cnt(:)
    print'(i0)', ans
end program agc005_a

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve(){
	
	int k, ans=0;
	int v[3] = {1,0,-1};
	int t[3];
	
	for(int i=0; i<3; i++) cin >> t[i];
	cin >> k;
	
	for(int i=0; i<3; i++){
		if(k >= t[i]){
			k-=t[i];
			ans += v[i]*t[i];
		}
		else{
			ans += v[i]*k;
			break;
		}
	}
	
	cout << ans << endl;

}

int main(){

	fastcin
	
	solve();
	      
	return 0;
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
//#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/

template<class Monoid> struct SegTree{
	using Func = function<Monoid(Monoid, Monoid)>;
	vector<Monoid> dat;
	int SIZE_R;
	const Func F;
	const Monoid UNITY;

	SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity){ init(n); }
	void init(int n){
		SIZE_R = 1;
		while(SIZE_R < n) SIZE_R *= 2;
		dat .assign(SIZE_R*2, UNITY);
	}

	void set(int a, const Monoid &v) { dat[a+SIZE_R] = v;}
	void build(){
		for(int k = SIZE_R -1; k > 0; --k){
			dat[k] = F(dat[k*2], dat[k*2+1]);
		}
	}

	void update(int a, const Monoid &v){
		int k = a + SIZE_R;
		dat[k] = v;
		while(k >>= 1){
			dat[k] = F(dat[k*2], dat[k*2+1]);
		}
	}

	Monoid get(int a, int b){
		Monoid vleft = UNITY, vright = UNITY;
		for(int left = a+SIZE_R, right = b+SIZE_R; left < right; left >>= 1, right >>= 1){
			if(left & 1) vleft = F(vleft, dat[left++]);
			if(right & 1) vright = F(dat[--right], vright);
		}
		return F(vleft, vright);
	}
	inline Monoid operator [] (int a){return dat[a+SIZE_R]; }
};

#define int int64_t
signed main()
{
    int n; cin >> n;
	SegTree<int64_t> seg(n, [](int64_t a, int64_t b){return GCD(a, b);}, 0);

	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		seg.set(i, a[i]);
	}
	seg.build();

	int64_t ans{};
	for(int i = 0; i < n; ++i){
		int64_t left = seg.get(0,i);
		int64_t right = seg.get(i+1, n);
		amax(ans, GCD(left, right));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3072
import java.util.Random;
import java.util.Scanner;

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

        String str = scanner.nextLine();

        for (int i = 0; i < str.length(); ++i) {
            char c = str.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                System.out.print((char)(c - ('A' - 'a')));
            } else if (c >= 'a' && c <= 'z') {
                System.out.print((char)(c - ('a' - 'A')));
            } else {
                System.out.print(c);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 26944