akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int num = sc.nextInt();
		StringBuilder sb = new StringBuilder(sc.next());
		char ch = sb.charAt(sc.nextInt()-1);

		for(int i=0;i<num;i++)
			if(sb.charAt(i) != ch)
				sb.setCharAt(i,'*');

		sc.close();
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 22740
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
using namespace std;

int main(){
    int N, Q;
    int B, C;
    int num_list[100001] ={};
    long int sum = 0;

    cin >> N;
    for(int i = 0;i < N; i++){
        int input;
        cin >> input;
        num_list[input] = num_list[input]+ 1;
        sum += input;
    }
    //cout << sum <<endl;    
    cin >> Q;
    for(int i = 0; i< Q; i++){
        cin >> B>> C;
        //cout << B<<" "<<C <<endl;  
        sum = sum + (C-B)*num_list[B];
        num_list[C] = num_list[C] + num_list[B];
        num_list[B] = 0;
        cout << sum <<endl;  
    }
    
    return 0;
}

Measured memory_bytes: 4036
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int max = 0;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (n[i] >= max) {
                ans++;
                max = n[i];
            }
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 28500
//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 2e3 + 5;
const ll INF = 1e18;
const ll MOD = 924844033;

int fct[maxN], arumin[2 * maxN][maxN];

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	fct[0] = 1;
	for (int i = 1; i < maxN; i++)
		fct[i] = (1ll * i * fct[i - 1]) % MOD;
	int n, k; scanf("%d%d", &n, &k);
	int q = n / k, r = n % k;
	arumin[0][0] = 1;
	int v = 0;
	for (int x = 0; x < 2 * k; x++){
		int l = q + (x < 2 * r);
		for (int i = 1; i <= l; i++)
			for (int j = 0; j <= n; j++){
				arumin[v + i][j] = arumin[v + i - 1][j];
				if (i > 1 && j > 0)
					arumin[v + i][j] += arumin[v + i - 2][j - 1];
				arumin[v + i][j] %= MOD;
			}
		v += l;
	}
	int res = 0;
	for (int i = 0; i <= n; i++)
		res = (0ll + res + MOD + 1ll * (1 - 2 * (i & 1)) * arumin[v][i] * fct[n - i] % MOD) % MOD;
	printf("%d\n", res);
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 



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

