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

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        String[] tokens = in.nextLine().split(" ");

        int max = 0;
        int count = 0;
        int value = 0;
        for (int i = 0; i < n; i++) {
            value = Integer.parseInt(tokens[i]);
            if (value >= max) {
                count++;
                max = Math.max(max, value);
            }
        }
        out.println(count);
    }
}


Measured memory_bytes: 23124
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def main():
    #A, B, T = map(int, input().split())
    N = int(input())
    A_list = [int(a) for a in input().split()]

    left = [A_list[0]]
    for i in range(1, N):
        left.append(gcd(left[i-1], A_list[i]))
    right = [A_list[N-1]]
    for i in range(1, N):
        right.append(gcd(right[i-1], A_list[N-i-1]))

    max_val = 0
    for i in range(N):
        if i == 0:
            g = right[N-2]
        elif i == N-1:
            g = left[N-2]
        else:
            g = gcd(left[i-1], right[N-i-2])
        
        if g > max_val:
            max_val = g

    print(max_val)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15092
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		if(n==b&&b==c) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;
const ll MAX = 1000005;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  ll a, b; cin >> a >> b;
  set<ll> c, d;

  rep2(i, 2, sqrt(a)) {
    while (a % i == 0) {
      a /= i;
      c.em(i);
    }
  }

  if (a != 1) c.em(a);

  rep2(i, 2, sqrt(b)) {
    while (b % i == 0) {
      b /= i;
      d.em(i);
    }
  }

  if (b != 1) d.em(b);

  int ans = 0;
  for (auto e : c) if (d.count(e)) ++ans;

  cout << ans+1 << endl;
}

Measured memory_bytes: 3668
n = int(input())
s = input()
x = []
c = 0
for i in range(0,n):
  if(s[i] == "I"):
    c = c + 1
    x.append(c)
  else:
    c = c - 1
    x.append(c)

if(max(x) > 0):
  print(max(x))
else:
  print(0)
  

