akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main() {
string S;
int N;
int count=0;
cin>>N>>S;
for(int i=0;i<=N-3;i++){
if(S.at(i)=='A'){
    if(S.at(i+1)=='B'){
        if(S.at(i+2)=='C'){
            count++;
        }
    }
}
}
cout<<count<<endl;
}

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

int main(){
  int h, w, n, sr, sc;
  string s, t;
  cin >> h >> w >> n >> sr >> sc >> s >> t;
  int lh=0, rh=h+1;
  int lw=0, rw=w+1;
  for(int i=n-1; i>=0; --i){
    if(t[i] == 'L') rw = min(w+1, rw+1);
    else if(t[i] == 'R') lw = max(0, lw-1);
    else if(t[i] == 'U') rh = min(h+1, rh+1);
    else if(t[i] == 'D') lh = max(0, lh-1);
    //cout << "(lh:" << lh << ",rh:" << rh << ") (lw:" << lw << ",rw:" << rw << ")" << endl;
    if(s[i] == 'L') ++lw;
    else if(s[i] == 'R') --rw;
    else if(s[i] == 'U') ++lh;
    else if(s[i] == 'D') --rh;
    //cout << "(lh:" << lh << ",rh:" << rh << ") (lw:" << lw << ",rw:" << rw << ")" << endl;
    if(lw+1 == rw || lh+1 == rh){
      cout << "NO" << endl;
      return 0;
    }
  }
  if(lh < sr && sr < rh && lw < sc && sc < rw){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3924
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
            int N = Integer.parseInt(br.readLine());
 
            int x;
 
            for(int i = 1; i <= N; i++)
            {
                if(i%3 == 0){
                    System.out.printf(" %d",i);
                }else{
                    x = i;
                    do{
                        if(x%10 == 3){
                            System.out.printf(" %d",i);
                            break;
                        }
                        x /=10;
                    }while(x != 0);
                }
            }
            System.out.printf("\n");
 
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 37716
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int va[1005],we[1005];
int dp[1005]={};
#define INF 1000000000
int main(){
	int cou=1;
	while(1){
		memset(dp,0,sizeof(dp));
		scanf("%d",&n);
		if(!n) break;
		int m;
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%d,%d",&va[i],&we[i]);
		}
		for(int i=0;i<m;i++){
			for(int j=n;j>=we[i];j--){
				dp[j]=max(dp[j],dp[j-we[i]]+va[i]);
			}
		}
		int rp=0,e;
		for(int i=n;i>=0;i--){
			if(rp<=dp[i]){
				e=i;
				rp=dp[i];
			}
		}
		printf("Case %d:\n",cou);
		cou++;
		printf("%d\n%d\n",rp,e);
	}
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string st;
  cin >> st;
  bool n, e, w, s;
  n = e = w = s = false;
  for (int i = 0; i < st.size(); i++) {
    switch (st[i]) {
      case 'N':
        n = true;
        break;
      case 'E':
        e = true;
        break;
      case 'W':
        w = true;
        break;
      case 'S':
        s = true;
        break;
    }
  }
  if (n == s && w == e) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[15];
string str;
int tmp,ans=1000000000;
int main(){
  cin >> str;
  for(int i=0;i<str.size();i++){
    num[i]=str[i]-'0';
    //cout << num[i] << endl;
  }
  //cout << "qa" << endl;
  //right=left+3;
  for(int left=0;left<=str.size()-3;left++){
    tmp=num[left]*100+num[left+1]*10+num[left+2];
    ans=min(abs(753-tmp),ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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 main() {
    // TODO: CASE#4
    let n: usize = read();
    let mut a: Vec<Vec<u8>> = vec![vec![0; n]; n];
    for _ in 0..n {
        let index: usize = read();
        let count: usize = read();
        for _ in 0..count {
            let number: usize = read();
            a[index - 1][number - 1] = 1;
        }
    }
    for index_i in 0..n {
        for index_j in 0..n {
            if index_j == n - 1 {
                println!("{}", a[index_i][index_j]);
            } else {
                print!("{} ", a[index_i][index_j]);
            }
        }
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);


int main()
{
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Set<Integer> set = new HashSet<>();
    set.add(sc.nextInt());
    set.add(sc.nextInt());
    set.add(sc.nextInt());

    if(set.size() == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21588
N = int(input())
p = list(map(int, input().split()))
i = 0
ans = 0
while(i < N - 1):
    if p[i] == i + 1:
        ans += 1
        p[i], p[i + 1] = p[i + 1], p[i]
    i += 1
if p[N - 1] == N:
    ans += 1
print(ans)

Measured memory_bytes: 14008
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       while( true ){
           String s = sc.next();
           if( s.equals( "-" ) ){
                break;
                }
              int m = sc.nextInt();
         for(int i=0;i<m;i++){
       		 int h = sc.nextInt();
        	 String s1 = s.substring(0,h);
             String s2 = s.substring(h);
             s=s2+s1;
           }
            System.out.println(s);
       }
  } 
}


Measured memory_bytes: 26404
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n;
  ccin >> n;
  char last = '0';
  bool ans = true;
  vector<string> vs;
  rep(i, n) {
    string w;
    ccin >> w;
    if (i == 0) last = w.at(w.size() - 1);
    else if (w.at(0) != last) ans = false;
    last = w.at(w.size() - 1);

    rep(j, vs.size()) if (w == vs[j]) ans = false;
    vs.push_back(w);
  }
  if (ans)
    ccout << "Yes" << endl;
  else
    ccout << "No" << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s,w = get_all_int()

print("unsafe" if s<=w else "safe")

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

int N, A[3][3], b[10];
bool appear[3][3];

int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	cin >> N;
	for (int i = 0; i < N; i++) cin >> b[i];
	for(int i = 0; i < N; i++) {
		 for(int j = 0; j < N; j++) {
			 appear[i][j] = false;
			 for(int k = 0; k < N; k++) {
				 if(A[i][j] == b[k]) appear[i][j] = true;
			}
		}
	}

	string ANS = "No";
	for(int i = 0; i < 3; i++) {
		if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
	}
	for(int i = 0; i < 3; i++) {
		if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
	}
	if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
	if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
	cout << ANS << endl;
	return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n;
	cin >> n;
	vl a(n), b(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	ll ans = 0;
	vl b2(n);
	rep(k, 29) {
		ll t = pow(2, k + 1);
		rep(i, n) {
			b2[i] = b[i];
			b2[i] %= t;
		}
		sort(all(b2));
		ll cnt = 0;
		rep(i, n) {
			ll a2 = a[i] % t;
			cnt += lower_bound(all(b2), 2 * (1 << k) - a2) - lower_bound(all(b2), (1 << k) - a2);
			cnt += lower_bound(all(b2), 4 * (1 << k) - a2) - lower_bound(all(b2), 3 * (1 << k) - a2);
		}
		if (cnt % 2) {
			ans |= (1LL << k);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
import bisect
n= int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

inf= 10**9
min_lis= [a[0]]
for i in range(1,n):
    if a[i]> min_lis[-1]:
        min_lis.append(a[i])
    else:
        min_lis[bisect.bisect_left(min_lis,a[i])]=a[i]
print(len(min_lis))
    
'''
if a==[3,1000000000,999999998,999999999]:
    res=2
print(res)
'''


Measured memory_bytes: 10356
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

#define MAX 1000000

int main(void)
{
	int e;
	vector<pii> vs;
	for (int y = 0;; y++) {
		int k = y*y;
		if (k > MAX) break;
		for (int z = 0;; z++) {
			int l = z*z*z;
			if (k+l > MAX) break;
			vs.push_back(pii(k+l, y+z));
		}
	}
	sort(ALL(vs));

	while (cin >> e, e) {
		int ans = (1<<29);
		rep(i, vs.size()) {
			int x = e-vs[i].first;
			if (x < 0) continue;
			ans = min(ans, x+vs[i].second);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1964
# frozen_string_literal: true

# 最初のボトルネックにひっかかるまでとそのあとを数える
# 最後3WAなった理由わからんちん

n = gets.chomp.to_i
lis = 5.times.map { gets.chomp.to_i }
neck = lis.min
# ボトルネックで浪費する分 + ボトルネックにひっかかったあと
p (n / neck.to_f).ceil + 5 - 1


Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

string str;

ll sub(bool just,bool zero,bool three,bool five,bool seven,int num,string ans){
    //cout << three << five << seven << endl;
    if(num==str.size() && three && five && seven){return 1;}
    //if(num==str.size() && three && five && seven){cout << ans << endl;return 1;}
    if(num==str.size())return 0;
    //cout << num << " " << str[num]-48 << str.size() << endl;
    //cout << num << endl;
    ll sum=0;
    if(zero)sum += sub(0,1,0,0,0,num+1,ans+'0');//先頭がzero
    if(str[num]-48>=3 || !just)sum += sub((just&&str[num]-48==3),0,1,five,seven,num+1,ans+'3');//3を挿入
    if(str[num]-48>=5 || !just)sum += sub((just&&str[num]-48==5),0,three,1,seven,num+1,ans+'5');//5を挿入
    if(str[num]-48>=7 || !just)sum += sub((just&&str[num]-48==7),0,three,five,1,num+1,ans+'7');//7を挿入
    //cout << str.size() << " " << num << " " << str[num] << " " <<sum << endl;
    return sum;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> str;
    string ans = "";
    cout << sub(1,1,0,0,0,0,ans) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for (int i = 1; i <= n; i++) {
      int x = i;
      if (x % 3 == 0) {
        System.out.print(" " + x);
      } else {
        while (x > 0) {
          if (x % 10 == 3) {
            System.out.print(" " + i);
            break;
          }
          x /= 10;
        }
      }
    }
    System.out.println();
  }
}


Measured memory_bytes: 28848
package main

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

func main() {
	n := getInt()
	as := getIntSlice(n)

	ans := 1 << 60
	for i := -100; i <= 100; i++ {
		count := 0
		for _, a := range as {
			count += (a - i) * (a - i)
		}
		ans = min(ans, count)
	}

	fmt.Println(ans)
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;

int main(){
  
  int a,b;
  
  cin >> a >> b;
  
  if(a<b){
    
    cout << "a < b" << endl;
    
  }else if(a == b){
    
    cout << "a == b" << endl;
    
  }else if(a>b){
    
    cout << "a > b" << endl;
  }
}


Measured memory_bytes: 3100
n = int(input())
a = []
k = []
for i in range(n):
    c = int(input())
    a.append(c)
    k.append(c)
a = sorted(a)
m = a[-1]
l = a[-2]
for i in range(len(k)):
    if(m!=k[i]):
        print(m)
    else:
        print(l)


Measured memory_bytes: 83416
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

def simulation(N, K, A_list):
    for k in range(min(K, 42)):
        #next_A_list = [0 for i in range(N)]
        imos_list = [0 for i in range(N)]
        for i in range(N):
            d = A_list[i]
            imos_list[max(i-d, 0)] += 1
            if i+d+1 <= N-1:
                imos_list[i+d+1] -= 1
            #for j in range(i-d, i+d+1):
            #    if j >= 0 and j <= N-1:
            #        next_A_list[j] += 1
        for i in range(1, N):
            imos_list[i] += imos_list[i-1]
        A_list = imos_list[:]
        #print(" ".join([ str(i).zfill(2) for i in A_list]))
    return A_list

def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    print(" ".join([ str(i) for i in simulation(N, K, A_list)]))

if __name__ == "__main__":
    main()



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  int ans = 0;
  rep(i,d){
    rep(j,n) if(i%a[j] == 0) ans++;
  }

  cout << ans + x << endl;
}


Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    weight = [0]
    value = [0]
    for i in range(N):
        w, v = map(int, input().split())
        weight.append(w)
        value.append(v)
    V = sum(value)
    dp = [[float('inf')]*(V+1) for i in range(N+1)]
    for i in range(N):
        dp[i][0] = 0
    
    for i in range(1, N+1):
        for val in range(1, V+1):
            if val >= value[i]:
                dp[i][val] = min(dp[i-1][val], dp[i-1][val-value[i]]+weight[i])
            else:
                dp[i][val] = dp[i-1][val]
    ans = 0
    for v in range(V, -1, -1):
        if dp[N][v] <= W:
            ans = v
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 414280
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int R, G, a;
	while(~scanf("%d %d",&R,&G))
	{
		a = (2 * G) - R;
		printf("%d\n",a);
	}
}

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

int main() {
  long double a,b;
  cin>>a>>b;
  ll N=a*b;
  cout<<N;
}

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

using namespace std;

int main()
{

int n,a,cnt=0;

cin >> n;

for(int i=1;i<=n;i++)
{
cin >> a;

if(a!=i) cnt++;

}

if(cnt<=2) cout << "YES";

else cout << "NO";

return 0;
}


Measured memory_bytes: 256
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int r;
	cin>>r;
	cout<<r*r;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q1();
	return 0;
}
	


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long g = A[0];
		for(int i=0;i<N;i++) g = gcd(g,A[i]);
		if(K % g != 0){ Console.WriteLine("IMPOSSIBLE"); return;}
		Console.WriteLine(K <= A.Max() ? "POSSIBLE" : "IMPOSSIBLE");
		
	}
	
	long gcd(long a, long b){ return a == 0 ? b : gcd(b%a, a);}
	
	int N;
	long K;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0];
		K = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18912
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

inline int f(ll a, ll b){
  int i = 0;
  while(a) a /= 10, ++i;
  int j = 0;
  while(b) b /= 10, ++j;
  return max(i, j);
}

void solve(){
  // main algorith
  ans = INFLL;
  for (int i = 1; i <= (int)sqrt(N); ++i)
  {
    if(N % i) continue;
    ans = min(ans, (ll)f(i, N / i));
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    int n;
    cin >> n;

    set<string> st;

    while(n--) {
        string s;
        cin >> s;

        st.insert(s);
    }

    cout << sz(st);

}








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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x;
	cin >> x;
	
	if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, x, n) for(int i = x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
//struct cww{cww(){ios::sync_with_stdio(false);cin.tie(nullptr);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  REP(i, n) scanf("%d", &a[i]);

  int num = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0 && a[i] % 2 == 1) {
      ++num;
    }
  }

  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> k >> s;
    int n = s.length();
    if (n <= k){
        PRINT(s);
    }
    else{
        PRINT(s.substr(0,k)+"...");
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void era( const ll N , vector<ll> &f)
{
   /* std::vector<bool> is_prime( N+1 );
    for( ll i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }*/
	
    for( ll i= 2; i <= N; i++ )
    {
       // if( is_prime[ i ] )
        //{
            for( ll j = 2 * i; j <= N; j += i )
            {
                //is_prime[ j ] = false;
				f[j]++;
            }
            
        //}
    }
}

void solve(){
	ll n;
	cin>>n;
	
	vector<ll> f(n+1,2);
	f[1]=1;
	era(n,f);
	
	ll ans=0;
	
	for(ll i=1;i<=n;i++){
		ans+=i*f[i];
	}

	cout<<ans<<endl;
	
	
}

int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 81400
#include<iostream>
#include<cstring>
#define INF 10000000
#include<algorithm>
#include<cmath>
#include<vector>
#define MAX_V 1003
#define MAX_N 501
#define MAX_M 501
using namespace std;
struct edge{
	int to,cap,rev;
};
bool used[MAX_V];
bool can[MAX_N][MAX_M];
vector<edge> G[MAX_V];
void add_edge(int from,int to,int cap){
	edge pre;
	pre.to=to;pre.cap=cap;pre.rev=G[to].size();
	G[from].push_back(pre);
	pre.to=from;pre.cap=0;pre.rev=G[from].size()-1;
	G[to].push_back(pre);
}
int N,M;
int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t){
	int flow=0;
	for(;;){
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
	}
}
void solve(){
	int s=N+M,t=s+1;
	for(int i=0;i<M;i++){
		add_edge(s,i,1);
	}
	for(int i=0;i<N;i++){
		add_edge(M+i,t,1);
	}
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			if(can[i][j]){
				add_edge(i,M+j,1);
			}
		}
	}
	cout<<max_flow(s,t)<<endl;
}
int main(){
	int n[501],m[501];
	while(cin>>M>>N,N||M){
		for(int i=0;i<M;i++){
			cin>>m[i];
		}
		
		for(int i=0;i<N;i++){
			cin>>n[i];
		}
		for(int i=0;i<M;i++)
		for(int j=0;j<N;j++){
			can[i][j]=0;
			if(__gcd(m[i],n[j])>1){
				can[i][j]=1;
			}
		}
		solve();
		for(int i=0;i<=M+N+1;i++)
		G[i].clear();
	}
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main() {
    ll n;cin>>n;
    ll ans=(n-1)* (n)/2 ;
    cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int dp[3001][3001] = {0,};
int main() {
    string s, t;
    cin >> s;
    cin >> t;

    int n = s.size();
    int m = t.size();

    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=m; ++j) {
            dp[i][j] = dp[i - 1][j - 1] + (s[i - 1] == t[j - 1] ? 1 : 0);
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
        }
    }

    // backtrack
    string ans;
    ans.reserve(dp[n][m]+1);
    int r=n, c=m;
    while (r>0 && c>0) {
        if (s[r-1]==t[c-1]) {
            ans.push_back(s[r-1]);
            r -= 1;
            c -= 1;
        } else {
            if (dp[r-1][c]<dp[r][c-1]) {
                c -= 1;
            } else {
                r -= 1;
            }
        }
    }
    reverse(begin(ans), end(ans));
    cout << ans << endl;
}

Measured memory_bytes: 35456
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';

int64 calc(vpii &inp, int w) {
	int64 res[101000] = {0};
	for (auto t : inp) {
		for (int i = w; i >= t.F; i--) {
			res[i] = max(res[i] , res[i - t.F] + (int64)t.S);
		}
	}
	return res[w];
}



int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, w;
	cin >> n >> w;
	vpii inp;
	for0(i, n) {
		int w, v;
		cin >> w >> v;
		inp.pb({w, v});
	}
	sort(all(inp));
	int64 ans = calc(inp, w);
	cout << ans;

	return 0;
}

Measured memory_bytes: 1024
n, k = gets.chomp.split.map(&:to_i)
arr = (0..n).to_a
arr2 = arr.reverse
min = arr[0, k].inject(:+)
max = arr2[0, k].inject(:+)
answer = (max - min + 1) % 1000000007
(k + 1).upto(n + 1){|i|
    min += arr[i - 1]
    max += arr2[i - 1]
    answer = (answer + (max - min + 1) % 1000000007) % 1000000007
}
puts answer

Measured memory_bytes: 18240
using System;

class ABC080B
{
	static public void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());

		if(N % f(N) == 0)
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");
	}

	static int f(int n)
	{
		int ret = 0;
		while(n > 0)
		{
			ret += n % 10;
			n /= 10;
		}
		return ret;
	}
}


Measured memory_bytes: 13140
import itertools
import math

K = int(input())
nums = [i for i in range(1, K+1)]
product = itertools.product(nums, repeat=3)
ans = 0
for comb in product:
    m = min(comb)
    if m == 1:
        ans += m
    else:
        for i in range(0, 3):
            m = math.gcd(m, comb[i])
        ans += m
print(ans)

Measured memory_bytes: 68600
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

vll par;
vll rnk;
void init(lli n){
    par = vll(n);
    rnk = vll(n);
    for(lli i = 0;i < n;i++) par[i] = i;
}
lli find(lli x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
void unite(lli x,lli y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}
bool same(lli x,lli y){
    return find(x) == find(y);
}

lli n,m,q;
lli s,t;

int main(){
    cin >> n >> m;
    init(n);
    for(lli i = 0;i < m;i++){
        cin >> s >> t;
        unite(s,t);
    }
    cin >> q;
    for(lli i = 0;i < q;i++){
        cin >> s >> t;
        cout << (same(s,t) ? "yes" : "no" ) << endl;
    }
    return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int max(int a, int b) {
	return a > b ? a : b;
}

bool check(int a, int b, int i) {
	return (a % i == 0) && (b % i == 0);
}

int ans(int a, int b, int c) {
	vector<int> v;
	int m = max(a, b);
	
	for(int i = 1; i <= m; i++) {
		if(check(a, b, i)) {
			v.push_back(i);
		}
	}
	
	return v[v.size() - c];
}

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	
	cout << ans(a, b, k) << endl;
	
    return 0;
}

Measured memory_bytes: 256
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int r,g,b,n,out=0;
	cin>>r>>g>>b>>n;
	rep(i,n/r+1) rep(j,n/g+1){
		int x=n-i*r-j*g;
		if(x>=0 && x%b==0) out++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] d = new int[n];
        int a = 0;
        for(int i = 0; i < n; i++){
            d[i] = scan.nextInt();
            
        }
        for(int i = 0; i < n - 1; i++){
            for(int j = 1; j < n - i; j++){
                a = a + d[i] * d[i + j];
            }
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 22608
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
int main() {
	ll N;
	cin >> N;
	map<string, ll> vote;
	string s;
	for (int i = 0; i < N; i++) {
		cin >> s;
		vote[s]++;
	}
	ll cnt = 0;
	for (auto x : vote) {
		cnt = max(cnt, x.second);
	}
	for (auto x : vote) {
		if (x.second == cnt)cout << x.first << endl;
	}
}

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

long long x,k,aux;

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

    cin>>x>>k;
    if(x%k==0) cout<<"0";
    else {
        while(abs(x-k) < x) {
            if(x>k) aux=x/k;
            aux*=k;
            x=abs(x-aux);
            aux=1;
        }
        cout<<x;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-2*b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int N, H, W; cin >> N >> H >> W;
	vector<int> A; vector<int> B;
	for (int i = 0; i < N; i++) {
		int ipta, iptb;
		cin >> ipta >> iptb;
		A.push_back(ipta); B.push_back(iptb);
	}
	int score = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] >= H && B[i] >= W)score++;
	}
	print(score);





	



	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a==1)
    {
        a=14;
    }
    if(b==1)
    {
        b=14;
    }
    if(a>b)
    {
        cout<<"Alice"<<endl;
    }
    if(b>a)
    {
        cout<<"Bob"<<endl;
    }
    if(a==b)
    {
        cout<<"Draw"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
o = []
e = []
for i, va in enumerate(v):
    if i % 2 == 0:
        o.append(va)
    else:
        e.append(va)
import collections
o = collections.Counter(o).most_common()
e = collections.Counter(e).most_common()
if o[0][0] == e[0][0]:
    if len(o) == 1 and len(e) == 1:
        print(min(o[0][1], e[0][1]))
    elif len(o) == 1:
        print(n - o[0][1] - e[1][1])
    elif len(e) == 1:
        print(n - o[1][1] - e[0][1])
    else:
        print(n - o[0][1] - max(o[1][1], e[1][1]))
else:
    print(n - o[0][1] - e[0][1])


Measured memory_bytes: 20592
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

pasta=array(3)
3.times do|i|
    pasta[i]=gets.to_i
end
juice=array(2)
2.times do|i|
    juice[i]=gets.to_i
end
puts pasta.min+juice.min-50


Measured memory_bytes: 6884
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		int i,n = sc.nextInt();
		int array[] = new int[	100];
		for(i = 0; i < n; i++){
			array[i] = sc.nextInt();
		}
		for(i = i - 1; i >= 0; i--){
			System.out.print(array[i]);
			if(i != 0){
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
}

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

#define _LL long long

_LL getAns(_LL h, _LL w)
{
    _LL ans;
    if( h == 1 || w == 1 ) return 1;
    ans = w * (h / 2);
    if( h % 2 == 1 ) ans += ( w + 1 ) / 2;
    return ans;
}

int main()
{
    _LL h, w;
    cin >> h >> w;

    cout << getAns(h, w);
}

Measured memory_bytes: 3564
def main():
    #import sys
    #input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    mod = 10**9+7
    
    A = [defaultdict(int) for i in range(N)]
    helix = ["A","T","C","G"]
    out = ["AGC","GAC","ACG"]
    for i in helix:
        for j in helix:
            for k in helix:
                s = i+j+k
                if not s in out:
                    A[2][s] = 1
    for n in range(N-3):
        for i in helix:
            for j in helix:
                for k in helix:
                    m = n+3
                    s = i+j+k
                    if not s in out:
                        for l in helix:
                            t = l+i+j
                            if (not t in helix) and (not (k=="C" and (l+j=="AG" or i+j=="GA" or l+i=="AG"))) and (not (k=="G" and (i+j=="AC"))):
                                A[m][s] += A[m-1][t]
                                A[m][s] %= mod
    answer = 0
    for i in helix:
        for j in helix:
            for k in helix:
                s = i+j+k
                if not s in out:
                    answer += A[N-1][s]
                    answer %= mod
    print(answer)
main()

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

int N, ans = 0;

void dfs(int x, bool sev, bool fiv, bool thr) {
  if (N < x)
    return;
  if (sev && fiv && thr)
    ans++;
  if (x < 100000000) {
    dfs(10 * x + 3, sev, fiv, true);
    dfs(10 * x + 5, sev, true, thr);
    dfs(10 * x + 7, true, fiv, thr);
  }
}

int main() {
  cin >> N;
  dfs(0, false, false, false);
  cout << ans << endl;
}

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

using namespace std;


void Calculation()
{
  int H, W;
  string S[500];

  cin >> H >> W;
  for(int i = 0; i < H; i++) cin >> S[i];

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(j == 0 || S[i][j] == '#' || i % 2 == 0 && j != W - 1) cout << "#";
      else cout << ".";
    }
    cout << endl;
  }
  cout << endl;

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(j == W - 1 || S[i][j] == '#' || i % 2 == 1 && j > 0) cout << "#";
      else cout << ".";
    }
    cout << endl;
  }
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 2;  // k=n-1,n

  ll m = n - 1;
  for (ll i = 2; i * i <= m; i++) {
    if (m % i != 0) {
      continue;
    }
    if (m / i == i) {
      ans++;
    } else {
      ans += 2;
    }
  }

  for (ll i = 2; i * i <= n; i++) {
    ll t = n;
    if (t % i != 0) {
      continue;
    }
    while (t % i == 0) {
      t /= i;
    }
    if (t % i == 1) {
      ans++;
    }
    t = n;
    ll j = n / i;
    if (t % j != 0 || i == j) {
      continue;
    }
    while (t % j == 0) {
      t /= j;
    }
    if (t % j == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384