int main() {
    int n;
    cin >> n;
    int nums[n];
    for(auto i = 0; i < n; ++i){
        cin >> nums[i];
    }
    int safe = 0;
    int find = 1;
    for(auto &x: nums) {
        if(x == find){
            safe++;
            find++;
        }
    }
    if(safe){
        cout << n-safe << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 4360
# your code goes here
#graph
#????????????????¨?????????¨
n=int(input())
L=[]
for i in range(n):
    L.append([])
    for j in range(n):
        L[i].append("0")
#rint(L)
for i in range(n):
    v=[int(i) for i in input().split()]
#    print(v)
    for j in range(2,2+v[1]):
        L[v[0]-1][v[j]-1]="1"#??????????????????1????????????i???i-1
#        print(L)
     #   L[v[j]-1][v[0]-1]="1"
for i in range(n):
    print(" ".join(L[i]))

Measured memory_bytes: 7852
//   PIGMEISTER™   //

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

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mi map<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define pi pair<ll,ll>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 200005
ll powah(ll, ll);

int main()
{
    jaldi;
    
    ll n, k;
    cin >> k >> n;
    ll a[n];
    sidha (i, 0, n) cin >> a[i];
    ll m = k - a[n-1] + a[0];
    sidha (i, 0, n-1)
        m = max(m, a[i+1] - a[i]);
    cout << k - m << endl;
    
    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1; x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res*x) % mod; 
        y = y>>1; x = (x*x) % mod; } 
    return res; 
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define pb push_back
#define mp make_pair
#define pie 3.141592653589793238
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/////////////////////////////////////////////////////////////////////
const ll mod = 1e9 + 7;
const int N = 1e6 + 9;
ll a[N], n;
vector <ll> v[N];
ll modexp(ll a, ll n)
{
    ll r = 1;
    while(n){
        if(n & 1)
            r = (r * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return r;
}
bool cmp(const pair<double, ll> &a, const pair<double, int> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}
ll solve(ll sum, ll k, ll ans)
{
    for(int i = 1; i < n; i ++)
    {
        sum += a[i];//cout << sum << " ";
        if(k == 1)
        {
            if(sum >= 0){
                ans += sum + 1;
                sum = -1;
            }
        }
        else
        {
            if(sum <= 0){
                ans += (-1 * sum) + 1;
                sum = 1;
            }
        }
        if(k == 0) k = 1;
        else k = 0;
       // cout << k << endl;
    }
    return ans;
}
int main()
{
    fast;
    ll ans1 = 0, ans2 = 0;
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
    }
    ll sum1 = a[0];
    if(sum1 <= 0){
        ans1 += (-1 * sum1) + 1;
        sum1 = 1;
    }
    ll p = solve(sum1, 1, ans1);
    ll sum2 = a[0];
    if(sum2 >= 0){
        ans2 += sum2 + 1;
        sum2 = -1;
    }
    ll pp = solve(sum2, 0, ans2);
  //  cout << p << " " << pp << endl;
    cout << min(p, pp) << endl;

    return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

bool d[10];

int n,k;
int ans=INF;

void dfs(int a, int keta){
  if(keta==0 || keta==1) {
    if(a>=n)chmin(ans,a);
    if(keta == 0) return;
  }
  keta--;
  rep(i,10){
    if(d[i]) dfs(a*10+i,keta);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>k;
  rep(i,10) d[i]=true;
  rep(i,k){
    int a; cin>>a;
    d[a]=false;
  }
  int m=n;
  int keta=0;
  while(m){
    m/=10;
    keta++;
  }
  reps(i,9) if(d[i]) dfs(i,keta);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
int s[310][310],n,m;
char sa[310][310],sb[310][310];
int get(int x,int y){
	if(x<=0){
		y+=1-x;
		x=1;
	}
	return y<=m?s[x][y]:0;
}
ll count(){
	int i,j,k,d;
	ll res;
	memset(s,0,sizeof(s));
	for(i=n;i>0;i--){
		for(j=m;j>0;j--){
			s[i][j]=s[i+1][j+1]+(sa[i][j]=='#');
		}
	}
	res=0;
	for(i=1;i<=n;i++){
		for(j=0;i+j<=n&&1+j<=m;j++){
			if(sa[i+j][1+j]=='.')continue;
			for(k=j+1;i+k<=n&&1+k<=m;k++){
				if(sa[i+k][1+k]=='.')continue;
				d=k-j;
				res+=get(i+j-d,1+j+d)-get(i+j,1+j+d*2);	
			}
		}
	}
	for(i=2;i<=m;i++){
		for(j=0;1+j<=n&&i+j<=m;j++){
			if(sa[1+j][i+j]=='.')continue;
			for(k=j+1;1+k<=n&&i+k<=m;k++){
				if(sa[1+k][i+k]=='.')continue;
				d=k-j;
				res+=get(1+j-d,i+j+d)-get(1+j,i+j+d*2);
			}
		}
	}
	return res;
}
void rot(){
	int i,j;
	memset(sb,0,sizeof(sb));
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++)sb[j][n-i+1]=sa[i][j];
	}
	swap(n,m);
	memcpy(sa,sb,sizeof(sb));
}
int main(){
	int i;
	ll res;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%s",sa[i]+1);
	res=count();
	rot();
	res+=count();
	rot();
	res+=count();
	rot();
	res+=count();
	printf("%lld",res);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)

const int maxn = 1e6 + 5;

ll f[maxn];

int main() {
    inc(i, 1, 100) inc(j, 1, 100) inc(k, 1, 100) {
        int cnt = i * i + j * j + k * k + i * j + j * k + k * i;
        if (cnt <= 10000) f[cnt]++;
    }
    int n;
    cin >> n;
    inc(i, 1, n) cout << f[i] << "\n";
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    int n; cin >> n;
    int a;
    bool f = true;
    for(int i=0; i<n; i++) {
        cin >> a;
        if(a%2 == 1) f = false;
    }

    cout << (f ? "second": "first") << endl;


    return 0;
}

// EOF


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

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

  int ans = n * a;
  if (ans > b) {
    ans = b;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
  lli n,k,sub1,sub2;
  cin>>n>>k;
  lli m=n/k;
  if(m==0)
  {
    if(n<=abs(n-k))
    {
      cout<<n;return 0;
    }
    else
    {
      cout<<abs(n-k);return 0;
    }
  }
  else
  {
    sub1=m*k;sub2=m*k+k;
    sub1=abs(n-sub1);
    sub2=abs(n-sub2);
    sub1=(sub1<sub2?sub1:sub2);
    cout<<sub1;
  }
}
    
    
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

bool fu(pll a, pll b){
	return a.ss<b.ss;
}
void solve()
{
	int n;
	ll x,l;
	vector<pll> v;
	cin>>n;
	rep(i, n){
		cin>>x>>l;
		v.push_back({x-l, x+l});
	}
	sort(all(v), fu);
	int i = 0;
	int ans = 0;
	pll c;
	while(i < n){
		c = v[i];
		ans++;
		i++;
		while(i<n && c.ss>v[i].ff){
			i++;
		}
	}
	cout<<ans<<endl;
}
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);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 2420
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
ans = 0
for i in range(n):
    x = sorted(list(input()))
    s = "".join(x)
    dic[s] += 1

for j in dic.values():
    if j >= 2:
        ans += j * (j-1) // 2
print(ans)

Measured memory_bytes: 18192
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[(1<<22)];
int n;
int a[25][25];
int fun(int mask)
{
    if(mask==(1<<n)-1)
        return 1;
    int &ret=dp[mask];
    if(~ret) return ret;
    ret=0;
    int men=__builtin_popcount(mask);
    for(int i=0;i<n;i++)
    {
      if(a[men][i]&&!((1<<i)&mask))
      {
          ret+=fun(mask|(1<<i));
          ret%=mod;
      }
    }
    return ret;
}
signed main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;++j)
        {
            cin>>a[i][j];
        }
    }
    cout<<fun(0)<<endl;
	return 0;
}


