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

void solve(long long A, long long B, long long C)
{
    cout << min(B / A, C) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m;
bool flag;
char a[105][105];
bool u[105][105];
int main()
{
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>(a[i]+1);
	for(i=1;i<=n;i++)
	{
		flag=false;
		for(j=1;j<=m;j++)
			if(a[i][j]=='#')
			{
				flag=true;
				break;
			}
		if(!flag)
		{
			for(j=1;j<=m;j++)
				u[i][j]=true;
		}
	}
	
	for(j=1;j<=m;j++)
	{
		flag=false;
		for(i=1;i<=n;i++)
			if(!u[i][j]&&a[i][j]=='#')
			{
				flag=true;
				break;
			}
		if(!flag)
		{
			for(i=1;i<=n;i++)
				u[i][j]=true;
		}
	}
	for(i=1;i<=n;i++)
	{
		flag=false;
		for(j=1;j<=m;j++)
			if(!u[i][j])
			{
				cout<<a[i][j];
				flag=true;
			}
		if(flag) cout<<endl;
	}
	return 0;	
} 



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



int main(){
    int a,b,m;
    cin >>a>>b>>m;
    int aa[100001];
    int bb[100001];
    int mx[100001];int my[100001];int mc[100001];
    rep(i,a)cin>>aa[i];
    rep(i,b)cin>>bb[i];
    rep(i,m)cin>>mx[i]>>my[i]>>mc[i];

    int min_a=100001;
    rep(i,a){
        if(aa[i]<min_a){
            min_a=aa[i];
        }
    }

    int min_b=100001;
    rep(i,b){
        if(bb[i]<min_b){
            min_b=bb[i];
        }
    }
    int min_sum;
    min_sum=min_a+min_b;
	
    rep(i,m){
        if((aa[mx[i]-1]+bb[my[i]-1]-mc[i])<min_sum){
            min_sum=(aa[mx[i]-1]+bb[my[i]-1]-mc[i]);
        }    
    }

    cout<<min_sum<<endl;  
    return 0;
    
}

Measured memory_bytes: 2176
def insertion_sort(num_list,gap):
    global cnt
    for i in range(gap,len(num_list)):
        swap_num = num_list[i]
        j = i-gap
        while j >= 0 and num_list[j] > swap_num:
            num_list[j+gap] = num_list[j]
            j -= gap
            cnt += 1
        num_list[j+gap] = swap_num

def shell_sort(num_list):
    global cnt 
    cnt = 0
    m = 1
    m_list = []
    while len(num_list) >= m:
        m_list.append(m)
        m = 3*m+1
    m_list.reverse()
    print(len(m_list))
    print(' '.join([str(i) for i in m_list]))

    for i in range(len(m_list)):
        insertion_sort(num_list,m_list[i])
    print(cnt)

n = int(input())
num_list = [int(input()) for _ in range(n)]
shell_sort(num_list)
for num in num_list:
    print(num)


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;


int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n, m, k, curr ;
    cin>> n >> m >> k ;
    for(int i=0 ; i<=n ; i++)
      for(int j=0 ; j<=m ; j++)
        {
          curr=i*m-i*j+j*(n-i) ;
          if(curr==k)
            {
              cout<< "Yes" ;
              return 0 ;
            }
        }
    cout<< "No" ;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
  
int main()
{
    fastio
    long long int t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,f,e,p,o,nl,np,q,r,g;
    string s;
    vector<pair<ll,ll>>v(5);
    rep(i,0,5)
    {
        cin>>x;
        v[i].ff=x;
        v[i].ss=i+1;
    }
    sort(v.begin(),v.end());
    cout<<v[0].ss<<endl;
}

Measured memory_bytes: 3584
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

const int MAXN = 100+10;
char str[MAXN];
ll K;

int main(){
	scanf("%s",str);
	scanf("%lld",&K);
	int flag = 0;
	int le = strlen(str);
	for(int i=0;i<le;i++){
		if(str[i]!='1'){
			flag = 1;
			break;
		}
	}
	
	int sav = 0;
	while(str[sav]=='1')	sav++;
	if(sav>=K)	printf("1\n");
	else 	printf("%d\n",str[sav]-'0');
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long t = 1L;
        for (int i = 1; i <= n; i++) {
            t *= i;
            t %= (Math.pow(10, 9) + 7);
        }
        System.out.println((int)(t % (Math.pow(10, 9) + 7)));
    }

}


Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int n, place;

