akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int A = one.get(0);
		int B = one.get(1);
		int C = one.get(2);
		for(int i = 1; i <= 10000; i++){
			if(A * i % B == C){
				myout("YES");
				return;
			}
		}
		myout("NO");
	}
	//Method addition frame start



	//Method addition frame end
}


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

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

using ll = long long;
using grid = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;
ll dp[1<<23];

ll f(const grid &g,int bit){
  if(dp[bit]!=-1LL) return dp[bit];
  dp[bit]=0LL;
  int cnt = __builtin_popcount(bit);
  for(int i = 0; i < 25;i++){
    if((bit&(1<<i))&&g[i][cnt-1]==1){
      int bitt=bit&(~(1<<i));
      dp[bit]+=f(g,bitt);
      dp[bit]%=mod;
    }
  }
  dp[bit]%=mod;
  return dp[bit];
}

int main() {
  int N;
  cin>>N;
  grid g(N,vector<int>(N));
  for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) cin>>g[i][j];
  for(int i = 0; i < 1<<23; i++) dp[i]=-1LL;
  for(int i = 0; i < N; i++){
    if(g[i][0]==1) dp[1<<i] = 1LL;
    if(g[i][0]==0) dp[1<<i] = 0LL;
  }
  cout<<f(g,(1<<N)-1)<<endl;
}

Measured memory_bytes: 65792
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (H, W) = get!(usize, usize);
    let a = get!(String; H);
    let mut S: String = "".to_string();
    for _ in 0..(W+2) {
        S.push('#');
    }
    println!("{}", S);
    for s in a {
        println!("#{}#", s);
    }
    println!("{}", S);
}

Measured memory_bytes: 4352
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int H = nextInt();
		int W = nextInt();
		int A = W - nextInt();
		int B = H - nextInt();

		int[][] map = new int[H][W];
		int[] h = new int[H];
		int[] w = new int[W];

		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(h[i]<A&&w[j]<B) {
					map[i][j] = 1;
					h[i]++;
					w[j]++;
				}
			}
		}

		int cntA = 0,cntB = 0;
		for(int i=0;i<H;i++) {
			if(h[i] == A)cntA++;
		}
		for(int j=0;j<W;j++) {
			if(w[j] == B)cntB++;
		}
		if(cntA != B||cntB != A) {
			out.println("No");
			return;
		}

		StringBuilder buf = new StringBuilder();
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				buf.append(map[i][j]);
			}
			buf.append(System.getProperty("line.separator"));
		}
		out.print(buf);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 33960
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");

		long[] A = new long[Ws.length];
		for (int i = 0; i < Ws.length; i++) {
			A[i] = Long.parseLong(Ws[i]);
		}


		if(A[0]==A[1]+A[2] || A[1] == A[0]+A[2] || A[2] == A[0]+A[1]){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}
	}

}


Measured memory_bytes: 21076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

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

    private void solve() {
        try {
            int K = sc.nextInt();

            int sum = 0;

            for(int a=1; a<K+1; a++) {
                for(int b=1; b<K+1; b++) {
                    for(int c=1; c<K+1; c++) {

                        sum+=gcd(gcd(a,b),c);

                    }
                }
            }

            System.out.println(sum);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private int gcd(int m, int n) {
        int r;
        while (n > 0) {
            r = m % n;
            m = n;
            n = r;
        }
        return m;
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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


int p[200010];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int ans=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		p[x]=i;
	}
	int cur=0;
	for(int i=1;i<=n;i++){
		if(p[i]>p[i-1])	cur++;
		else	cur=1;
		ans=max(cur,ans);
	}
	cout<<n-ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define MAX 10000000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> P;
int used[MAX];

P getRecurringCycle(int fraction,int denominator)
{
  rep(i,MAX)used[i] = -1;
  fraction *= 10;
  used[fraction] = 0;
  int cnt = 0;
  while(true)
    {
      cnt++;
      fraction -= fraction/denominator*denominator;
      fraction *= 10;
      if(fraction == 0)return P(cnt,0);
      if(used[fraction] != -1)break;
      used[fraction] = cnt;
    }
  return P(used[fraction],cnt-used[fraction]);
}

int main()
{
  int x,y;
  while(cin >> x >> y,x|y)
    {
      P p = getRecurringCycle(x,y);
      cout << p.first << " " << p.second << endl;
    }
  return 0;
}

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

using namespace std;

#define int long long
int cnt[100005];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q, b, c, sum = 0, x;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        cnt[x]++;
        sum += x;
    }
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        cin >> b >> c;
        sum -= cnt[b] * b;
        cnt[c] += cnt[b];
        sum += cnt[b] * c;
        cnt[b] = 0;
        cout << sum << '\n';
    }
    return 0;
}