Measured memory_bytes: 19948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;


void solve(){
    int n;
    cin >> n;
    string s[n+10];
    rep(i,n){
        cin >> s[i];
    }

    int m;
    cin >> m;
    string t[m+10];
    rep(i,m){
        cin >> t[i];
    }
    int count=0;
    int ma = 0;
    rep(i,n){
        count = 0;
        rep(j,n){
            if(s[i]==s[j]) count++;
        }
        //count--;
        rep(j,m){
            if(s[i]==t[j]) count--;
        }
        ma = max(ma, count);
    }
    cout << ma << endl;

}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		for(int i=a;i<=b;i++){
			if(c%i==0){
				n++;
			}
		}
		System.out.println(n);
	}
}

Measured memory_bytes: 26392
#include<bits/stdc++.h>
using namespace std;
int n,i,c,x;
set<int>S;
main()
{
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>c>>x;
    if(c)cout<<(S.find(x)!=S.end())<<endl;
    else S.insert(x),cout<<S.size()<<endl;
  }
}


Measured memory_bytes: 12480
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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 ll mod=1e9+7;

int main(){
    vector<ll> a(5);
    rep(i,5){
        cin >> a[i];
        if(a[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
} 


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

int main(){
    int64_t n, l;
    cin >> n >> l;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());

    int f = -1;
    
    for (int i = 0; i < n - 1; i++){
        if (A[i] + A[i + 1] >= l){
            f = i + 1;
        }
    }

    if (f == -1){
        puts("Impossible");
        return 0;
    }

    puts("Possible");
    for (int i = 1; i < f; i++)
        cout << i << endl;
    for (int i = n - 1; i >= f; i--)
        cout << i << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
using namespace std;
vector<int> v;
long long ans;
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;

	// 1 3 6
	// 5 * 1 + 3*2
	vector<long long> v(n);
	for (auto& i : v) cin >> i;
	vector<long long> partSum(n);
	partSum[0] = v[0];
	for (int i = 0; i < v.size(); ++i) {
		partSum[i] = (i-1 >= 0 ? partSum[i - 1] : 0 ) + v[i];
	}
	for (int i = 0; i < v.size(); ++i) {
		ans += (v[i] * ((partSum[n - 1] - partSum[i]) % MOD));
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;

}

Measured memory_bytes: 6380
#include <stdio.h>

int	main(void)
{
  	int	K;
  	int X;
  	int	i;
  
  	scanf("%d %d", &K, &X);
  	
  	for(i=X-K+1; i<=X+K-1; i++)
    {
      	printf("%d ", i);
    }
  	return (0);
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if(a == b){
        rep(i,a) cout << a;
    }else if(a < b){
        rep(i,b) cout << a;
    }else{
        rep(i,a) cout << b;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, k,i,s=0;
	scanf("%d %d %d", &a, &b, &k);
	if (a >= 1 && a <= 100 && b >= 1 && b <= 100 && k >= 1)
	{
		for (i = b;i > 0;i--)
		{
			if (a%i == 0 && b%i == 0)
			{
				s++;
				if (s == k)
				{
					printf("%d\n", i);
				}
			}
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, k, a[N], p[N], s[N];

int32_t main(){_
   
   cin>>k>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }

   p[0] = a[0];
   for (int i = 1; i < n; ++i)
   {
      p[i] = p[i-1];
      p[i] += a[i] - a[i-1];
   }

   s[n-1] = k - a[n-1];

   for (int i = n-2; i >= 0; --i)
   {
      s[i] = s[i+1];
      s[i] += a[i+1] - a[i];
   }
   
   int ans = min(p[n-1] - a[0], s[0] - (k - a[n-1]));
   tr(p[n-1], ans);
   for (int i = 1; i+1 < n; ++i)
   {
      tr(i, p[i-1], s[i+1]);
      smin(ans, ((i-1 < 0) ? 0 : p[i]) + s[i+1]);
   }
   
   cout<<ans;

   return 0;
}

Measured memory_bytes: 9984
#include <stdio.h>
#include <math.h>
int main(){

  int x,y,n,tmp;
  
  /*入力*/
  scanf("%d %d",&x,&y);

  /*制約*/
  if(x>=1&&y<=pow(10,9)){

  if(x>=y){
    tmp = y;
    y = x;
    x = tmp;
  }

  n=y%x;
  while(n!=0){
    y = x;
    x = n;
    n = y%x;
  }
  printf("%d\n",x);
  
  }
}



Measured memory_bytes: 2760
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> P, Z, N;
	rep(i, n)
	{
		int a; cin >> a;
		if (a > 0)P.push_back(a);
		else if (a == 0)Z.push_back(a);
		else N.push_back(a);
	}
	int Pnum = P.size(), Znum = Z.size(), Nnum = N.size();
	if (Znum != 0)
	{
		int s = 0;
		for (int x : P)s += x;
		for (int x : N)s -= x;
		cout << s << endl;
		int now = 0;
		rep(i, Pnum - 1)
		{
			cout << now << " " << P[i] << endl;
			now -= P[i];
		}
		if (Pnum != 0)
		{
			cout << P.back() << " " << now << endl;
			now = P.back() - now;
		}
		rep(i, Nnum)
		{
			cout << now << " " << N[i] << endl;
			now -= N[i];
		}
		rep(i, Znum - 1)cout << now << " " << 0 << endl;
	}
	else if (Pnum == 0)
	{
		sort(all(N));
		int s = 0;
		for (int x : N)s -= x;
		s += N.back() * 2;
		cout << s << endl;
		int now = N.back();
		rep(i, Nnum - 1)
		{
			cout << now << " " << N[i] << endl;
			now -= N[i];
		}
	}
	else if (Nnum == 0)
	{
		sort(all(P));
		int s = 0;
		for (int x : P)s += x;
		s -= P[0] * 2;
		cout << s << endl;
		int now = P[0];
		for (int i = 1; i <= Pnum - 2; ++i)
		{
			cout << now << " " << P[i] << endl;
			now -= P[i];
		}
		cout << P.back() << " " << now << endl;
	}
	else
	{
		int s = 0;
		for (int x : P)s += x;
		for (int x : N)s -= x;
		cout << s << endl;
		int now = N[0];
		rep(i, Pnum - 1)
		{
			cout << now << " " << P[i] << endl;
			now -= P[i];
		}
		cout << P.back() << " " << now << endl;
		now = P.back() - now;
		for (int i = 1; i < Nnum; ++i)
		{
			cout << now << " " << N[i] << endl;
			now -= N[i];
		}
	}
}

Measured memory_bytes: 3932
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int time, rest_min, h, m, s;

	scanf("%d", &time);

	rest_min = time % 3600;
	s = rest_min % 60;
	m = (rest_min - s) / 60;
	h = (time - rest_min) / 3600;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}


Measured memory_bytes: 2120
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
ll n, m, i, ans;

int main()
{
	while(cin >> n)
	{
		ans = 0;
		if((n + 1) % 10 == 0)
		{
			for(;;)
			{
				ans++;
				if(n < 10) break;
				n = n / 10;
			}
			m = n + (ans - 1) * 9;
			cout << m << endl;
		}
		else
		{
			for(;;)
			{
				ans++;
				if(n < 10) break;
				n = n / 10;
			}
			if(ans != 1) m = (n - 1) + (ans - 1) * 9;
			else m = n;
			cout << m << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] cnt = new int[100005];
		for(int i=0;i<n;i++) {
			cnt[sc.nextInt()]++;
		}
		
		int max = 0;
		for(int i=0;i<cnt.length-2;i++) {
			int c = cnt[i]+cnt[i+1]+cnt[i+2];
			
			if(c>max)
				max = c;
		}
		
		System.out.println(max);
	}
}


Measured memory_bytes: 48256
n, m = map(int, input().split())
money = 0
li = [list(map(int, input().split())) for _ in range(n)]
li.sort()

for j in range(n):
    shop = li.pop(0)
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)

# リスト内包表記を利用
# #4716613 より早くなるかな？


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



int main() {
	int A[3][3] ;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	int N;
	cin >> N;

	int b[11];
	for (int i = 0; i < N; i++)cin >> b[i];

	int hantei[3][3] = { 0 };

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			
			for (int v = 0; v < N; v++) {
				if (A[i][j] == b[v]) hantei[i][j] = 1;
			}
		}
	}


	for (int i = 0; i < N; i++) {
		if (hantei[i][0] == 1 && hantei[i][1] == 1 && hantei[i][2] == 1)
		{
			cout << "Yes" << endl; return 0;
		}

		if (hantei[0][i] == 1 && hantei[1][i] == 1 && hantei[2][i] == 1)
		{
			cout << "Yes" << endl; return 0;
		}
	}


		if (hantei[0][0] == 1 && hantei[1][1] == 1 && hantei[2][2] == 1)
		{
			cout << "Yes" << endl; return 0;
		}

		if (hantei[0][2] == 1 && hantei[1][1] == 1 && hantei[2][0] == 1)
		{
			cout << "Yes" << endl; return 0;
		}


	cout<< "No" << endl;
	return 0;



}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int a;
        cin>>a;
        if(a==-1)break;
        int ans=3130;
        ans-=125*min(10,max(0,a-10));
        ans-=140*min(10,max(0,a-20));
        ans-=160*max(0,a-30);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <bits/stdc++.h>
using namespace std ;
#define printshosu(a) cout << fixed << setprecision(15) << a << endl;
int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  bool isTakahashi = true;
  while(A>0&&C>0){
    if(isTakahashi){
      C = C-B;
      isTakahashi = false;
    }else{
      A = A - D;
      isTakahashi = true;
    }
  }
  if(isTakahashi){
    cout <<"No"<<endl;
  }else{
    cout <<"Yes"<<endl;
  }
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i,a,b) for(int i=(a); i<(b); i++)
const double pi=acos(-1);
int main() {
	int a,b,h,m; scanf("%d%d%d%d", &a, &b, &h, &m);
	double vh=2*pi/12/60, vm=2*pi/60;
	int t=h*60+m;
	double ah=vh*t, am=vm*t;
	double xh=a*cos(ah), yh=a*sin(ah), xm=b*cos(am), ym=b*sin(am);
	printf("%.10lf\n", sqrt(pow(xh-xm,2)+pow(yh-ym,2)));
}