struct node
{
	int id, pid, bid, depth, degree, h;
	int lc, rc;
	string type;
}N[10000];

void Set()
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		N[i].pid = -1;
		N[i].bid = -1;
		N[i].h = 0;
	}

	for (int i = 0; i < n; i++)
	{
		cin >> place;
		N[place].id = place;

		cin >> N[place].lc >> N[place].rc;
		N[N[place].lc].id = N[place].lc;
		N[N[place].rc].id = N[place].rc;

		if (N[place].lc != -1 && N[place].rc != -1)
		{
			N[N[place].lc].bid = N[N[place].rc].id;
			N[N[place].rc].bid = N[N[place].lc].id;

			N[N[place].lc].pid = N[place].id;
			N[N[place].rc].pid = N[place].id;

			N[place].degree = 2;
		}
		else if (N[place].lc == -1 && N[place].rc == -1)
			N[place].degree = 0;
		else
		{
			if (N[place].lc != -1)
				N[N[place].lc].pid = N[place].id;
			else
				N[N[place].rc].pid = N[place].id;

			N[place].degree = 1;
		}
	}
}

void GetDepth(node& GN)
{
	GN.depth = 0;
	node temp = GN;
                                           
	while (temp.pid != -1)
	{
		GN.depth++;
		temp = N[temp.pid];
	}
}

int GetHeight(node& GN)
{
	int h1 = 0, h2 = 0;
	if (GN.lc != -1)
		h1 = GetHeight(N[GN.lc]) + 1;
	if (GN.rc != -1)
		h2 = GetHeight(N[GN.rc]) + 1;
	return h1 > h2 ? h1 : h2;
}

void GetType(node& GN)
{
	if (GN.pid == -1)
		GN.type = "root";
	else if (GN.degree == 0)
		GN.type = "leaf";
	else
		GN.type = "internal node";
}

void print()
{
	for (int i = 0; i < n; i++)
	{
		cout << "node " << N[i].id << ": " << "parent = " << N[i].pid << ", ";
	    cout << "sibling = " << N[i].bid << ", ";
		cout << "degree = " << N[i].degree << ", ";
		cout << "depth = " << N[i].depth << ", ";
		cout << "height = " << N[i].h << ", ";
		cout << N[i].type << endl;
	}
}

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

	Set();

	for (int i = 0; i < n; i++)
	{
		GetDepth(N[i]);	
		N[i].h = GetHeight(N[i]);
		GetType(N[i]);
	}
	
	print();

	return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
   ll n;
   cin>>n;
   vector<ll> a(n);
   for(ll i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a.begin(),a.end());
   double ans=a[0];
   for(ll i=1;i<n;i++){
       ans=(double)(ans+a[i])/2;
   }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 100000070

#define MAXR 100000
#define PI 3.14159265358979323846

using namespace std;

void getEachNum(int a, vector<int>& S) {
    S.push_back(a % 10);
    while (a / 10) {
        a /= 10;
        S.push_back(a % 10);
    }
    return;
}

signed main() {
    string a;
    cin >> a;
    int sum = 0;
    REP(i, a.size()) {
        const char c = a[i];
        int b = atoi(&c);
        sum += b;
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
 
int main(){
  int n;
  scanf("%d\n",&n);
  int a[n];
  long int sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];}
  long int sum2=0;
  int i=0;
  while(labs(sum-2*sum2) > labs(2*(sum2+a[i])-sum)){
    sum2+=a[i];
    i++;}
  printf("%ld\n",labs(sum-2*sum2));
 
  return 0;
}