Measured memory_bytes: 38256
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if not arr:
        arr.append([n, 1])

    return arr


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())

    target_s = factorization(n)

    # 素因数1だけ処理対象外。
    if sum([i[1] for i in target_s]) == 1:
        if target_s[0][0] == 1:
            print(0)
        else:
            print(1)
        return

    # 少ない物から使っていく。
    cnt = 0
    for i in range(1, 1000):

        if not any([True if j[1] >= i else False for j in target_s]):
            break

        for target in target_s:
            if target[1] < i:
                continue
            target[1] -= i
            cnt += 1

    print(cnt)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """24"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """1"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """64"""
        output = """3"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """1000000007"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_5(self):
        test_input = """997764507000"""
        output = """7"""
        self.assertIO(test_input, output)

    def test_1original_1(self):
        test_input = """108"""
        output = """3"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 77864
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
    
    long long n, k, q;
    std::cin >> n >> k >> q;

    std::vector<long long> score(n, 0);

    for(long long i = 0; i < q; i++){
        size_t a;
        std::cin >> a;
        score.at(a - 1)++;
    }

    for(const auto& e : score){
        if(k - (q - e) > 0){
            std::cout << "Yes" << std::endl;
        }else{
            std::cout << "No" << std::endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
start = time.time()
# N = list(map(int, input()))[::-1]
N = int(input())
A, B = map(int, input().split())

for i in range(A, B+1):
    if i % N == 0:
        print('OK')
        exit()
else:
    print('NG')


Measured memory_bytes: 65028
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pr printf
#define P push
#define PB push_back
#define F front
#define T top
#define MP make_pair
#define Fi first
#define Se second
using namespace std;
inline long long gcd(long long a,long long b){return b==0?a:gcd(b,a%b);}
inline long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
inline void read(long long &x){
	char ch;
	do ch=getchar();while(ch<48||ch>57);
	x=0;while(ch<=57&&ch>=48){x=x*10+ch-48;ch=getchar();}
}
inline void read(int &x){
	char ch;
	do ch=getchar();while(ch<48||ch>57);
	x=0;while(ch<=57&&ch>=48){x=x*10+ch-48;ch=getchar();}
}
int i,j,k,n,m;
int a,b,c;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d/%d/%d",&a,&b,&c);
	if(a<2019){cout<<"Heisei";return 0;}
	if(a>2019){cout<<"TBD";return 0;}
	if(b<4){cout<<"Heisei";return 0;}
	if(b>4){cout<<"TBD";return 0;}
	if(c<=30){cout<<"Heisei";return 0;}
	if(c>30){cout<<"TBD";return 0;}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int a,b,c,i,n;
        for (i=0,scanf("%d%d",&n,&a); i<n && scanf("%d",&b);i++){
        while (b) {
                c = b;
                b =a%b;
                a = c;
                }
        }
        printf("%d",a);
        return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n, Nmax, Dmax;

    void run(){
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n==0) break;
	    Nmax = -1; Dmax = 0;
	    for(int i=0; i<n; i++){
		int n = sc.nextInt();
		int d = sc.nextInt()+sc.nextInt();
		if(Dmax<d){
		    Nmax = n;
		    Dmax = d;
		}
	    }

	    System.out.println(Nmax+" "+Dmax);
	}
    }
}

Measured memory_bytes: 157728
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
  h, w = MAP()
  a = [list(input()) for _ in range(h)]
  g = []
  r = []
  for i in range(h):
    for j in range(w):
      if a[i][j] == "#":
        g.append(i)
        r.append(j)
  g = set(g)
  r = set(r)
  #print(g)
  #print(r)
  for i in g:
    for j in r:
      print(a[i][j], end='')
    print()

if  __name__=='__main__':
    main()


Measured memory_bytes: 6788
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;

	//n頂点m枝に対して隣接リストをつくる。
	int n, m;
	cin >> n >> m;
	int u, v;
	//vector< vector <int> > ls(n); //0-origin
	vector< vector <int> > ls(n+1); //1-origin
	REP(i, m){ 
		cin >> u >> v; 
		ls[u].push_back(v); 
		ls[v].push_back(u); //有向グラフならコメントアウトせよ
	}
	//
	
	//BFS
	bool ch[n+1] = {};
	queue<int> q;
	REP1(i, n){
		if(!ch[i]){
			q.push(i); //最初に入れるべきものを入れる
			tmp = 0;
			while(!q.empty()){
				int now = q.front();
				q.pop();
				if(!ch[now]){ //何かするならここ？
					ch[now] = true;
					tmp++;
					REP(j, (int)ls[now].size()){
						if(!ch[ls[now][j]]) q.push(ls[now][j]);
					}
				}
			}
			ans = max(ans, tmp);
		}
	}
	//
	
	cout << ans << endl;
}

Measured memory_bytes: 14940
n = int(input())
A = list(map(int, input().split()))
A.sort()

ans = A.pop()
n -= 2

while n > 0:
    if n >= 2:
        ans += A.pop() * 2
        n -= 2
    elif n == 1:
        ans += A.pop()
        n -= 1

print(ans)

Measured memory_bytes: 94192
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;


using namespace std;

vector<int> tovec(int h,int w){
  vector<int> v(3);
  v[0] = (h*h)+(w*w);
  v[1] = h;
  v[2] = w;
  return v;
}

int main(){

  vector< vector<int> > tbl;

  for(int i=1;i<151;i++){
    for(int j=i+1;j<151;j++){
      tbl.push_back(tovec(i,j));
    }
  }

  sort(tbl.begin(),tbl.end());
  

 // rep(i,tbl.size())  cout << tbl[i][0] << " " << tbl[i][1] << " " << tbl[i][2] << endl;



  while(1){
    int h,w;
    cin >> h >> w;
    if(h==0&&w==0) break;
    
    vector<int> v = *upper_bound(tbl.begin(),tbl.end(),tovec(h,w));
    
    cout << v[1] << " " << v[2] << endl;

  }

}

Measured memory_bytes: 1800
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll p2[200005];
ll p5[200005];
ll cnt[60][60];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    rep(_,n){
        string s;
        cin >> s;
        ll x = 0;
        bool f = false;
        int rest = 9;
        for(int i=0;i<s.size();i++){
            if(s[i] != '.'){
                x = x * 10 + (s[i] - '0');
                if(f)rest--;
            }else{
                f = true;
            }
        }
        rep(i,rest) x *= 10;
        while(x%2==0)x/=2,p2[_]++;
        while(x%5==0)x/=5,p5[_]++;
    }
    for(int i=0;i<n;i++){
        cnt[p2[i]][p5[i]]++;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll need2 = max(18 - p2[i],0LL);
        ll need5 = max(18 - p5[i],0LL);
        for(int n2 = need2;n2<60;n2++){
            for(int n5 = need5;n5<60;n5++){
                ans += cnt[n2][n5];
            }
        }
        if(need2 <= p2[i] && need5 <= p5[i])ans--;
    }
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  long long n; cin>>n;
  long long mi = 1LL<<60;
  rep(i, 5) {
    long long t; cin>>t;
    mi = min(mi, t);
  }
  long long a = n / mi + (n % mi != 0);
  print(a + 4);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int D = 1000;
  for(int i = 0; i<n-2;i++){
    int num = (s.at(i) - '0') *100 + (s.at(i+1) - '0')*10 + (s.at(i+2) - '0');
    int d = max(num,753) -min(num,753);
    D = min(d,D);
  }
    cout << D;
    
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define EPS 0.001

int main(void){
    unsigned long long A; cin >> A;
    double B; cin >> B;
    long long Bh = B * 100 + EPS;
    unsigned long long C = (A * Bh) / 100;
    cout << C << endl;
    return 0;
}

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

int main() {
    string S, top;
    cin >> S;
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int type;
        cin >> type;
        if (type == 1) {
            swap(top, S);
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                top += c;
            } else {
                S += c;
            }
        }
    }
    reverse(top.begin(), top.end());
    string answer = top + S;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string solve(string s)
{
	char table[6][6]={
		"abcde",
		"fghij",
		"klmno",
		"pqrst",
		"uvwxy",
		"z.?! ",
	};
	if(s.size()&1){
		return "NA";
	}
	else{
		string res;
		for(int k=0;k<s.size();k+=2){
			int i=s[k]-'1';
			int j=s[k+1]-'1';
			if(i<0 || 6<=i || j<0 || 5<=j)
				return "NA";
			res+=table[i][j];
		}
		return res;
	}
}

int main()
{
	for(string s;getline(cin,s);)
		cout<<solve(s)<<endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9 + 7;
int quickpow(int m, int p)
{
    int res = 1;
    while (p) {
        if (p & 1)
            res = res * m % mod;
        m = m * m % mod;
        p >>= 1;
    }
    return res;
}
const int maxn = 2005;
int a[maxn];
signed main()
{
    int n, k;
    scanf("%I64d%I64d", &n, &k);
    for (int i = 1; i <= n; i++)
        scanf("%I64d", &a[i]);
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++)
            if (a[i] < a[j])
                cnt++;
    }
    int ans = cnt * k % mod;
    cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++)
            if (a[j] > a[i])
                cnt++;
    }
    ans += cnt * k % mod * (k - 1) % mod * quickpow(2, mod - 2) % mod;
    ans %= mod;
    printf("%I64d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;
 
 
ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}
 
ll intlog(double base, double x) {
	return (ll)(log(x) / log(base));
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
	// int t ;
	// cin >> t;
	// while (t--) {
	int x ;
	cin >> x ;
	for (int k = 1 ;  ; k++) {
		if (k * x % 360 == 0) {
			cout << k << "\n";
			return 0 ;
		}
	}
 
 
 
	// }
 
	// return 0;
}

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

int main() {
  std::string s, t;
  std::cin >> s >> t;
  int count = 0;
  int len = s.length();
  for (int i = 0; i < len; ++i) {
    if (s[i] != t[i]) {
      ++count;
    }
  }
  std::cout << count << std::endl;
  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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


int main(){
	
	int a, b, c;cin >> a >> b >> c;
	cout << min(c, b/a) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

bool anag(string s, string t){
  int cnts[26] = {};
  int cntt[26] = {};
  for(int i = 0; i < 10; i++) cnts[(int)(s[i] - 'a')]++;
  for(int i = 0; i < 10; i++) cntt[(int)(t[i] - 'a')]++;

  for(int i = 0; i < 26; i++){
    if(cnts[i] != cntt[i]){
      return false;
    }
  }

  return true;
}

int main(){
  int N;
  cin >> N;
  string s[N];
  for(int i = 0; i < N; i++) cin >> s[i];

  for(int i = 0; i < N; i++){
    char c[10];
    for(int j = 0; j < 10; j++) c[j] = s[i][j];
    sort(c, c + 10);
    for(int j = 0; j < 10; j++) s[i][j] = c[j];
  }

  sort(s, s + N);
  /*for(int i = 0; i < N; i++){
    cout << s[i] << endl;
  }*/

  ll cnt = 1;
  ll ans = 0;
  for(int i = 1; i < N; i++){
    if(s[i - 1] == s[i]) cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;

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


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  vl div_a(0);
  ll a,b;
  cin>>a>>b;
  if(a>b){
      swap(a,b);
  }
  for(ll i=1;i*i<=a;i++){
    if(a%i==0){
        div_a.pb(i);
        if(i!=a/i){
            div_a.pb(a/i);
        }
    }
  }
  vl co(0);
  for(ll i=1;i*i<=b;i++){
      if(b%i==0){
          rep(j,sz(div_a)){
              if(div_a[j]==i){
                  co.pb(i);
              }
          }
          if(i!=b/i){
            rep(j,sz(div_a)){
                if(div_a[j]==b/i){
                  co.pb(b/i);
              }
            }
          }
      }
  }
  ll size=sz(co);
  ll ans=0;
  /*for (int tmp = 0; tmp < (1 << 22); tmp++) {
  bitset<22> s(tmp);
  bool OK=true;
  vl z(0);
  ll sum=0;
  rep(i,sz(co)){
      if(s[i]){
          z.pb(co[i]);
          sum++;
          rep(j,sz(z)-1){
              if(gcd(z[j],co[i])!=1){
                  OK=false;
                  j=INF;
                  i=INF;
              }
          }
      }
  }
  if(OK){
      chmax(ans,sum);
  }
}*/
  rep(i,sz(co)){
      bool sosuu=true;
      for(ll j=2;j*j<=co[i];j++){
          if(co[i]%j==0){
              sosuu=false;
          }
      }
      if(sosuu){
          ans++;
      }
  }
  print(ans);
}



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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = 1e10;
int main() {
	cin.sync_with_stdio(false);
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;
	int x1 = 0, y1 = 0;
	bool flag = false, f = true;
	int cnt = 0;
	vector<int>tate, yoko;
	s.push_back('T');
	rep(i, s.size()) {
		if (s[i] == 'T') {
			if (f) {
				x -= cnt;
				f = false;
			}
			else if (!flag) yoko.push_back(cnt);
			else tate.push_back(cnt);
			flag = !flag;
			cnt = 0;
		}
		else cnt++;
	}
	sort(tate.begin(), tate.end(), greater<int>());
	sort(yoko.begin(), yoko.end(), greater<int>());

	rep(i, yoko.size()) {
		if (abs(x+yoko[i])>abs(x-yoko[i]))x -= yoko[i];
		else x += yoko[i];
	}
	rep(i, tate.size()) {
		if (abs(y + tate[i])>abs(y - tate[i]))y -= tate[i];
		else y += tate[i];
	}


	if (x == 0&&y == 0) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  map<ll,ll> m;
  m[a]++;
  m[b]++;
  m[c]++;
  if(m.size()==2)cY;
  else cN;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)

#define X(x) ((x) & ((1 << 30) - 1))
#define Y(x) ((x) >> 30)
#define XY(x, y) (((y) << 30) | (x))


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long H, W, a, b;

  int N;

  std::cin >> H >> W >> N;

  std::map<long long, uint8_t> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> a >> b;

    a --;
    b --;

    for (int i = 0; i < 3; i ++) {
      long long aa = a - i;

      if (0 <= aa && aa < H - 2)
        for (int j = 0; j < 3; j ++) {
          long long bb = b - j;
        
          if (0 <= bb && bb < W - 2)
            map[XY(bb, aa)] ++;
        }
    }
  }

  long long x[10] = {0};

  for (const auto& kv : map)
    x[kv.second] ++;

  x[0] = (H - 2) * (W - 2) - map.size();

  for (int i = 0; i < 10; i ++)
    std::cout << x[i] << std::endl;

  return 0;
}


Measured memory_bytes: 56576
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define mp make_pair
#define pb push_back
using namespace std; 
typedef long long ll; 
vector<int> app[35], vec; 
int cnt[35], n, tp[200005], opp[200005]; 
char str[200005]; 
ll sum[200005]; 
inline void modify(int pos, int x)
{
	for (; pos <= n; pos += pos & -pos)
		sum[pos] += x; 
}
inline ll query(int pos)
{
	ll res = 0; 
	for (; pos; pos -= pos & -pos)
		res += sum[pos]; 
	return res; 
}
int main()
{
	// freopen("ARC088-E.in", "r", stdin); 
	scanf("%s", str); 
	n = strlen(str); 
	for (int i = 0; i < n; i++)
		app[str[i] - 'a'].pb(i); 
	bool odd = false; 
	for (int i = 0; i < 26; i++)
	{
		if (app[i].size() & 1)
		{
			if (odd)
			{
				puts("-1");
				return 0; 
			}
			odd = true; 
		}
	}
	for (int i = 0; i < n; i++)
	{
		int c = str[i] - 'a'; 
		if (cnt[c] < app[c].size() / 2)
			tp[i] = 0; 
		else if ((app[c].size() & 1) && (cnt[c] == app[c].size() / 2))
			tp[i] = 2; 
		else
		{
			tp[i] = 1; 
			opp[i] = app[c][app[c].size() - cnt[c] - 1]; 
		}
		cnt[c]++; 
	}
	int zero = 0; 
	ll ans = 0; 
	for (int i = 0; i < n; i++)
	{
		if (tp[i] == 1)
			vec.pb(opp[i] + 1); 
		else if (!tp[i])
		{
			zero++; 
			ans += vec.size(); 
		}
		else
			ans += vec.size() + (n - 1 >> 1) - zero; 
	}
	for (int i = 0; i < vec.size(); i++)
	{
		ans += query(vec[i]); 
		modify(vec[i], 1); 
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 4216
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int a, b; cin >> a >> b;
    if(a + b == 15) {
        cout << "+" << endl;
    } else if(a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
  int N, M = 1e9+7;
  cin >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> cnt(60);
  for (auto a : A) {
    int i = 0;
    while (a) cnt.at(i) += a % 2, a /= 2, i++;
  }
  long ans = 0;
  for (int i = 0; i < 60; i++) {
    ans += (1L << i) % M * cnt.at(i) % M * (N - cnt.at(i)) % M;
  }
  cout << ans % M << "\n";
}

Measured memory_bytes: 5572
import sys

def solve(n, d):
    d_sorted = sorted(d, reverse=True)
    for i in range(n):
        print d_sorted[0] if d[i] != d_sorted[0] else d_sorted[1]


if __name__ == '__main__':

    n = int(sys.stdin.readline().strip())
    d = []
    for i in range(n):
        d.append(int(sys.stdin.readline().strip()))
    solve(n, d)

Measured memory_bytes: 18280
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    cout << setprecision(16);
    int n; cin >> n;
    double ans = 0;
    rep(i,n){
        double d; string s; cin >> d >> s;
        if(s == "JPY") ans += d;
        else ans += d*380000;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define vl vector<ll>
#define pll pair<ll,ll>
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i= 0;i < a;i++)
#define rep1(i,a) for(ll i= 1;i < a;i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define pb push_back
#define sz(v) v.size()
#define all(a) a.begin(), a.end()
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007
#define el "\n"
const ll INF = 2e9+5;
  
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);}
ll isPrime(ll n){if(n<=3) return 1;if(n%2==0||n%3==0) return 0;
for(ll j=5;j*j<=n;j+=6){if(n%j == 0||n%(j+2) == 0) return 0;}return 1;}
 
using namespace std;
void solve(){
   ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n)cin>>a[i]>>b[i]>>c[i];
  // rep(i,n)cin>>b[i];
  // rep(i,n)cin>>c[i];
  ll dp[n][3];
  dp[0][0] = a[0];dp[0][1] = b[0];dp[0][2] = c[0];
  // cout<<dp[i][0]<<" "<<dp[i][0]<<" "<<dp[0][0]<<" ";
  foi(i,1,n){
    dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2] = max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
    // cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<" ";
}
  cout<<max3(dp[n-1][0],dp[n-1][1],dp[n-1][2])<<el;
}
 
int main() {
   #ifndef ONLINE_JUDGE
      freopen("input.txt", "r" , stdin);
      freopen("output.txt", "w" , stdout);
   #endif
   ios::sync_with_stdio(0); 
   cin.tie(0); cout.tie(0);   
   ll t;
   // cin>>t;
   t = 1;
   ll tc=0;
   while(tc++<t){
      // cout<<"Case #"<<tc<<": ";
      solve();
   }
   cerr<<"Time taken : "<<(double)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}

Measured memory_bytes: 7940
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
long long gcd(long long  a,long long b){
    long long tmp,r;
    long long c=a;
    long long d=b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    c/=b;
    return c*d;
}

int main(){
    int n;
    cin>>n;
    long long  cl[101];
    for(int i=0; i<n; i++){
        cin>>cl[i];
    }
    long long ans=cl[0];
    for(int i=1; i<n; i++){
        ans=gcd(ans,cl[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n,i;
  bool a=0,b=0;
  cin>>n;
  for(i=9;i>=1&&a==0;i--){
    if(n%i==0){
      n=n/i;
      a=1;
    }
  }
  a=0;
  for(i=9;i>=1&&a==0;i--){
    if(n%i==0){
      n=n/i;
      a=1;
    }
  }
    if(n==1)
      cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
      return 0;
    }
    
    


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

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    map<int, int> mp;
    int max_num = a[n-1], max_diff = -INF;
    for(int i = n-2; i >= 0; i--){
        mp[max_num - a[i]]++;
        max_diff = max(max_diff, max_num - a[i]);
        max_num = max(max_num, a[i]);
    }
    
    cout << mp[max_diff] << endl;

}

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

int main(){
    int A, B, K;
    int cnt=0;
    scanf("%d %d %d", &A, &B, &K);
    
    for(int i = 100;i >=1; i--) {
        if(A%i == 0 && B%i == 0) {
            cnt++;
            if (cnt == K) {
                printf("%d\n", i);
                break;
            }
        } 
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>

#include <algorithm>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <string>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF 1 << 29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  if (!v.empty()) {
    out << '[';
    copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

/* template end */

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

  int n, i;
  cin >> n >> i;

#if DEBUG
  cout << "** RESULT **" << endl; // debug
#endif

  cout << (n - i + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;


int main(void) {
	ll n, a, b; cin >> n >> a >> b;
	ll sum = a + b;
	ll x = n / sum;
	ll y = n % sum;
	if (y <= a) {
		cout << x*a + y<<endl;
	}
	else {
		cout << x*a + a << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll h, w, n, a[10001], cmap[101][101];

int main() {
	cin >> h >> w >> n;
	for(ll i = 1; i <= n; i++){cin >> a[i];}
	
	ll c = 1;
	for(ll i = 1; i <= h; i++){
		for(ll j = 1; j <= w; j++){
			if(i%2 == 1){cmap[i][j] = c;}
			else{cmap[i][w-(j-1)] = c;}
			a[c]--;
			if(a[c] == 0){c++;}
		}
	}
	
	for(ll i = 1; i <= h; i++){
		for(ll j = 1; j <= w; j++){
			if(j != w){cout << cmap[i][j] << " ";}
			else{cout << cmap[i][j] << endl;}
		}
	}
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define SIZE_MAX 101

int h, w;
char field[SIZE_MAX][SIZE_MAX];

void fill(int x, int y, char target) {
  if (x < 0 || h <= x || y < 0 || w <= y) return;
  if (field[x][y] != target) return;

  field[x][y] = ' ';

  fill(x - 1, y, target);
  fill(x + 1, y, target);
  fill(x, y - 1, target);
  fill(x, y + 1, target);
}

int solve() {
  int result = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (field[i][j] == ' ') continue;
      fill(i, j, field[i][j]);
      result++;
    }
  }
  return result;
}

int main() {
  while (true) {
    scanf("%d %d", &h, &w);
    if (h == 0 && w == 0) break;

    for (int i = 0; i < h; i++) {
      scanf("%s", field[i]);
    }
    int answer = solve();
    printf("%d\n", answer);
  }
  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    double a, b, h, m;
    double x1, x2, y1, y2, t1, t2;
    cin >> a >> b >> h >> m;
    t1 = M_PI * 2 * (h / 12 + m / 60 / 12);
    t2 = M_PI * 2 * m / 60;
    x1 = a * cos(t1);
    y1 = a * sin(t1);
    x2 = b * cos(t2);
    y2 = b * sin(t2);
    double ans = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}

Measured memory_bytes: 4128
def is_unique(seq):
    return len(seq) == len(set(seq))

flag = "Yes"
N = int(input())
word = input()
list = [word]
for i in range(N - 1):
    word = input()
    if list[i][len(list[i]) - 1] != word[0]:
        flag = "No"
        break
    list.append(word)
if not is_unique(list):
    flag = "No"
print(flag)

Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import bisect
import math
import fractions
import sys
import copy


def L(): return sys.stdin.readline().split()


def I(): return int(sys.stdin.readline().rstrip())


def SL(): return list(sys.stdin.readline().rstrip())


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def IR(n): return [I() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def LIR1(n): return [LI1() for _ in range(n)]


def SR(n): return [SL() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def LR(n): return [L() for _ in range(n)]


def perm(n, r): return math.factorial(n) // math.factorial(r)


def comb(n, r): return math.factorial(
    n) // (math.factorial(r) * math.factorial(n-r))


alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")


def main():
    X, K, D = LI()

    if abs(X) >= K * D:
        if X < 0:
            print(abs(X + K * D))
        else:
            print(abs(X - K * D))
    else:
        t = abs(X) // D
        rest = K - t
        if rest % 2 == 0:
            print(abs(X) % D)
        else:
            print(abs(abs(X) % D - D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 72488
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

struct frac {
	ll up;
	ll down;
};

ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}

frac operator + (frac a, frac b) {
	frac c;
	c.down = a.down * b.down;
	c.up = a.up * b.down + a.down * b.up;
	ll g = gcd(c.down, c.up);
	c.down /= g;
	c.up /= g;
	return c;
}

frac operator - (frac a, frac b) {
	frac c;
	c.down = a.down * b.down;
	c.up = a.up * b.down - a.down * b.up;
	ll g = gcd(abs(c.down), abs(c.up));
	c.down /= g;
	c.up /= g;
	return c;
}

frac make(ll a, ll b) {
	frac c;
	c.up = a;
	c.down = b;
	ll g = gcd(abs(c.down), abs(c.up));
	c.down /= g;
	c.up /= g;
	return c;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    frac now = make(4, N);
    for (int h = 1;h <= 3500;h++) {
    	for (int n = h;n <= 3500;n++) {
    		frac c = make(1, h) + make(1, n);
    		frac d = now - c;
    		if (d.up == 1) {
    			cout << h << ' ' << n << ' ' << d.down << endl;
    			return 0;
    		}
    	}
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int selectionSort(int A[], int N)
{
  int minj = 0, i, j, tmp, count = 0;

  for(i = 0; i < N - 1; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }

    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;

    if(minj != i){      //iとminjが異なり実際に交換が行われた回数
      count++;
    }
  }
  return count;
}

int main(void)
{
  int i, a[100], n, count = 0;

  scanf("%d", &n);

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

  count = selectionSort(a, n);

  for(i = 0; i < n; i++){
    if(i) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2088
import java.util.Scanner;
     
class Main{
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        //sc.nextLine();
        sc.close();
        
        
        //for(int i = 0; i < N; i++) {
        //	String tmp = s[i];
        //	n[i] = Integer.parseInt(tmp);
        //}
        
        System.out.println(sum(S));    
    }
    
    public static int sum(String S) {
        String s[] = S.split(" ");
        int N = Integer.parseInt(s[0]);
        int A = Integer.parseInt(s[1]);
        int B = Integer.parseInt(s[2]);
        String[] ss = new String[N+1];
        int a = 0;
        int sum = 0;
        
        
        for(int i = 1; i <= N; i++){
            ss[i] = String.valueOf(i);
        }

        for(int j = 1; j <= N; j++ ){
            String[] tmp = ss[j].split("");
            for(int k = 0; k < tmp.length; k++){
                a += Integer.parseInt(tmp[k]);
            }  
            if( a >= A && a <= B){
                sum += Integer.parseInt(ss[j]);
            }
            a = 0;
        }
		return sum;
    }
}

Measured memory_bytes: 35412
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int main(){
	int a;
	cin>>a;
	cout<<(a+a*a+a*a*a)<<endl;
	return 0;
}


Measured memory_bytes: 3620