Measured memory_bytes: 2532
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'
for n in list(reversed(range(N-1))):
    if H[n+1]-H[n]>=0:
        pass
    elif H[n+1]-H[n]==-1:
        H[n] -= 1
    else:
        ans = 'No'
        
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
} rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int M(2e5 + 5), N(3003), P(1e9 + 7);
inline int fpow(int x, int k = P - 2) {
	int r = 1;
	for (; k; k >>= 1, x = 1ll * x * x % P)
		if (k & 1) r = 1ll * r * x % P;
	return r;
}
int fac[M], ifac[M], f[N];
std::pair<int, int> a[N];

inline int comb(int n, int m) {
	return n < m ? 0 : 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}
int main() {
	int h = rd, w = rd, n = rd;
	ifac[0] = fac[0] = 1;
	REP(i, 1, h + w) fac[i] = 1ll * fac[i - 1] * i % P;
	ifac[h + w] = fpow(fac[h + w]);
	for (int i = h + w - 1; i; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % P;
	REP(i, 1, n) a[i] = {rd, rd};
	std::sort(a + 1, a + 1 + n);
	a[n + 1] = {h, w};
	#define fi first
	#define se second
	REP(i, 1, n + 1) {
		f[i] = comb(a[i].fi + a[i].se - 2, a[i].fi - 1);
		REP(j, 1, i - 1) 
			if (a[j].fi <= a[i].fi && a[j].se <= a[i].se)
				f[i] = (f[i] - 1ll * f[j] * comb(a[i].fi + a[i].se - a[j].fi - a[j].se, a[i].fi - a[j].fi)) % P;
	}
	std::cout << (f[n + 1] + P) % P;
	return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int A = sc.nextInt();
		
		if(X<A) {
			System.out.println("0");
		}else {
			System.out.println("10");
		}
		
		sc.close();
		
	}

}