Measured memory_bytes: 896
from itertools import accumulate
from bisect import bisect_right
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Acc=list(accumulate(B))
ans=0
time=0
a_cnt=0
for a in A:
    remain=k-time
    if remain<0:
        break
    b_cnt=bisect_right(Acc,remain)
    ans=max(ans,a_cnt+b_cnt)
    time+=a
    a_cnt+=1
remain=k-time
if remain>=0:
    b_cnt=bisect_right(Acc,remain)
    ans=max(ans,a_cnt+b_cnt)
print(ans)

Measured memory_bytes: 116556
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll N;
void dfs(string s, char M)
{
  ll sl = s.size();
  if (sl == N) {
    cout << s << "\n";
    return;
  }
  for (ll i = 0; i <= M - 'a' + 1; ++i) {
    dfs(s + (char)('a' + i), max(M, (char)('a' + i)));
  }
}

int main()
{
  cin >> N;
  dfs("a", 'a');
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main()
{
  int n;
  cin >> n;
  priority_queue<P, vector<P>, greater<P>> que;
  ll total = 0;
  rep(i, n)
  {
    ll a, b;
    cin >> a >> b;
    if (b - a < 0)
    {
      cout << "No" << endl;
      return 0;
    }
    que.push(make_pair(b, a));
  }
  rep(i, n)
  {
    P p = que.top();
    que.pop();
    total += p.second;
    if (p.first < total)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 6128
using System;
using System.Collections.Generic;
using System.Linq;

namespace Project
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var Head = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = Head[0];
            var M = Head[1];
            var HoleList = new List<int>(0);


            var dp = new int[N+1];

            // 0段目
            dp[0] = 1;

            for (int i = 0; i < M; i++)
            {
                dp[int.Parse(Console.ReadLine())] = -1;
            }
            // 1段目
            dp[1] = dp[1] == -1 ? 0 : 1;

            // x>1段目。dp[x] = dp[x-1] + dp[x-2]
            for (int i=2; i<N+1; i++)
            {
                if (dp[i] == -1) 
                {
                    dp[i] = 0;
                }
                else
                {
                    dp[i] = dp[i - 1] + dp[i - 2];
                    dp[i] %= 1000000007;
                }
            }

            Console.WriteLine(dp[N]);

        }
    }
}


Measured memory_bytes: 13536
#include <stdio.h>

int main(void) {
	int n, k, x, y;
	
	scanf("%d\n%d\n%d\n%d", &n, &k, &x, &y);
	
	if(n>k){
		printf("%d\n", (n-k)*y+k*x);
	}
	else
	printf("%d\n", n*x);
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    ll n=s.size();
    bool flg=false;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='9')flg=true;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

int lcm(int x,int y) {return x/__gcd(x,y)*y;};

signed main(){
    int x; cin >> x; 
    cout << lcm(360,x) / x << endl;
}


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

int digitsum(int n){
    int sum=0;
    
    while(n){
        int rem= n%10;
        sum+=rem;
        n/=10;
    }
    return sum;
}
int main(void){
    // Your code here!
   int n;
   cin>>n;
   
   int a,b;
   cin>>a>>b;
   int sum =0;
   for(int i=1;i<=n;i++){
       int dsum=digitsum(i); 
       if(dsum>=a && dsum<=b){
           sum+=i;
       }
   }
cout<<sum;
    
}


Measured memory_bytes: 3132
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let l: usize = sc.read();
    let mut n = 0;
    while (1 << (n + 1)) <= l {
        n += 1;
    }

    n += 1;
    let mut graph = vec![vec![]; n];
    for i in 1..n {
        graph[i - 1].push((i, 1 << (i - 1)));
        graph[i - 1].push((i, 0));
    }

    let lower = (1 << (n - 1)) - 1;
    let mut upper = l - 1;
    for i in (0..(n - 1)).rev() {
        let sum = (1 << i) - 1;
        if upper <= sum {
            continue;
        }
        let edge = upper - sum;

        // sum + edge == upper
        // 0 + edge
        if edge <= lower {
            continue;
        }
        upper = edge - 1;
        graph[i].push((n - 1, edge));
    }

    let mut ans = vec![];
    for from in 0..n {
        for &(to, w) in graph[from].iter() {
            ans.push((from, to, w));
        }
    }

    println!("{} {}", n, ans.len());
    for (from, to, w) in ans.into_iter() {
        println!("{} {} {}", from + 1, to + 1, w);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if (a<b){
      System.out.println("a < b");
    }else if(a>b){
      System.out.println("a > b");
    }else{
      System.out.println("a == b");
    }
  }
}