Measured memory_bytes: 4416
#include<stdio.h>
 
int main()
{
  // 計算用の変数を宣言
  int i, tmp, current_kind, ans;

  // 入力を変数に代入
  int N, K;
  scanf("%d %d", &N, &K);

  // 配列初期化
  int count[N + 1]; // 添字の個数を表す配列 例えばAが1 4 4 4 5 5 7とかだったらcount[1] = 1, count[4] = 3, count[5] = 2, count[7] = 1
  int freq[N + 1]; // countの個数を表す配列 例えば上の例でいうとfreq[1] = 2, freq[2] = 1, freq[3] = 1
  for (i = 0; i <= N; i++) {
    count[i] = 0;
    freq[i] = 0;
  }

  // 配列の添字に入力された数字を入れてcountを「数字の個数」の配列にする
  for (i = 0; i < N; i++) {
    scanf("%d", &tmp);
    count[tmp]++;
  }

  // countの結果を添字にして足すことでfreqを「countの個数」の配列にする
  for (i = 0; i <= N; i++) {
    freq[count[i]]++;
  }

  // freqは同じ数字のボールの個数が何種類あるかの配列になっているので
  // 大きい方から順番に足していってKを超えたところで積和を取ればよい
  current_kind = 0;
  ans = 0;
  for (i = N; i > 0; i--) {
    if (current_kind >= K) {
      // 既に種類がK種類を超えてるときはそのまま足す
      ans += i * freq[i];
    } else if (current_kind + freq[i] > K) {
      // 今回、足そうとした時に超える場合は超えた分だけ足す
      ans += i * (current_kind + freq[i] - K);
    }
    current_kind += freq[i];
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

template <typename T>
T keta(T N){
  T counter = 1;
  while(N/10 > 0){
    N /= 10;
    counter ++;
  }
  return counter;
}

template <typename T>
T beki(T x, ll n){
  T res = 1;
  while(n > 0){
    if(n & 1) res *= x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  int ketaN = keta(N);

  vi keta575(10, 0);
  for(int i = 3; i <= 8; i++){
    int x = beki(3, i);
    x -= (beki(2, i) - 2) * 3;
    x -= 3;
    keta575.at(i) = x;
  }

  int res = 0;
  for(int i = 3; i <= ketaN-1; i++){
    res += keta575.at(i);
  }

  vi result(0);
  for(int i = 0; i <= ketaN-3; i++){
    for(int j = 0; i+j <= ketaN-3; j++){
      vi A = {7, 5, 3};
      for(int k = 0; k < i; k++){
        A.push_back(7);
      }
      for(int k = 0; k < j; k++){
        A.push_back(5);
      }
      for(int k = 0; k < ketaN-3 - i - j; k++){
        A.push_back(3);
      }
      sort(ALL(A));
      do{
        int num = 0;
        int x = 1;
        for(int k = 0; k < A.size(); k++){
          num += A.at(k) * x;
          x *= 10;
        }
        result.push_back(num);
      }while(next_permutation(ALL(A)));
    }
  }
  sort(ALL(result));
  int dist = distance(result.begin(), upper_bound(ALL(result), N));
  res += dist;
  cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#define ll long long
#define pii pair <int, int>
#define pll pair <long long, long long>
#define plxy pair <long long, pll>
#define INT_MAX 1e18
#define Keep_calm_You_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
ll fact[1000006],inv[1000006];
ll fp(ll base,ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}
ll n,k;
int main()
{
    Keep_calm_You_are_still_learning
    calcFacAndInv(1e5);
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
    {
        if(n-k+1>=i)
        {
            cout<<(((ncr(n-k+1,i))%mod)*((ncr(k-1,i-1))%mod))%mod<<endl;
        }
        else
        {
            cout<<0<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5120
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  const string  target = "ABC";
  int count = 0;
  int i = 0;
  while (i < N - 2) {
    string s = S.substr(i, 3);
    if (s == target) {
      count++;
      i += 3;
      continue;
    }
    i++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	bool flag=false;

	cin>>n;

	rep(i, 26){
		rep(j, 16){
			if(4*i+7*j==n){
				flag=true;
				break;
			}
		}
	}
	cout<<yn(flag)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    list<int> lis;
    for (int i=0; i<n; ++i) {
        string ope; int key;
        cin >> ope;
        if (ope == "insert") {
            cin >> key;
            lis.push_front(key);
        } else if (ope == "delete") {
            cin >> key;
            list<int>::iterator pos = find(lis.begin(), lis.end(), key);
            if (pos != lis.end()) {
                lis.erase(pos);
            }
        } else if (ope == "deleteFirst") {
            lis.pop_front();
        } else if (ope == "deleteLast") {
            lis.pop_back();
        }
    }

    for (list<int>::iterator it = lis.begin(); it != lis.end(); ++it) {
        cout << ((it == lis.begin()) ? "" : " ") << *it;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 32480
package main

import "fmt"

var s string

func main() {
	fmt.Scan(&s)
	n := len([]rune(s))
	digits := make([]int, n)
	for i, c := range s {
		digits[i] = int(c - '0')
	}

	ans := 0
	for bit := 0; bit < 1<<uint(n-1); bit++ {
		cursor := 0
		for i := 0; i < n-1; i++ {
			if bit&(1<<uint(i)) > 0 {
				ans += todecimal(digits[cursor : i+1])
				cursor = i + 1
			}
		}
		if cursor != n {
			ans += todecimal(digits[cursor:n])
		}
	}
	fmt.Println(ans)
}

func todecimal(ds []int) int {
	ans := ds[0]
	if len(ds) != 1 {
		for i := 1; i < len(ds); i++ {
			ans *= 10
			ans += ds[i]
		}
	}
	return ans
}


Measured memory_bytes: 512
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

x,y=map(int, input().split())
c=(prime_factorize(x))
d=(prime_factorize(y))
n = set(c) & set(d)
m=len(n)
print(m+1)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	int k, x; 
	cin >> k >> x; 
	int ans; 
	for(int i = x - k + 1; i <= x + k - 1; i ++)
	{
		ans = i; 
		cout << ans << " "; 
	}
	return 0; 
}

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

using namespace std;

int const maxn = 2e5 + 5;
int a[maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) x = (x^a[i]);
    for (int i = 1; i <= n; ++i) cout << (x^a[i]) << " ";
    return 0;
}



Measured memory_bytes: 4356
using System;
using System.Collections.Generic;

public class ABC136C {

    public struct Node {
        public string s;
        public int freq;
        public List<Node> child;
    }
    public struct Result {
        public Node root;
        public int ans;
    }
    public static Node Make(Node newNode, string term) {
        newNode.s = term;
        newNode.freq = 1;
        newNode.child = new List<Node>();
        newNode.child.Add(new Node());
        newNode.child.Add(new Node());
        return newNode;
    }
    public static Result Add(Node root, string term) {
        Result result = new Result();
        if (Smaller(term, root.s)) {
            if (root.child[0].s != null) {
                result = Add(root.child[0], term);
                root.child[0] = result.root;
                result.root = root;
                return result;
            } else {
                root.child[0] = Make(root.child[0], term);
                result.root = root;
                result.ans = 0;
                return result;
            }
        } else if (root.s == term) {
            root.freq++;
            result.root = root;
            result.ans = root.freq - 1;
            return result;
        } else {
            if (root.child[1].s != null) {
                result = Add(root.child[1], term);
                root.child[1] = result.root;
                result.root = root;
                return result;
            } else {
                root.child[1] = Make(root.child[1], term);
                result.root = root;
                result.ans = 0;
                return result;
            }
        }
    }
    public static void Main() {
        int N;
        long ans = 0;
        string term;
        Node root = new Node();
        Result result;

        N = int.Parse(Console.ReadLine());
        term = Console.ReadLine();
        term = MySort(term);
        root = Make(root, term);
        for (int i = 0; i < N - 1; i++) {
            term = Console.ReadLine();
            term = MySort(term);
            result = Add(root, term);
            root = result.root;
            ans += result.ans;
        }

        Console.WriteLine(ans);
    }
    public static bool Smaller(string term1, string term2) {
        bool ans = false;
        for (int i = 0; i < term1.Length; i++) {
            if (term1[i] == term2[i]) continue;
            else if (term1[i] < term2[i]) {
                ans = true;
                break;
            } else {
                break;
            }
        }
        return ans;
    }
    public static string MySort(string term) {
        string sort = "";
        List<char> list = new List<char>();
        for (int i = 0; i < term.Length; i++) {
            list.Add(term[i]);
        }
        list.Sort();
        for (int i = 0; i < term.Length; i++) {
            sort += list[i];
        }
        return sort;
    }
}


Measured memory_bytes: 40556
#include <stdio.h>

int main(void){
  
  char str[10];
  
  scanf("%s", str);
  
  if(str[0] >='a' && str[0] <= 'z'){
    printf("a\n");
  } else if (str[0] >='A' && str[0] <= 'Z') {
    printf("A\n");
  }  	 
  return 0;
}

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

int n, m, ans = 0;
map<int, int, greater<int>> dp;

int main() {
	cin >> n >> m;
	dp[0] = 0;
	for (int i = 0, w, v; i < n; ++i) {
		cin >> w >> v;
		for (auto &x : dp)
			if (x.first + w <= m)
				dp[x.first + w] = max(dp[x.first + w], dp[x.first] + v);
	}
	for (auto &x : dp)
		ans = max(ans, x.second);
	cout << ans << endl;
}


Measured memory_bytes: 3636
a=2,3,5
def f(n):
 if(m:=s.get(n))is None:s[n]=m=min([d*n]+[abs(p*k-n)*d+c+f(k)for p,c in zip(a,b)for k in(n//p,0--n//p)])
 return m
exec("n,*b,d=map(int,input().split());s={0:0,1:d};print(f(n));"*int(input()))

Measured memory_bytes: 10980
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;cin >> n;
  int k;cin >> k;
  vector<int> h(n);
  int count = 0;
  for(int i = 0;i < n;i++) cin >> h.at(i);

  for(int i = 0;i < n;i++){
    if(h.at(i) >= k){
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100100];

struct number{
    int value;
    int falg;
} b[100100];

bool cmp(number a,number b){
    return a.value < b.value;
}

int main(){
    std::ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n;i++)
        cin >> a[i];
    sort(a, a + n);
    for (int i = 0; i < m;i++){
        cin >> b[i].falg >> b[i].value;
    }
    sort(b, b + m,cmp);
    int prej = 0;
    for (int i = m - 1; i >= 0;i--){
        if(b[i].value>a[prej]){
            a[prej] = b[i].value;
            b[i].falg--;
            for (int j = prej+1; j < n;j++){
                if(a[j]<b[i].value&&b[i].falg){
                    a[j] = b[i].value;
                    b[i].falg--;
                }
                else{
                    prej = j;
                    break;
                }
            }
        }
        else
            break;
    }
    ll sum = 0;
    for (int i = 0; i < n;i++)
        sum += a[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 1792
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

LL gcd(LL a,LL b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

LL lcm(LL a,LL b)
{
	return a*b/gcd(a,b);
}
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	LL a,b;
	while(cin >> a >> b)
		cout << gcd(a,b) << ' ' << lcm(a,b) << endl;
	return 0;
}  

Measured memory_bytes: 1156
N = int(input())
A = list(map(int, input().split()))

ans = 1000
lastpay = -1
buy = True
stock = 0

buf = []
for i in range(N-1):
  if A[i+1]==A[i]:
    buf.append(0)
  elif A[i+1]>A[i]:
    buf.append(1)
  else:
    buf.append(-1)

for i in range(len(buf)):
  if buy:
    if i == 0 and buf[i]>0:
      buy = False
      dstock = ans//A[i]
      stock += dstock
      ans -= dstock*A[i]
      lastpay = dstock*A[i]
      #print(i,"buy")
    elif i>0 and buf[i]>0:
      buy = False
      dstock = ans//A[i]
      stock += dstock
      ans -= dstock*A[i]
      lastpay = dstock*A[i]
      #print(i, "buy")
    if i == N-2 and buf[i]>0:
       ans += stock*A[i+1]
        #print(i+1, "pay")
  else:
    if buf[i-1]>=0 and buf[i]<0:
      buy = True
      ans += stock*A[i]
      stock = 0
      #print(i, "pay")
    elif i == N-2 and buf[i]>=0:
      buy = True
      ans += stock*A[i+1]
      #print(i+1, "pay")
#print(buf)
print(ans)
    
    
    
  



Measured memory_bytes: 9228
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	ll n;
	cin>>n;
	string a,b,c;
	cin>>a>>b>>c;
	ll ans=0;
	rep(i,0,n){
		if(a[i]==b[i]&&b[i]==c[i])continue;
		else if(a[i]==b[i])ans++;
		else if(b[i]==c[i])ans++;
		else if(c[i]==a[i])ans++;
		else ans+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;

	cin >> N >> M;
	if (N == M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int>A(n+2);
    A[0] = A[n+1] = 0;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    
    ll  sum = 0;
    for(int i = 0; i <= n; i++){
        sum += abs(A[i] - A[i+1]);
    }
    for(int i = 1; i <= n; i++){
        int diff_1 = abs(A[i-1] - A[i]);
        int diff_2 = abs(A[i+1] - A[i]);
        int sum_num = abs(A[i-1] - A[i+1]);
        cout << sum - (diff_1 + diff_2) + sum_num << endl; 
    }
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>

using namespace std;
typedef long long LL;
const int maxn = 100005;

int ehead[maxn],ecnt;
struct edge {
	int u,v,next;
}edg[maxn<<1];
void add(int u,int v) {
	edg[++ecnt]=(edge){u,v,ehead[u]};
	ehead[u]=ecnt;
	edg[++ecnt]=(edge){v,u,ehead[v]};
	ehead[v]=ecnt;
}
int n,bit[maxn],f[maxn],ans;
void dfs(int u,int fa)
{
	int conf=0;
	for (int v,j=ehead[u];j;j=edg[j].next)
	if ((v=edg[j].v)!=fa) {
		dfs(v,u);conf|=bit[u]&bit[v];bit[u]|=bit[v];
	}
	while ((conf>>f[u])||(bit[u]>>f[u]&1)) ++f[u];
	bit[u]=(bit[u]>>f[u]<<f[u])|(1<<f[u]);
	ans=max(ans,f[u]);
}
int main()
{
	#ifdef Amberframe
		freopen("agc009d.in","r",stdin);
		freopen("agc009d.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int u,v,i=1;i<n;i++)
		scanf("%d %d",&u,&v),add(u,v);
	dfs(1,0);printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int a[N];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++) cout<<a[i]<<endl;
}


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

int main()
{
	int n;
	int count = 0;
	vector<int> result;

	while (cin >> n) {
		count = 0;
		for(int a=0;a<10;a++)
			for(int b=0;b<10;b++)
				for(int c=0;c<10;c++)
					for(int d=0;d<10;d++) 
						if(a+b+c+d == n)
							count++;
		result.push_back(count);
	}

	for(int j=0;j<result.size();j++)
		cout << result[j] << endl;

	return 0;
}

Measured memory_bytes: 1220
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
	n = int(input())
	s = input()
	k = int(input())
	tmp=''
	for i in range(n):
		if i == k-1:
			tmp = s[i]	
	ans = ''
	for c in s:
		if c != tmp:
			ans+='*'
		else:
			ans+=c
	print(ans)

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



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

typedef long long i64;
typedef pair<int, int> ii;
typedef pair<i64, i64> ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(a, x) memset(a, x, sizeof(a))
#define len(x) (x).size()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const double eps = 1e-9;
const double pi = acos(-1.0);
const int inf = 1e9;
const int maxn = 2e5+5;
const int mod = 1e9+7;

i64 n, d, a, b;
int ans;

int main() {
    fastIO();
    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
    	cin >> a >> b;
    	if (a*a+b*b <= d*d) ans++;
    }
    cout << ans << '\n';
    return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int s = 0;
    if(a >= k) {
        s += k;
        k = 0;

    } else {
        s += a;
        k -= a;

    }

    if(b >= k) {
        k = 0;

    } else {
        k -= b;

    }

    if(k >= 0) s -= k;
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 3656
function main()
  lines=readlines()
  N,M=map(x->parse(Int,x),split(shift!(lines)))
  A=zeros(Int,N)
  B=zeros(Int,N)
  for s=lines
    x,y=map(x->parse(Int,x),split(s))
    if x==1
      A[y]=1
    end
    if x==N
      B[y]=1
    end
    if y==1
      A[x]=1
    end
    if y==N
      B[x]=1
    end
  end
  for i=1:N
    if A[i]==B[i]==1
      println("POSSIBLE")
      exit()
    end
  end
  println("IMPOSSIBLE")
end
main()

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

using Oct=array<int,8>;
void rotateA(Oct& o){
    Oct tmp=o;
    for(int i=0;i<4;i++){
        o[i]=tmp[(i+1)%4];
        o[i+4]=tmp[(i+1)%4+4];
    }
}
void rotateB(Oct& oct){
    Oct tmp=oct;
    oct[0]=tmp[4];
    oct[1]=tmp[5];
    oct[2]=tmp[1];
    oct[3]=tmp[0];
    oct[4]=tmp[7];
    oct[5]=tmp[6];
    oct[6]=tmp[2];
    oct[7]=tmp[3];
}

bool check(Oct oct,set<Oct> &s){
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                if(s.count(oct)) return false;             
                rotateA(oct);
            }
            rotateB(oct);
        }
        rotateA(oct);
    }
    return true;
}
int dfs(int x,const vector<int>& v,set<Oct>& s,Oct& oct){
    if(x==8){
        assert(count(oct.begin(),oct.end(),-1)==0);
        if(!check(oct,s)) return 0;
        s.insert(oct);
        return 1;
    }
    int res=0;
    for(int i=0;i<oct.size();i++){
        if(oct[i]==-1){
            oct[i]=v[x];
            res+=dfs(x+1,v,s,oct);
            oct[i]=-1;
        }
    }
    return res;
}
int main(){
    vector<string> color(8);
    while(cin>>color[0]){
        for(int i=1;i<8;i++) cin>>color[i];
        map<string,int> mp;
        for(int i=0;i<8;i++) mp[color[i]]++;
        vector<int> v;
        int idx=0;
        for(auto &e:mp){
            for(int i=0;i<e.second;i++) v.push_back(idx);
            idx++;
        }
        set<Oct> s;
        Oct oct;
        fill(oct.begin(),oct.end(),-1);
        cout<<dfs(0,v,s,oct)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3296
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String A=sc.next();
        String B=sc.next();
        String C=sc.next();
        char a=A.charAt(A.length()-1);
        char b=B.charAt(0);
        char bb=B.charAt(B.length()-1);
        char c=C.charAt(0);
        if((a==b)&&(bb==c)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
        
     
    }


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

int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int w, a, b;
  cin >> w >> a >> b;
  int ans;
  if(a==b) ans = 0;
  else if(a<b) ans = b-a-w;
  else ans = a-b-w;
  if(ans<0) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;
vector<vector<bool>> used;
vector<ll> d;

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    char c;
    cin >> c;
    
    if (c - 'A' < 26)
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3652
N=int(input())
AB=[list(map(int,input().split())) for i in range(N-1)]
c=[[] for i in range(N)]
v=[0]*N
x=[0]*N
for i,j in AB:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
import sys
sys.setrecursionlimit(10**9)
def dfs(p):
    y=1 if x[p]==2 else 2
    for n in c[p]:
        if v[n]==0:
            v[n]=1
            x[n]=y
            dfs(n)
v[0]=x[0]=1
dfs(0)
def f(x,a,b):
    p,q,r=0,0,1
    for i in range(N):
        if x[i]==a and p*3+1<=N:
            x[i]=p*3+1
            p+=1
        elif x[i]==b and q*3+2<=N:
            x[i]=q*3+2
            q+=1
        else:
            x[i]=r*3
            r+=1
if x.count(1)<=N//3:
    f(x,2,2)
elif x.count(2)<=N//3:
    f(x,1,1)
else:
    f(x,1,2)
print(*x)

Measured memory_bytes: 219100
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(55);
const int LOG = (int)(20);

int n, col[N][N];
char s[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> s + 1;
		int len = strlen(s + 1);
		for(int j = 1; j <= len; j++)
			col[s[j] - 'a'][i]++;
	}
	for(int i = 0; i < 26; i++) {
		int opt = *min_element(col[i] + 1, col[i] + n + 1);
		for(int j = 1; j <= opt; j++)
			cout << (char)(i + 'a');
	}
}

Measured memory_bytes: 256
import math
import itertools

n = int(raw_input())

pos = list()
for i in range(0, n):
    x, y = map(int, raw_input().split(" "))
    pos.append((x, y))

all_permutations = list(itertools.permutations(pos))
sum = 0.0
for x in all_permutations:
    length = len(x)
    tmp = 0.0
    for s in range(1,length):
        x_1, y_1 = x[s - 1]
        x_2, y_2 = x[s]
        dist = math.sqrt((x_1 - x_2) ** 2 + (y_1 - y_2) ** 2)
        tmp = tmp + dist
    sum = sum + tmp

ans = sum / len(all_permutations)
print(ans)


Measured memory_bytes: 7924
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sumA += a[i];
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
            sumB += b[i];
        }
        int[] ans = new int[n];
        ans[0] = sumB + a[0];
        for (int i = 1; i < n; i++) {
            ans[i] = ans[i - 1] - b[i - 1] + a[i];
        }
        Arrays.sort(ans);
        System.out.println(ans[n - 1]);
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0;
  string s;
  cin >> s;
  if (s == "RRR")
    ans = 3;
  else if (s == "RRS" || s == "SRR")
    ans = 2;
  else if (s == "RSS" || s == "SSR" || s == "SRS" || s == "RSR")
    ans = 1;

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


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007*1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n;
	cin >> n;
	cout << n / 3 << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  ll ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++)
        ans += __gcd(__gcd(a, b), c);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,a,b; cin >> n >> a >> b;
	int ans = min(n*a,b);
	cout << ans << endl;
}




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

// ?
int main(){
    int n;
    cin >> n;
    vector<int> a(n-1), b(n-1), deg(n,0), v[n];
    for(int i = 0; i < n-1; i++){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
        deg[a[i]]++, deg[b[i]]++;
    }
    vector<int> c(n);
    for(int i = 0; i < n; i++)  cin >> c[i];
    sort(c.begin(), c.end());
    int pos = 0;
    queue<int> q;
    vector<int> w(n, 0);
    for(int i = 0; i < n; i++)  if(deg[i] == 1) q.push(i);
    while(!q.empty()){
        int p = q.front();  q.pop();
        if(w[p] != 0) continue;
        w[p] = c[pos++];
        for(int next : v[p]){
            deg[next]--;
            if(deg[next] == 1)  q.push(next);
        }
    }
    int ans = 0;
    for(int i = 0; i < n-1; i++){
        ans += min(w[a[i]], w[b[i]]);
    }
    cout << ans << endl;
    for(int i = 0; i < n; i++)  cout << w[i] << " \n"[i==n-1];
    return 0;
}

Measured memory_bytes: 1152
using System;
 
class MainClass{
  public static void Main(string[] args){
    int x = 0;
    string s = Console.ReadLine();
    string[] c = new string[4];
    c[0] = s.Substring(0,1);
    c[1] = s.Substring(1,1);
    c[2] = s.Substring(2,1);
    c[3] = s.Substring(3,1);
 
    for(int i = 0; i < 4; i++){
      if(c[i] == "+"){x++;}else{x--;}
    }
    Console.WriteLine(x);
  }
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//最大公約数
ll gcd(ll a,ll b){
    if(b == 0LL) return a;
    return gcd(b , a % b);
}

//最小公倍数
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;

}

//前後を比較
bool compare(int pos,vector<int>& a){
    if(a[pos] == a[pos + 1]) return true;
    else return false;
}

int main(){

    string s;
    cin >> s;
    bool f = false;
    for(int i=0;i < 3;i++) {
        if(s[i] == '7'){
            f = true;
            break;

        }
        
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    char c;
    cin >> c;
    if ('a' <= c && c <= 'z') cout << 'a' <<endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n, k, s;
	cin >> n >> k >> s;
	vector<ll>a;
	rep(i, k)a.push_back(s);
	rep(i, n - k)a.push_back((s == pow(10,9) ? 1 : s+1));
	rep(i, n)cout << a[i] << " ";
}

Measured memory_bytes: 2164
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");
        int[] atozArray = new int[26];
        int ans;
        char atoz;
        while (sc.hasNext()) {
            String str = sc.nextLine().toLowerCase();
            for (int i = 97; i <= 122; i++) {
                atozArray[i-97] += strCount(str, i);
            }
        }
        for (int i = 97; i <= 122; i++) {
            atoz = (char) i;
            System.out.println(atoz + " : " + atozArray[i-97]);
        }
//        pw.flush();
    }
    
    public static int strCount(String str, int ch) {
        int count = 0;
        for (char c : str.toCharArray()) {
            if (c == ch) count++;
        }
        return count;
    }
}


Measured memory_bytes: 26112