Measured memory_bytes: 23124
k = int(input())
d = 1
tmp = 0
for i in range(10**6+1):
    if i == 0:
        d = 1
    else:
        d *= 10 
        d %= k
    tmp += 7*d
    tmp %= k
    if tmp%k == 0:
        print(i+1)
        exit(0)
print("-1")

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

const int maxn = 5e5+1000;



void getFail(char *P,int f[])
{
    int m = strlen(P);
    f[0] = 0,f[1] = 0;
    for(int i = 1;i < m;++i)
    {
        int j = f[i];
        while(j && P[i] != P[j]) j = f[j];
        f[i+1] = P[i] == P[j] ?j+1:0;
    }
}

void check(bool good[],int f[],int n)
{
    good[1] = 1;
    for(int i = 2;i <= n;++i)
    {
        if(f[i] > 0 && i % (i-f[i]) == 0)
        {
            int t = i/(i-f[i]);
            if(t >= 2)
                good[i] = 0;
            else
                good[i] = 1;
        }
        else
            good[i] = 1;
    }

}


int f[maxn];
char s[maxn];
bool goodpre[maxn];
bool goodsuf[maxn];


bool IsSame(int n)
{
    for(int i = 1;i < n;++i)
        if(s[i] != s[0]) return false;
    return true;
}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%s",s);
    int n = strlen(s);

    if(IsSame(n))
    {
        printf("%d\n1\n",n);
        return 0;
    }

    getFail(s,f);

    check(goodpre,f,n);
    reverse(s,s+n);
    getFail(s,f);
    check(goodsuf,f,n);
    reverse(goodsuf+1,goodsuf+1+n);

    if(goodpre[n])
    {
        puts("1\n1");
        return 0;
    }

    int res = 0;
    for(int i = 1;i < n;++i)
        if(goodpre[i] && goodsuf[i+1])
            res++;
    printf("2\n%d\n",res);


    return 0;
}