Measured memory_bytes: 26072
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	vector<pair<ll,ll> > v;
	ll mx = 0;
	rep(i,0,n){
		ll a,b;
		cin>>a>>b;
		v.pb(mp(b,a));
		mx = max(mx,b);
	}
	sort(all(v));
	reverse(all(v));
	ll c = mx;
	rep(i,0,v.sz){
		ll a = v[i].se;
		ll b = v[i].fi;
		c = min(b,c);
		c -= a;
	}
	if(c<0){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 6524
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = input()
ans = 0
for i in range(len(n)):
    ans += int(n[i])
if int(n)%ans == 0:
    print("Yes")
else:
    print("No")

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

int main(){
	int a;
	string s;
	cin>>a>>s;
	if(a==3200){
		cout<<"pink"<<endl;
	}else if(a<3200){
		cout<<"red"<<endl;
	}else{
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
edge=[[] for i in range(3*n)]
for i in range(m):
  u,v=map(int,input().split())
  for j in range(3):
    edge[u-1+j*n].append([1,(v-1+(j+1)*n)%(3*n)])
import heapq
def dijkstra_heap(s):
  d=[float("inf")]*(3*n)
  used=[True]*(3*n)
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge = heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v = minedge[1]
    d[v] = minedge[0]
    used[v] = False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d
s,t=map(int,input().split())
ans=dijkstra_heap(s-1)[t-1]
print(ans//3 if ans%3==0 else -1)

Measured memory_bytes: 124016
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

B = [0] + A + [0]
sum_d = 0
for i in range(N+1):
    sum_d += abs(B[i+1] - B[i])

for i in range(1, N+1):
    print(sum_d - abs(B[i] - B[i-1]) - abs(B[i+1] - B[i]) + abs(B[i+1] - B[i-1]))

Measured memory_bytes: 19820
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, ans = 0, counter;
	bool flag;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N - 1; i++) {
		counter = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			flag = false;
			for (int j = 0; j <= i; j++) {
				if (S.at(j) == c) {
					flag = true;
					break;
				}
			}
			if (flag == false)
				continue;
			for (int j = i + 1; j < N; j++) {
				if (S.at(j) == c) {
					counter++;
					break;
				}
			}
		}
		if (ans < counter)
			ans = counter;
	}

	cout << ans << endl;

	return 0;
}

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

#define MAX 100000

int n,k;
long T[MAX];

int check(long p){
    int i = 0;
    for(int j = 0;j < k;++j){
        long s = 0;
        while(s + T[i] <= p){
            s += T[i];
            ++i;
            if(i == n){
                return n;
            }
        }
    }
    return i;
}

long solve(){
    long left = 0;
    // 荷物の個数 * 一個あたりの最大重量
    long right = 100000 * 10000;
    long mid;
    while(right - left > 1){
        mid = (left + right) / 2;
        // Pを暫定的に決める
        int v = check(mid);
        if(v >= n){
            right = mid;
        }
        else{
            left = mid;
        }
    }
    return right;
}

int main(){
    std::cin >> n >> k;
    for(int i = 0;i < n;++i){
        std::cin >> T[i];
    }
    long ans = solve();
    printf("%ld\n",ans);
    return 0;
}



Measured memory_bytes: 3940
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

void solve(){
	int n , k ;
	cin >> n >> k ;
	vi ans(n,-1) ;
	for(int i = 0 ; i < k ; i++){
		int x,y ;
		cin >> x >> y ;
		--x ;
		if(ans[x] == -1){
			ans[x] = y ;
		}
		else if(ans[x] != -1){
			if(ans[x] == y){

			}
			else{
				cout << -1 << endl ;
				return ;
			}
		}
	}	
	if(ans.size() == 1 && ans[0] <= 0){
		cout << 0 << endl ;
		return ;
	}
	if(ans.size() > 1 && ans[0] == 0){
		cout << -1 << endl ;
		return ;
	}
	for(int i = 0 ; i < n ; i++){
		if(ans[i] == -1) ans[i]++ ;
	}
	if(ans[0] == 0){
		ans[0]++ ;
	}
	for(auto x : ans) cout << x ;
	cout << endl ;
	
}


int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int x, y; cin >> x >> y;
  cout << x + y / 2 << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int maxl = 0;
    for(int i = 0; i < n; i++){
        int l;
        cin >> l;
        sum += l;
        maxl = max(maxl, l);
    }
    sum -= maxl;
    cout << (maxl < sum ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int K, A, B;

int main(){
	getint(K), getint(A), getint(B);
	if(B - A <= 1 || K <= A) return printf("%d\n", K + 1), 0;
	const int rem =  K - A + 1;
	return printf("%lld\n", A + (B - A) * ll(rem >> 1) + (rem & 1)), 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int digitsum(int x){
  int sum=0;
  while(x>0){
    sum+=(x%10);
    x/=10;
  }
  return sum;
}

int main() {
  ll MOD=998244353;
  ll n,k;
  cin>>n>>k;
  llP lr[k];
  for(int i=0;i<k;i++){
    ll l,r;
    cin>>l>>r;
    lr[i]=make_pair(l,r);
  }
  sort(lr,lr+k);
  ll sum[n],d[n];
  d[0]=1,sum[0]=1;
  for(int i=1;i<n;i++){
    d[i]=0;
    for(int j=0;j<k;j++){
      int a=lr[j].first,b=lr[j].second;
      if(a>i) break;
      if(b<i){
        d[i]+=(sum[i-a]-sum[i-b-1]);
        d[i]=mod(d[i],MOD);
      }
      if(b>=i){
        d[i]+=sum[i-a];
        d[i]=mod(d[i],MOD);
      }
    }
    sum[i]=sum[i-1]+d[i];
    sum[i]=mod(sum[i],MOD);
  }
  cout<<d[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 6760
#include<cstdio>
#include<vector>
#include<set>


using namespace std;
using vi=vector<int>;
using si=set<int>;


class v_t
{
public:
	si c;
	si p;
	int x;
	v_t() : x(-1) {}
};


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vector<v_t> v(n+1);

		for(int i=0;i<n-1+m;i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			v[a].c.insert(b);
			v[b].p.insert(a);
		}
		int r=1;
		for(;;)
		{
			if(v[r].p.size()<=0) break;
			r=*v[r].p.begin();
		}
		v[r].x=0;

		vi q;
		q.push_back(r);
		for(int i=0;i<q.size();i++)
		{
			int c=q[i];
			int x=v[c].x;

			for(auto&mc:v[c].c)
			{
				if(v[mc].p.size()==1)
				{
					v[mc].x=x+1;
					q.push_back(mc);
				}
				else
				{
					v[mc].p.erase(v[mc].p.find(c));
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			int ans=0;
			if(v[i].p.size()>=1)
			{
				ans=*(v[i].p.begin());
			}
			printf("%d\n", ans);
		}
	}

	return 0;
}


Measured memory_bytes: 20860
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> p(N);

    REP(i, N)
    {
        string city;
        int point;
        cin >> city >> point;
        p.at(i) = make_pair(make_pair(city, -point), i);
    }

    sort(p.begin(), p.end());
    REP(i, N)
    {
        cout << p.at(i).second + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  std::cin >> n;
  int am=n%100;
  int sh=n/100;
  if(n<100)std::cout << "0" << '\n';
  else if(sh*5>=am)std::cout << "1" << '\n';
  else  std::cout << "0" << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc=new Scanner(System.in);
    		long a=sc.nextLong(),b=sc.nextLong(),x=sc.nextLong(),c=0;
    		c=b/x-a/x;
    		if(a%x==0){
    			c++;
    }
    	System.out.println(c);
    }
    }

Measured memory_bytes: 23764
#include<cstdio>
long long N,A,B;
int main()
{
    scanf("%lld%lld%lld",&N,&A,&B);
    long long s;
    scanf("%lld",&s);
    long long ans=0;
    for(int i=1;i<N;i++)
    {
        long long x;
        scanf("%lld",&x);
        if((x-s)*A<B)
            ans+=(x-s)*A;
        else
            ans+=B;
        s=x;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	uf := MakeUnionFind(N)
	for i := 0; i < M; i++ {
		A, B := ReadInt()-1, ReadInt()-1
		uf.Unite(A, B)
	}
	max := 0
	for i := 0; i < N; i++ {
		size := uf.Size(i)
		if size > max {
			max = size
		}
	}
	fmt.Println(max)
}

type UnionFind []int

func MakeUnionFind(size int) UnionFind {
	uf := make([]int, size)
	for i := 0; i < size; i++ {
		uf[i] = -1
	}
	return uf
}
func (uf UnionFind) Root(x int) int {
	if uf[x] < 0 {
		return x
	}
	uf[x] = uf.Root(uf[x])
	return uf[x]
}
func (uf UnionFind) Unite(x, y int) {
	x, y = uf.Root(x), uf.Root(y)
	if x == y {
		return
	}
	if uf[x] > uf[y] {
		x, y = y, x
	}
	uf[x] += uf[y]
	uf[y] = x
}
func (uf UnionFind) Connected(x, y int) bool { return uf.Root(x) == uf.Root(y) }
func (uf UnionFind) Size(x int) int          { return -uf[uf.Root(x)] }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 6320
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	long long a[6];
	for(int i=0;i<6;i++)cin>>a[i];
	long long ans = 0;
	for(int i=0;i<5;i++){
			ans = max(lldiv(a[0],a[i+1]).quot - (lldiv(a[0],a[i+1]).rem == 0LL ? 1LL : 0LL),ans);
	}
	cout<<ans+5<<endl;
	return 0;
}

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

int main(void){
    double r;
    double S, L;
    cin >> r;
    S = r*r*3.141592653589;
    L = r*2*3.141592653589;
    printf("%f %f\n", S, L);

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
void solve() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for (int i=0;;++i) {
		if (i&1) a-=d;
		else c-=b;
		if (a<=0) {
			cout<<"No\n";
			return;
		} else if (c<=0) {
			cout<<"Yes\n";
			return;
		}
	}
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	map<int, int> numMap;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		numMap[a[i]] += 1;
	}

	int ans = 0;

	for (int i = 0; i < N; ++i) {
		int value = 0;
		value = numMap[a[i]] + numMap[a[i] - 1] + numMap[a[i] + 1];
		if (value > ans) {
			ans = value;
		}
	}


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

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:


bool can_out(int l, int s, string a, string b, char hc, char tc){
	int head = 0, tail = l - 1;
	const int n = a.size();

	rrep(i, n){
		if(head > tail) break;

		if(b[i] == hc){
			tail++;
			chmin(tail, l - 1);
		}

		if(b[i] == tc){
			head--;
			chmax(head, 0);
		}

		if(a[i] == hc){
			head++;
			chmax(head, 0);
		}

		if(a[i] == tc){
			tail--;
			chmin(tail, l - 1);
		}
	}

	if(head <= s and s <= tail) 
		return false;
	else
		return true;
}


int main(void){
	int h, w, n;
	cin >> h >> w >> n;
	
	int sr, sc;
	cin >> sr >> sc;
	sr--, sc--;

	string s;
	string t;
	cin >> s >> t;

	bool out = false;

	out |= can_out(h, sr, s, t, 'U', 'D');
	out |= can_out(w, sc, s, t, 'L', 'R');
	
	if(out == false)
		puts("YES");
	else
		puts("NO");

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
    return *(double*)a - *(double*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int a ,b, c, d, e, X, Y;
  double d_a,d_b, d_temp, d_count;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  double  A[100003]={};
  long long  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
  for(i=0;i<a;i++){
    scanf("%lf", &A[i]);
//    printf("A=%lf\n",A[i]);
  }
  qsort(A, a, sizeof(double), compare_int);
//  for(i=0;i<a;i++){
//    scanf("%lf", &A[i]);
//    printf("A=%lf\n",A[i]);
//  }
  d_temp=A[0];
  for(i=0;i<a-1;i++){
    d_temp=(d_temp+A[i+1])/2;
  }
  
//  if(a<3200)  printf("red\n");
//  else   printf("%s\n",t);
  printf("%lf\n",d_temp);
 

return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> l(n+1,0);
  l.at(0) = 2;
  l.at(1) = 1;
  FOR(i,2,n+1) l.at(i) = l.at(i-1) + l.at(i-2);

  cout << l.at(n) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

a_s, b_s, c_s = sorted(a), sorted(b), sorted(c)

a_idx, c_idx = 0, 0
small_at, big_at = [], []
small_cnt, big_cnt = 0, 0

for i in b_s :
    while a_idx < N and a_s[a_idx] < i :
        a_idx += 1
        small_cnt += 1
        
    while c_idx < N and c_s[c_idx] <= i :
        c_idx += 1
        big_cnt += 1
        
    small_at.append(small_cnt)
    big_at.append(big_cnt)
    
sum_comb = 0 
for i in range(N) :
    sum_comb += small_at[i] * (N - big_at[i])

print(sum_comb)

Measured memory_bytes: 27060
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

vector<int> inv(vector<int> vec) {
    int N = vec.size();
    vector<int> res(N);
    for(int i=0; i<N; i++) {
        res[ vec[i] ] = i;
    }
    return res;
}

vector<int> mul(vector<int> A, vector<int> B) {
    int N = A.size();
    vector<int> res(N);
    for(int i=0; i<N; i++) {
        res[i] = A[ B[i] ];
    }
    return res;
}

vector<int> mod_pow(vector<int> A, int k) {
    int N = A.size();
    vector<int> res(N);
    iota(res.begin(), res.end(), 0);
    for(; k>0; k>>=1) {
        if(k & 1) res = mul(res, A);
        A = mul(A, A);
    }
    return res;
}

signed main() {
    int N, K; cin >> N >> K;
    vector<int> p(N), q(N);
    for(int i=0; i<N; i++) cin >> p[i], p[i]--;
    for(int i=0; i<N; i++) cin >> q[i], q[i]--;
    vector<int> ip = inv(p), iq = inv(q);

    vector<int> prod = mul(mul(mul(q, ip), iq), p);
    vector<int> A = mod_pow(prod, (K - 1) / 6);

    int mod = (K - 1) % 6;
    vector<int> B;
    if(mod == 0) B = p;
    else if(mod == 1) B = q;
    else {
        vector<int> X = p, Y = q;
        for(int i=0; i<mod-1; i++) {
            vector<int> Z = mul(Y, inv(X));
            X = Y, Y = Z;
        }
        B = Y;
    }

    vector<int> ans = mul(mul(A, B), inv(A));
    for(int i=0; i<N; i++) {
        printf("%lld%c", ans[i] + 1, i+1 == N ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 10992
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();

		if(S.equals(U)) A--;
		else if(T.equals(U)){
			B--;
		}

		System.out.printf("%d %d",A,B);
		sc.close();
	}

}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
typedef long long ll;



int main() {
	string s, t;
	cin >> s >> t;
	VVI v(26, vector<int>(26, 0));
	REP(i, s.size()) {
		v[s[i] - 'a'][t[i] - 'a'] = 1;
	}
	REP(i, 26) {
		int n = 0;
		REP(j, 26) {
			if (v[i][j])n++;
		}
		if (n > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	REP(i, 26) {
		int n = 0;
		REP(j, 26) {
			if (v[j][i])n++;
		}
		if (n > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> v = vector<int>(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end(), greater<>());

    cout << stoi(to_string(v[0]) + to_string(v[1])) + v[2] << "\n";
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>
 
using namespace std;

const int INF = 1e9 + 239;
const int N = 1e6 + 7;
const vector<int> dx = {0, 0, 1, -1};
const vector<int> dy = {1, -1, 0, 0};

int d[4 * N];
vector<int> g[4 * N];

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

	int n, m, K;
	cin >> n >> m >> K;
	int i1, i2, j1, j2;
	cin >> i1 >> j1 >> i2 >> j2;
	i1--;
	i2--;
	j1--;
	j2--;
	vector<vector<int>> ban(n, vector<int> (m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			ban[i][j] = (c == '@');
		}
	}
	fill(d, d + 4 * n * m, INF);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < 4; k++) {
				int ni = i + dx[k];
				int nj = j + dy[k];
				if (0 <= ni && ni < n && 0 <= nj && nj < m && !ban[i][j] && !ban[ni][nj]) {
					g[i * m + j + k * n * m].push_back(ni * m + nj + k * n * m);
				}
			}
		}
	}	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (!ban[i][j]) {
				for (int k = 0; k < 4; k++) {
					g[i * m + j + k * n * m].push_back(i * m + j + ((k + 1) % 4) * n * m);
				}
			}
		}
	}
	d[i1 * m + j1] = 0;
	set<pair<int, int>> s;
	s.insert({d[i1 * m + j1], i1 * m + j1});
	while (!s.empty()) {
		int v = s.begin()->second;
		s.erase(s.begin());
		// cerr << d[v] << endl;
		for (auto t : g[v]) {
			if (abs(t - v) % (n * m)) {
				if (d[t] > d[v] + 1) {
					s.erase({d[t], t});
					d[t] = d[v] + 1;
					s.insert({d[t], t});
				}
			} else {
				if (d[t] > ((d[v] + K - 1) / K) * K) {
					s.erase({d[t], t});
					d[t] = ((d[v] + K - 1) / K) * K;
					s.insert({d[t], t});
				}
			}
		}
	}
	int ans = d[i2 * m + j2];
	if (ans == INF) {
		cout << -1 << endl;
	} else {
		cout << (ans + K - 1) / K << endl;
	}
}

Measured memory_bytes: 240312
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

const db pi = 3.141592653;

int32_t main() {
  FAST_IO;
  int r;
  cin >> r;
  cout << 2.0 * pi * r << '\n';
  rtn 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  int i=0;
  cin>>a>>b;
  while(a[i]!='\0'){
    if(a[i]!=b[i]){
      cout<<"No"<<"\n";
      return(0);
    }
    i++;
  }
  cout<<"Yes"<<"\n";
  return(0);
}


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

B = [0]*N

for i in range(N-1, -1, -1):
  count = 0
  for j in range(i, N, i+1):
    count += B[j]
  if count%2 == A[i]:
    B[i] = 0
  else:
    B[i] = 1

sum = sum(B)
if sum == 0:
  print(0)
else:
  print(sum)
  ans = []
  for i in range(N):
    if B[i] == 1:
      ans.append(i+1)
  print(*ans)


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

#define ll long long

using namespace std;

const int MAX = 50;

int main()
{
	int n, m;
	char a[MAX][MAX], b[MAX][MAX];
	cin >> n >> m;
	
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> a[i][j];
		}
	}
	
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> b[i][j];
		}
	}
	
	bool exits = false;
	
	for (int ay = 0; ay < n; ++ay) {
		for (int ax = 0; ax < n; ++ax) {
			
			if (ay + m -1 >= n || ax + m - 1 >= n) continue;
			
			bool match = true;
			for (int by = 0; by < m; ++by) {
				for (int bx = 0; bx < m; ++bx) {
					if (a[ay + by][ax + bx] != b[by][bx]) match = false;
				}
			}
			
			if (match) exits = true;
			
		}
	}
	
	exits ? cout << "Yes" : cout << "No";
	
	return 0;
}


Measured memory_bytes: 256