Measured memory_bytes: 3712
n = int(input())
la = [int(i) for i in input().split()]

ia = {}
pair = 0
for j, a in enumerate(la):
  ia[j + a] = ia.get(j + a, 0) + 1

for j, a in enumerate(la): 
  pair += ia.get(j - a, 0)

print(pair)


Measured memory_bytes: 40312
#include <bits/stdc++.h>
using namespace std;
 #define REP(i,x,n) for(int i = x ; i < (int)(n) ; i++)
#define rep(i,n) REP(i,0,n)
 static const int dx[]={1,-1,0,0};
static const int dy[]={0,0,1,-1};
static const char color[]={'R','G','B'};
 int n,m;
int changeV;
char G[10][10];
bool used[10][10];

struct State{
  int push;
  char grid[10][10];
  State(){}
  State(int p, char g[][10]){
    push = p;
    rep(i,n) rep(j,m) grid[i][j] = g[i][j];
  }
};

bool check(){
  char tmp = G[0][0];
  rep(i,n){
    rep(j,m){
      if(G[i][j]!=tmp) return false;
    }
  }
  return true;
}

void dfs(int x, int y, int idx){
  used[x][y] = true;
  rep(k,4){
    int nx = x + dx[k];   int ny = y + dy[k];
    if(0<=nx&&nx<n && 0<=ny&&ny<m && G[x][y]==G[nx][ny] && !used[nx][ny]){
      dfs(nx,ny,idx);
    }
  }
  G[x][y] = color[idx];
}

int solve(){
  queue<State> q;
  q.push(State(0,G));
    while(!q.empty()){
    State st = q.front();
    q.pop();
    rep(k,3){
      if(st.grid[0][0]!=color[k]){
        memcpy(G,st.grid,sizeof(G));
        memset(used,false,sizeof(used));
        dfs(0,0,k);
        if(check()) return st.push + 1;
        if(G[0][0]==G[0][1] || G[0][0]==G[1][0]){
          q.push(State(st.push + 1, G));
        }
      }
    }
  }
  return -1;
}

int main(){
  while(cin >> m >> n && (n|m)){
    rep(i,n){
      rep(j,m){
        cin >> G[i][j];
      }
    }

    int ans = 0;
    if(!check()) ans = solve();
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 8784
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	int n;
	cin >> n;
	ll ans = pow_mod(10, n) - pow_mod(9, n) * 2 + pow_mod(8, n);
	ans %= mod;
	ans = (ans + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env php
<?php
// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

function genInputs() {
    while(($input = rtrim(fgets(STDIN))) !== false) {
        foreach (explode(' ', $input) as $v) {
            yield $v;
        }
    }
}
function getNext($gen) {
    $value = $gen->current();
    $gen->next();
    return $value;
}
$gen = genInputs();

$N = (int)getNext($gen);
$K = (int)getNext($gen);
$S = (string)getNext($gen);
$K--;
$S[$K] = strtolower($S[$K]);
echo $S.PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define N 200010
using namespace std;
 
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge{int v,next;}vs[N<<1];
int n,ee,st[N<<1],du[N],Rt,F[N];
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt,int pr,int x)
{
	vector <int> v; v.clear();
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		dfs(vs[i].v,rt,x);
		v.push_back(F[vs[i].v]);
	}
	if(du[rt]&1) v.push_back(0);
	sort(v.begin(),v.end());
	// printf("son of node %d len of %d\n",rt,x);
	// for(int i=0;i<v.size();i++) printf("%d ",v[i]); puts("");
	int l=0,r=v.size()-1,rs=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1,fg=1;
		for(int i=0,j=v.size()-1;i<j;i++,j--)
		{
			if(i==mid) i++; if(j==mid) j--;
			fg&=(v[i]+v[j])<=x;
		}
		if(fg) r=mid-1,rs=v[mid];
		else l=mid+1;
	}
	F[rt]=rs+1;
}
inline bool check(int x)
{
	dfs(Rt,0,x); return F[Rt]<=x+1;
}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); du[u]++;
		addedge(v,u); du[v]++;
	}
	int cnt=0; for(int i=1;i<=n;i++) 
		cnt+=du[i]&1,Rt=du[i]==1? i:Rt;
	//Rt=1;
	int l=1,r=n,B=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,B=mid;
		else l=mid+1;
	}
	cout << cnt/2 << " " << B << endl;
	return 0;
}


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

int main(){
    vector<int> a;
    int s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    a.push_back(s1);
    a.push_back(s2);
    a.push_back(s3);
    sort(a.begin(),a.end());
    int count=0;
    count = a[2]-a[0];
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG 1
#define dd if (DEBUG)

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define rall(a) (a).rbegin (), (a).rend ()
#define sz(a) (int) (a).size ()
#define szl(a) (int) (a).length ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;
typedef pair <int, int> pii;
#define f first
#define s second
#define mp(a, b) make_pair((a), (b))
typedef vector <int> vi;
typedef vector <vi> mi;
typedef vector <ll> vll;
typedef vector <vll> mll;
#define pb(a) push_back ((a))

const ll MOD = 1e+9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
    FASTIO;
    int i, j, n, m, s;
    cin >> n >> m;
    vi AC (n + 1), WA (n + 1);
    string sx;
    for (i = 0; i < m; ++i)
    {
        cin >> s >> sx;
        if (sx == "AC") AC[s] = 1;
        else if (!AC[s]) ++WA[s];
    }
    for (i = j = s = 0; i <= n; ++i)
    {
        j += AC[i];
        if (AC[i]) s += WA[i];
    }
    cout << j << ' ' << s << '\n';

    return 0;
}




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

int main() {
  int n, t, a, h;
  std::cin >> n >> t >> a;
  
  double min = 100000000;
  int minnum = 0;
  
  double tdif;
  for (int i = 0; i < n; i++) {
    std::cin >> h;
    tdif = t - 0.006 * h > a ? t - 0.006 * h - a : a - (t - 0.006 * h);
    if (tdif < min) {
      min = tdif;
      minnum = i+1;
    }
  }
  std::cout << minnum << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
vector<int> c(n-1);
  for(int i=0;i<n;i++){
  cin >> a.at(i);}
  for(int i=0;i<n;i++){
  cin >> b.at(i);}
  for(int i=0;i<n-1;i++){
  cin >> c.at(i);}

int satis=0;
 for(int i=0;i<n;i++){
 satis+=b.at(a.at(i)-1);}
  for(int i=0;i<n-1;i++){
  if(a.at(i)==a.at(i+1)-1)
  satis+=c.at(a.at(i)-1);}
cout << satis << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string S;
  cin>>S;
  int ans=1000000,N=S.length();
  int tmp=0;
  for(int i=0;i<N;i++){
    if(i%2==1 && S[i]=='1'){
      tmp++;
    }
    if(i%2==0 && S[i]=='0'){
      tmp++;
    }
  }
  ans=min(ans,tmp);

  tmp=0;
  for(int i=0;i<N;i++){
    if(i%2==1 && S[i]=='0'){
      tmp++;
    }
    if(i%2==0 && S[i]=='1'){
      tmp++;
    }
  }
  ans=min(ans,tmp);
  
  cout<<ans<<endl;
}


Measured memory_bytes: 512
import sys
int_n, int_y = list(map(int, input().split()))

find = False

for ichimanen in range(int_n + 1):
    for gosenen in range(int_n + 1):
        if int_n - ichimanen - gosenen >= 0:
            if ichimanen + gosenen + (int_n - ichimanen - gosenen) == int_n and find is False:
                if (ichimanen * 10000 + gosenen * 5000 + (int_n - ichimanen - gosenen) * 1000) == int_y:
                    find = True
                    print(ichimanen, gosenen, (int_n - ichimanen - gosenen))
                    sys.exit()

if find is False:
    print(-1, -1, -1)





Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#define N 1000005
using namespace std;
using ll = long long;

int p[N];
void sieve(int n) {
  p[1] = 1;
  p[0] = 1;
  for (ll i = 2; i <= n; ++i) {
    if (p[i] == 0) {
      p[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        p[j] = i;
      }
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &ai: a) cin >> ai;
  int max_a = *max_element(a.begin(), a.end());
  sieve(max_a);
  vector<int> cnt(max_a + 1, 0);
  for (auto ai: a) {
    while (ai > 1) {
      int prime = p[ai];
      while (ai % prime == 0) ai /= prime;
      ++cnt[prime];
    }
  }

  bool pairwise = true;
  for (int i = 0; i <= max_a; ++i) {
    if (cnt[i] > 1) {
      pairwise = false;
      break;
    }
  }
  if (pairwise) {
    cout << "pairwise coprime\n";
    return 0;
  }
  int setgcd = gcd(a[0], a[1]);
  for (int i = 2; i < n; ++i) {
    setgcd = gcd(setgcd, a[i]);
  }
  if (setgcd == 1) {
    cout << "setwise coprime\n";
  } else {
    cout << "not coprime\n";
  }

  return 0;
}


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

class UnionFind {
public:
    UnionFind(int64_t n) {
        //parが負の場合、このグループに属する要素数 * (-1)を示す
        par_.resize(n, -1);
    }

    //根を求める
    int64_t root(int64_t x) {
        return (par_[x] < 0 ? x : par_[x] = root(par_[x]));
    }

    //xとyの属する集合を併合
    void unite(int64_t x, int64_t y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }

        //要素数を足す(負の数だがそのまま足せば良い)
        par_[x] += par_[y];

        //yをxに繋げる
        par_[y] = x;
    }

    //xとyが同じ集合に属するか否かを判定
    bool same(int64_t x, int64_t y) {
        return (root(x) == root(y));
    }

    //xと同じ集合に属する要素数を返す
    int64_t size(int64_t x) {
        x = root(x);
        return -par_[x];
    }
private:
    vector<int64_t> par_;
};

int main() {
    int64_t N, M;
    cin >> N >> M;

    UnionFind uf(N);
    for (int64_t i = 0; i < M; i++) {
        int64_t A, B;
        cin >> A >> B;
        A--; B--;
        uf.unite(A, B);
    }

    int64_t ans = 1;
    for (int64_t i = 0; i < N; i++) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5104
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, n) {
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll ans = 0;
    for (auto p : mp) {
        ll m = p.second;
        ans += m*(m-1)/2;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(){
	int tl,pl;
	string T,P;

	cin>>T;
	cin>>P;
	tl=T.size();
	pl=P.size();
	if(tl<pl) return 0;
	for(int i=0;i<tl-pl+1;i++){
		if(T[i]==P[0]){
			if(T.substr(i,pl)==P)
			printf("%d\n",i);
		}
	}
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define int long long
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 (a>b) { a=b; return 1; } return 0; }

const int INF=1e9;

class LazySegmentTree
{
 private:
    int n;
    vector<int> node,lazy;
 public:
    LazySegmentTree(int sz){
        n=1;
        while(n<sz) n*=2;
        node.assign(2*n-1,0LL);
        lazy.assign(2*n-1,INF);
    }
    void update(int a,int b,int x,int k,int l,int r){
        if(a<=l and r<=b){
            node[k]=x*(r-l);
            lazy[k]=x;
        }else{
            if(lazy[k]!=INF) push(k,l,r),lazy[k]=INF;
            if(check(a,b,l,(l+r)/2)) update(a,b,x,2*k+1,l,(l+r)/2);
            if(check(a,b,(l+r)/2,r)) update(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }
    int get(int a,int b,int k,int l,int r){
        if(a<=l and r<=b){
            return node[k];
        }else{
            if(lazy[k]!=INF) push(k,l,r),lazy[k]=INF;
            int res=0;
            if(check(a,b,l,(l+r)/2)) res+=get(a,b,2*k+1,l,(l+r)/2);
            if(check(a,b,(l+r)/2,r)) res+=get(a,b,2*k+2,(l+r)/2,r);
            return res;
        }
    }
    void push(int k,int l,int r){
        node[2*k+1]=lazy[k]*(r-l)/2; lazy[2*k+1]=lazy[k];
        node[2*k+2]=lazy[k]*(r-l)/2; lazy[2*k+2]=lazy[k];
    }
    bool check(int a,int b,int l,int r){
        return max(a,l)<min(b,r);
    }
    void update(int a,int b,int x){ update(a,b,x,0,0,n); }
    int get(int a,int b){ return get(a,b,0,0,n); }
};

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

    int N,Q; cin>>N>>Q;
    LazySegmentTree seg(N);
    while(Q--){
        int q; cin>>q;
        if(q==0){
            int s,t,x; cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }else{
            int s,t; cin>>s>>t;
            cout<<seg.get(s,t+1)<<endl;
        }
        // for(int i=0;i<4;i++) cout<<seg.get(i,i+1)<<' '; cout<<endl;
    }
    return 0;
}


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

typedef long long LL;  //Attention!!
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); cout.precision(15);cout.setf(ios::fixed);
LL n,i,j,m;

cin>>n;

LL ans = 0;

vector <LL> v(2*n);

for(i=0;i<2*n;i++) cin>>v[i];

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

for(i=0;i<2*n;i++)
	{m = v[i];
	if(i%2==0)	
		ans += m;
	}
cout<<ans<<endl
;
}


Measured memory_bytes: 256