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

int n,pos1,pos2,pos=0;
int permutation[10],a[10],b[10];

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  cin>>b[i];
	for (int i=1;i<=n;i++)  permutation[i]=i; 
	do
	{
		pos++;
		int flaga=1,flagb=1;
		for (int i=1;i<=n;i++)
		{
			if (a[i]!=permutation[i])
			{
				flaga=0;
				break;
			}
		}
		for (int i=1;i<=n;i++)
		{
			if (b[i]!=permutation[i])
			{
				flagb=0;
				break;
			}
		}
		if (flaga)  pos1=pos;
		if (flagb)  pos2=pos;
	}while (next_permutation(permutation+1,permutation+n+1));
	
	cout<<abs(pos1-pos2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

const ll inf=9223372036854775806;
int a[101],t,ans=0,n,j;

void f(int l,int r){
	int l1=l,r1=r,i;
	if (l1==r1){
		return ;
	}
	int m=1000000;
	for (i=l1;i<r1;i++){
		m=min(m,a[i]);
	}
	ans+=m;
	int t=l1;
	for (i=l1;i<r1;i++){
		a[i]-=(a[i]>=m)?m:0;
	}
	for (i=l1;i<=r1;i++){
		if (a[i]==0){
			f(t,i);
			t=i+1;
		}
	}
}

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for (j=0;j<n;j++){
		cin>>a[j];
	}
	a[n]=0;
	f(0,n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES

int a[1234567];
vector<int> g[1234567];
bool ans[1234567],res[1234567];

bool poss (int v)
{
    if(ans[v])
    {
        return res[v];
    }
    bool temper = false;
    for(int i=0;i<g[v].size();i++)
    {
        int temp = g[v][i];
        if(a[temp]>=a[v])
            continue;
        if(!poss(temp))
            temper = true;
    }  
    ans[v] = true;
    res[v] = temper;
    return temper;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=0;i<n;i++)
    {
        ans[i]=false;
    }
    for(int i=0;i<n;i++)
    {
        if(poss(i))
            cout<<i+1<<" ";
    }
    return 0;
}

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

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let n: usize = read();
    let a: Vec<i64> = (0..n).map(|_| read()).collect();
    let b: Vec<i64> = (0..n).map(|_| read()).collect();

    let a_sum:i64 = a.iter().sum();
    let b_sum:i64 = b.iter().sum();

    let mut OKs:Vec<i64> = Vec::new(); 
    let mut NGs:i64 = 0;
    let mut change_num:usize = 0;

    if a_sum >= b_sum {
        for i in 0..n{
            if a[i] >= b[i]{
                OKs.push(a[i]-b[i]);
            }else{
                NGs += b[i] - a[i];
                change_num += 1;
            }
        }
        if change_num != 0 {
            OKs.sort_by(|x,y| y.cmp(x));
            for i in 0..OKs.len(){
                NGs -= OKs[i];
                change_num += 1;
                if NGs <= 0 {
                    break;
                }
            }
        }
    println!("{}",change_num);
    }else{
        println!("-1");
    }

}

Measured memory_bytes: 4232
#include <iostream>
using namespace std;
 
int main(){
    int n, tmp;
    cin >> n;
    for(int i=1;i<n+1;i++){
        if(i%3==0){
            cout << " " << i;
        }else{
            tmp = i;
            while(tmp>0){
                if(tmp%10==3){
                    cout << " " << i;
                    break;
                }else{
                    tmp /= 10;
                }
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3124
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        String[] num = str.split(" ",0);
        int a,b;
        a = Integer.valueOf(num[0]);
        b = Integer.valueOf(num[1]);
        System.out.println(a*b+" "+2*(a+b));
        scan.close();
    }
}



Measured memory_bytes: 26000
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	string s;
	bool ans = true;
	cin >> s;
	for (i = 0; i < 3; i++)
	{
		if (s[i] == s[i + 1])
			ans = false;
	}
	if (ans)
		cout << "Good" << endl;
	else
		cout << "Bad" << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
  if a[i]==b[i]==c[i]:
    continue
  elif a[i]!=b[i]!=c[i]!=a[i]:
    count += 2
  else:
    count += 1

print(count)

Measured memory_bytes: 38384
#include<stdio.h>

int main(void){

    int S;
    scanf("%d",&S);
    int A = S/100;
    int B = S%100;

    if(A<0||B<0){
        printf("NA");
        return 0;
    }

    int Achk = 0;
    int Bchk = 0;
    
    if(A>0&&A<13){
        Achk = 1;
    }
    if(B>0&&B<13){
        Bchk = 1;
    }

    if(Achk == 1 && Bchk == 1){
        printf("AMBIGUOUS");
        return 0;
    }
    if(Achk != 1 && Bchk == 1){
        printf("YYMM");
        return 0;
    }
    if(Achk == 1 && Bchk != 1){
        printf("MMYY");
        return 0;
    }
    if(Achk != 1 && Bchk != 1){
        printf("NA");
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<string> s(N);
  rep(i,N)
  {
    cin >> s[i];
  }
  int M;
  cin >> M;
  vector<string> t(M);
  rep(i,M)
  {
    cin >> t[i];
  }
  vector<int> ss(N),tt(M);
  rep(i,N)
  {
    rep(j,N)
    {
      if(s[i]==s[j])
      {
        ss[i] ++;
      }
    }
  }
  rep(i,N)
  {
    rep(j,M)
    {
      if(s[i]==t[j])
      {
        ss[i] --;
      }
    }
  }
  int m = 0;
  rep(i,N)
  {
    m = max(m,ss[i]);
  }
  
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
  N, K = map(int, input().split())
  s = input()
  S = []
  look = s[0]
  cnt = 0

  if s[0] == '0': S.append(0)
  for c in s:
    if look == c: cnt += 1
    else:
      S.append(cnt)
      cnt = 1
      look = c
  S.append(cnt)
  if s[-1] == '0': S.append(0)

  num = min(len(S), 2 * K + 1)
  part = sum(S[0:num])
  ans = part

  for i in range(0, len(S) - num, 2):
    part += - sum(S[i:i+2]) + sum(S[i + num:i + num + 2])
    ans = max(ans, part)
  return ans

print(solve())


Measured memory_bytes: 4476
A = [[int(x) for x in input().split()] for i in range(3)]
n = int(input())
B = set(int(input()) for i in range(n))
res = False
for row in A:
    if all(x in B for x in row):
        res = True
for j in range(3):
    if all(A[i][j] in B for i in range(3)):
        res = True
if all(A[i][i] in B for i in range(3)):
    res = True
if all(A[i][2 - i] in B for i in range(3)):
    res = True
print("Yes" if res else "No")

Measured memory_bytes: 9224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 1000005
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,d,h;
ll fct[maxn],k,g[maxn << 1];
int main(){
  n = getint(), h = getint(), d = getint();
  fct[0] = 1;
  for(int i = 1;i <= n;i++) fct[i] = (ll)fct[i - 1] * i % mod;
  for(int i = 1;i <= n;i++) (k += fct[i]) %= mod;
  g[h] = 1; ll sum = 1;
  for(int i = h - 1;i >= 1;i--){
    g[i] = (ll)k * sum % mod;
    (sum += g[i] - g[i + d] + mod) %= mod;
  }
  printf("%lld\n",(ll)fct[n] * sum % mod);
  return 0;
}


Measured memory_bytes: 17536
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<ll,ll,ll>

struct BIT
{
    std::vector<int> bit;
    
    BIT(int size) : bit(size, 0){ }
    
    void add(int k, int x) {
        while (k < bit.size()) {
            bit[k] += x;
            k += k &-k;
        }
    }
    int sum(int k) {
        int res = 0;
        while (k > 0) {
            res += bit[k];
            k -= k&-k;
        }
        return res;
    }
};

struct UnionFind {
    vector<int> data;
    
    UnionFind(int size) : data(size, -1) { }
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

vector<int> g[10];
int n, m;

ll dfs(int p, unordered_set<int> b)
{
    auto s = b.size();
    if(s == n)
    {
        return 1;
    }
    ll sum = 0;
    for(auto e: g[p])
    {
        if(b.find(e) == b.end())
        {
            auto nb = b;
            nb.insert(e);
            sum += dfs(e, nb);
        }
    }
    return sum;
}

int main(void)
{
    cin >> n >> m;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    unordered_set<int> d;
    d.insert(1);
    cout << dfs(1, d) << endl;
    return 0;
}

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

#define endl '\n'
#define fr first
#define sc second

using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 1e5 + 1, INF = 1e9;
ll LINF = 1e18;
const double EPS = 1e-8;

main()
{
//    freopen("input.txt", "r", stdin);
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d", max(0, min(b, d) - max(a, c)));
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
hen = [key for key, val in c.items() if val > 1]

l = max(hen) if hen else 0
if l != 0:
    if c[l] > 3:
        s = l
    else:
        hen.remove(l)
        s = max(hen) if hen else 0
else:
    s = 0

print(l * s)


Measured memory_bytes: 18600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

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

void solve() {
    string s;
    cin >> s;

    string a[3] = {"Sunny", "Cloudy", "Rainy"};

    int idx = -1;

    for (int i = 0; i < 3; i++) {
        if (s == a[i]) {
            idx = (i + 1) % 3;
            break;
        }
    }

    cout << a[idx] << endl;
}

int main()
{
    IOS;
    //comment it out
    //freopen("input.txt", "r", stdin);
    lli t = 1;
    //cin >> t;
    while (t--) {
        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);
		
		while(true){
			int m = sc.nextInt();
			int n = sc.nextInt();
			if(m==0 && n==0) break;
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i=1;i<=m;i++) list.add(i);
			
			String s;
			int k = 0;
			for(int i=1;i<=n;i++){
				s = sc.next();
				if(list.size()>1){
					if(i%15==0){
						if(s.compareTo("FizzBuzz")==0) k++;
						else list.remove(k);
					}else if(i%5==0){
						if(s.compareTo("Buzz")==0) k++;
						else list.remove(k);
					}else if(i%3==0){
						if(s.compareTo("Fizz")==0) k++;
						else list.remove(k);
					}else{
						if(s.compareTo(Integer.toString(i))==0) k++;
						else list.remove(k);
					}
					if(k==list.size()) k=0;
				}
			}
			for(int i=0;i<list.size();i++){
				if(i!=0) System.out.print(" ");
				System.out.print(list.get(i));
			}
			System.out.println();
		}	
	}	
}

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

using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N;
int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    int ndiff = 0;
    for (int i = 0; i < N; i++)
    {
        int x; cin >> x;
        if (!arr[x]) ndiff++;
        arr[x] = 1;
    }

    if (ndiff % 2 == 0) ndiff--;
    cout << ndiff << "\n";
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 10000; // 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int N; cin >> N;
    VL A(N); REP(i,N) cin >> A[i];
    ll dp[N]; REP(i,N) dp[i] = 0; dp[0] = 1000;
    REP(i,N-1){
        chmax(dp[i+1], dp[i]);
        REP(j,i+1){
            chmax(dp[i+1], dp[j]%A[j] + dp[j]/A[j]*A[i+1]);
        }
    }
    cout << dp[N-1] << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;

import javax.lang.model.util.ElementScanner6;

 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int k=sc.nextInt();
      String s=sc.next();

      if(s.length()<=k){
          out.println(s);
      }else{
          out.println(s.substring(0, k)+"...");
      }
      
      out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 36680
from collections import Counter
from itertools import accumulate

N = int(input())
inputs = [int(i) for i in input().split()]

ans = 0

ruisekiwa = list(accumulate(inputs))

for key, value in Counter(ruisekiwa).items():
    if key == 0 and value == 1:
        ans += value
        continue
    elif key == 0 and value > 1:
        ans += value
    if value > 1:
        ans += value * (value - 1) // 2

print(ans)


Measured memory_bytes: 41472
#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;++i)
#define cost first
#define to second
typedef long long ll;
typedef pair<ll,int> edge;

#define MAX 100001
vector<edge> G[MAX];
ll dp[MAX][10];
priority_queue<edge,vector<edge>,greater<edge>> qu;

int main(){
	int N,M,R,Q,a,b,c;
	cin>>N>>M>>R>>Q;
	rep(i,M){
		cin>>a>>b>>c;
		G[b].push_back({c,a});
	}
	rep1(i,N)rep(r,R) dp[i][r] = LLONG_MAX/4;
	rep(r,R){
		rep1(i,N){
			if(i%R==r){
				dp[i][r]=0;
				qu.push({0,i});
			}
		}
		while(qu.size()){
			edge v=qu.top(); qu.pop();
			if(dp[v.to][r] < v.cost)continue;
			for(auto e:G[v.to]){
				if(dp[e.to][r] > dp[v.to][r] + e.cost){
					dp[e.to][r] = dp[v.to][r] + e.cost;
					qu.push({dp[e.to][r],e.to});
				}
			}
		}
	}
 
	ll res=0;
	rep(_,Q){
		int x,y,z;
		cin>>x>>y>>z;
		ll get=0;
		rep(r,R){
			get = max(get,z-(dp[x][r]+dp[y][r]));
		}
		res += get;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 17308
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define i(x) cin>>x
#define fr(n,x) for(ll n=0;n<x;n++)
#define pf(x) cout<<x
const ll mod=1e9+7 ;

void solv()
{
    ll x;
    string s;
    cin>>x>>s;
    ll wt=0,rd=0;
    fr(n,x)
    {
        s[n]=='W'?wt++:rd++;
    }
    ll res=0;
    for(ll n=x-1;n>=x-wt;n--)
    {
        if(s[n]=='R')res++;
    }
    cout<<min(res,min(wt,rd));
}

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)solv();
}

Measured memory_bytes: 3732
#include <stdio.h>
int main(void){
    int k,i;
    char s[101];
    scanf("%d %s",&k,s);
    for(i=0; i<k && s[i]!='\0'; i++)
        printf("%c",s[i]);
    if(s[i]!='\0')
        printf("...");
}


Measured memory_bytes: 1672
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let a: u64 = iter.next().unwrap().parse().unwrap();
    let mut b_str: String = iter.next().unwrap().parse().unwrap();
    b_str.remove(1);

    let b: u64 = b_str.parse().unwrap();

    let prod = a * b / 100;

    println!("{}", prod);
}


Measured memory_bytes: 2140
def change(X, coin):
    """ exchange
    :param X: total money
    :param coin: 500 or 5
    :return: reduced X and num of coins
    """
    num = X // coin
    X -= coin * num
    return X, num

if __name__ == '__main__':
    X = int(input())
    ans = 0
    X, num = change(X, 500)
    ans += 1000 * num
    X, num = change(X, 5)
    ans += 5 * num
    print(ans)


Measured memory_bytes: 8972
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==5){
    if((b==5&&c==7)||(b==7&&c==5)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  else if(b==5){
    if((a==5&&c==7)||(a==7&&c==5)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }  
  else if(c==5){
    if((b==5&&a==7)||(b==7&&a==5)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗, int 2*10^9

int main() {
  int N, K;
  ci(N, K);
  ve<ll> H(N);
  rep(i, N){
    ci(H.at(i));
  }
  so(H);
  if(K > N){
    co(0);
    rt;
  }
  ll a = 0;
  rep(i, N - K){
    a += H.at(i);
  }
  co(a);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int a[h][w]={};
  while(n--){
    int x,y,z;
    cin>>x>>y>>z;x--;y--;
    if(z==1)for(int i=0;i<h;i++)for(int j=0;j<=x;j++)a[i][j]=1;
    if(z==2)for(int i=0;i<h;i++)for(int j=w-1;j>x;j--)a[i][j]=1;
    if(z==3)for(int i=0;i<w;i++)for(int j=0;j<=y;j++)a[j][i]=1;
    if(z==4)for(int i=0;i<w;i++)for(int j=h-1;j>y;j--)a[j][i]=1;
  }int sum=0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(!a[i][j])sum++;
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    int[] numbers = new int[number];
    for (int i = 0; i < number; i++) {
      numbers[i] = sc.nextInt();
    }
    int[] count = new int[number];
    for (int j = 0; j < number; j++) {
      while(numbers[j] % 2 == 0) {
        numbers[j] /= 2;
        count[j]++;
        }
      }
    Arrays.sort(count);
    System.out.println(count[0]);
    
  }
}

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

typedef long long ll;

int ans[100][100];

int main(){
  int n, y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      int tmp=1000*i+5000*j;
      if(tmp==y&&i+j==n){
	cout<<0<<" "<<j<<" "<<i<<endl;
	return 0;
      }else{
	int res=y-tmp;
	if(res%10000==0){
	  if(res/10000+i+j==n){
	   cout<<res/10000<<" "<<j<<" "<<i<<endl;
	    return 0;
	  }
	}
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    ll n, a, b; cin >> n >> a >> b;
    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    } else {
        cout << min((a + b - 1) / 2, (2 * n - a - b + 1) / 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stdint.h>

int as[50];
int bs[50];

int can[51][51][51];

void compute_can(){
  for(int a=0;a<=50;a++){
    can[0][a][a]=1;
  }
  for(int k=1;k<=50;k++){
    for(int a=0;a<=50;a++){
      for(int b=0;b<=50;b++){
	can[k][a][b]=can[k-1][a][b]|can[k-1][a%k][b];
      }
    }
  }
}

bool somecan(int64_t k,int64_t mask,int b){
  for(int z=50;z>=0;z--){
    if((mask&(1LL<<z))&&can[k][z][b]){
      return true;
    }
  }
  return false;
}

int main(){
  compute_can();
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d",&as[i]);
  }
  for(int i=0;i<N;i++){
    scanf("%d",&bs[i]);
  }
  for(int i=0;i<N;i++){
    if(can[50][as[i]][bs[i]]==0){
      printf("-1\n");
      return 0;
    }
  }
  int64_t set[51];
  for(int i=0;i<N;i++){
    set[i]=(1LL<<as[i]);
  }
  int64_t total=0;
  for(int k=50;k>0;k--){
    bool use=false;
    for(int i=0;i<N;i++){
      if(somecan(k,set[i],bs[i])&&!somecan(k-1,set[i],bs[i])){
	use=true;
	break;
      }
    }
    if(use){
      //printf("USE %d\n",k);
      total|=(1LL<<k);
      for(int i=0;i<N;i++){
	for(int b=0;b<=50;b++){
	  if(set[i]&(1LL<<b)){
	    set[i]|=(1LL<<(b%k));
	  }
	}
      }
    }
  }
  printf("%ld\n",total);
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int N;

int main() {
  cin >> N;
  while (N > 0) {
    int r = N % 10;
    if (r == 9) {
      cout << "Yes";
      return 0;
    }
    N /= 10;
  }
  cout << "No";
}


Measured memory_bytes: 3600
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365)]
for i in range(D):
  s[i] = np.array( list(map(int, input().split())) )
#
last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)

def fav(d,c):
  return( s[d] - sum( c*(d-last) ) + c*(d-last) )
#
v = 0
for d in range(D):
  c2 = c*min(D-d,13)
  av = fav( d, c )
  av2 = fav( d, c2 )
  av2 += av
  m = max(av2)
  for t in range(26):
    if av2[t] == m:
      last[t] = d
      v += av[t]
      print(t+1)
      break
#


Measured memory_bytes: 27348
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005


ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


/////////////////////////////////////////////////////////////////


ll f(ll b,ll n){
    if(b>n)return n;
    else return f(b,n/b)+n%b;
}

int main(){
    ll n,s;cin>>n>>s;
    vector<ll>ans;
    ll p=(ll)sqrt(n);
    for(ll b=2;b<=p;b++){
        if(f(b,n)==s){
            ans.pb(b);
        }
    }
    for(ll x=p+1;x>=1;x--){
        if((n-s)%x!=0)continue;
        ll b=(n-s)/x+1;
        if(b>=2&&f(b,n)==s){
            ans.pb(b);
        }
    }
    if(s==1&&n!=1){ans.pb(n);}
    if(n==s)ans.pb(n+1);
    if(ans.size()>=1){
        sort(ans.begin(),ans.end());
        cout<<ans[0]<<endl;
    //    for(auto x:ans)cout<<x<<" ";
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

signed main() {
	int N;
	cin >> N;

	vector<int> T;
	inputVector(T, N);

	sort(all(T));

	int now = 1;
	rep(i, N) {
		now *= T[i] / gcd(now, T[i]);
	}

	cout << now << endl;

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE TypeFamilies, BangPatterns, FlexibleContexts #-}
import Data.Array
import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.Unsafe
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as U
import Data.Int
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as B
import Data.ByteString(ByteString)
import Data.Char

type Scanner a = StateT ByteString IO a
type family Freeze a where
  Freeze (IOUArray i v) = UArray i v
  Freeze (IOArray i v) = Array i v

foldM :: Monad m => (b -> a -> m b) -> b -> [a] -> m b
foldM f z0 xs = foldr c return xs z0
    where c x k = \z -> f z x >>= k
          {-# INLINE c #-}

scan :: Read a => Scanner a
scan = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s 
        !v = read (B.unpack s1)
    in (v, B.dropWhile isSpace s2)

scanInt :: Scanner Int
scanInt = scan

scanString :: Scanner B.ByteString
scanString = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s in
    (s1, B.dropWhile isSpace s2)

scanReal :: Scanner Double
scanReal = scan

newtype M = M Int
    deriving Show

modulo = 1000000007

instance Num M where
    M a + M b = M $ (a + b) `mod` modulo
    M a - M b = M $ (a - b) `mod` modulo
    M a * M b = M $ (a * b) `mod` modulo
    fromInteger x = M $ fromInteger x `mod` modulo
    abs = id
    signum _ = M 1

instance Fractional M where
    recip (M x) = M (recipM x modulo)

data EGCD = EGCD !Int !Int !Int

{-# NOINLINE recipM #-}
recipM :: Int -> Int -> Int
recipM x m | g /= 1 = error $ "No inverse for " ++ show x ++ " % " ++ show m 
           | s <  0 = s + m
           | otherwise = s
    where 
    EGCD s _ g = extgcd x m

extgcd :: Int -> Int -> EGCD
extgcd = go
    where 
    go a 0 = EGCD 1 0 a
    go a b = EGCD t (s - q * t) g
        where
        (q, r) = quotRem a b
        EGCD s t g = go b r

main :: IO ()
main = B.getContents >>= \content -> flip evalStateT content $ do
    vB <- scanInt
    vW <- scanInt
    liftIO $ solve vB vW

solve :: Int -> Int -> IO ()
solve vB vW = do
    let n = vB + vW
    let factTbl = U.unfoldrN (n + 1) factGen (1,1)
        factGen :: (M, Int) -> Maybe (Int, (M, Int))
        factGen (M m, i) = Just (m, (M m * M i, i + 1))
        fact :: Int -> M
        fact n = M (factTbl U.! n )
        comb :: Int -> Int -> M
        comb x y = fact x / (fact y * fact (x - y)) 
    let go !i !p !q = when (i < n) $ do
            let M z = p + (1 / 2) * ( 1 - p - q)
                p' | i + 1 < vW = 0
                   | otherwise = p + (1 / 2)^(i + 1) * comb i (vW-1)
                q' | i + 1 < vB = 0
                   | otherwise = q + (1 / 2)^(i + 1) * comb i (vB-1)
            print z
            go (i + 1) p' q'
    go 0 0 0


Measured memory_bytes: 4860
#include<iostream>
#include<vector>
#define ll long long 
using namespace std;
int main(){
	ll N,D;
	cin >> N >> D;
	if (N % (2 * D + 1) == 0){
		cout << N / (2 * D + 1) << endl;
	}
	else cout << N / (2 * D + 1)+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
int main(){
    cin >> S;
    for(int i = 0;i < 3; i++){
        if(S[i] == '1'){
            S[i] = '9';
        }else{
            S[i] = '1';
        }
    }
    
    cout << S << endl;
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define INF 2000000000
using namespace std;
int n,k;
int h[100000];
int dp[100001];
int main(){
  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> h[i];
  for(int i=1;i<=n;i++) dp[i]=INF;
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<k&&i>=j;j++){
      dp[i+1]=min(dp[i+1],dp[i-j]+abs(h[i-j]-h[i+1]));
    }
  }
  cout << dp[n-1] << "\n";

  return 0;
}


Measured memory_bytes: 1152
#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;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll ans=INF;
    string s;cin >>s;
    string t;cin >>t;
    ll n=s.size();
    ll m=t.size();
    for (int i = 0; i < n; ++i) {
        string sub=s.substr(i,m);
        ll now=0;
        if(sub.size()!=m)break;
        for (int j = 0; j < m; ++j) {
            if(sub[j]!=t[j])now++;
        }
        ans=min(ans,now);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3604
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const long MOD = 1000000007;
ll res=0;

int main(){
    ll N;cin>>N;
    if(N%2==1){
        cout<<0<<endl;
        return 0;
    }
    while(N>0){
        res+=N/10;
        N/=5;
    }

    cout<<res<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#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 VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
int main() {
	int a, b;
	cin >> a >> b;
	REP(i, 1500) {
		if (static_cast<int>(i * 0.08) == a && static_cast<int>(i * 0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[100000];
int y[100000];
int dx[]={1,1,1,0,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,0,-1,1,0,-1};
long long X[100000];
long long Y[100000];
pair<int,int> d[100000];
int abs(int a){
	return a<0?-a:a;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<c;i++){
		scanf("%d%d",&d[i].first,&d[i].second);
		x[i]=d[i].first;
		y[i]=d[i].second;
	}
	if(c==1){
		printf("%d\n%d %d\n",0,d[0].first,d[0].second);
		return 0;
	}
	std::sort(x,x+c);
	std::sort(y,y+c);
	X[0]=x[0];
	Y[0]=y[0];
	for(int i=1;i<c;i++){
		X[i]=X[i-1]+x[i];
		Y[i]=Y[i-1]+y[i];
	}
	long long ans=9999999999999999LL;
	int row=9999999;
	int col=9999999;
	for(int i=0;i<c;i++){
		int xat=lower_bound(x,x+c,d[i].first)-x;
		int yat=lower_bound(y,y+c,d[i].second)-y;
		int CenterX=c/2;
	//	if(c/2>=xat){
	//		;
	//	}else{
	//		CenterX--;
	//	}
		int CenterY=c/2;
	//	if(c/2>=yat){;}
	//	else CenterY--;
	//	printf("%d %d %d %d\n",xat,yat,x[CenterX],y[CenterY]);
		long long T;
		for(int j=0;j<9;j++){
			CenterX+=dx[j];
			CenterY+=dy[j];
			if(CenterX>=0&&CenterY>=0&&CenterX<c&&CenterY<c){
				T=-abs(x[CenterX]-d[i].first);
				T+=-abs(y[CenterY]-d[i].second);
				T+=((long long)(CenterX)*x[CenterX]-(CenterX?X[CenterX-1]:0))*2+(-(long long)(c-CenterX-1)*x[CenterX]+(X[c-1]-X[CenterX]))*2;
				T+=((long long)(CenterY)*y[CenterY]-(CenterY?Y[CenterY-1]:0))*2+(-(long long)(c-CenterY-1)*y[CenterY]+(Y[c-1]-Y[CenterY]))*2;
				
				//printf("%lld %lld %lld\n",T,((long long)(CenterX)*x[CenterX]-(CenterX?X[CenterX-1]:0))*2+(-(long long)(c-CenterX-1)*x[CenterX]+(X[c-1]-X[CenterX]))*2,((long long)(CenterY)*y[CenterY]-(CenterY?Y[CenterY-1]:0))*2+(-(long long)(c-CenterY-1)*y[CenterY]+(Y[c-1]-Y[CenterY]))*2);
				if(T<ans||(T==ans&&x[CenterX]<row)||(T==ans&&x[CenterX]==row&&y[CenterY]<col)){
					ans=T;
					row=x[CenterX];
					col=y[CenterY];
				}
			}
			CenterX-=dx[j];
			CenterY-=dy[j];
		}
	}
	printf("%lld\n%d %d\n",ans,row,col);
}
//..#...
//..###.
//.###..
//...#..

Measured memory_bytes: 3900
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:
    lst = s.split()

    # stack
    S = []

    for c in lst:
        if c == '+':
            a = S.pop()
            b = S.pop()
            S.append(b + a)
        elif c == '-':
            a = S.pop()
            b = S.pop()
            S.append(b - a)
        elif c == '*':
            a = S.pop()
            b = S.pop()
            S.append(b * a)
        elif c == '/':
            a = S.pop()
            b = S.pop()
            S.append(b / a)
        else:
            S.append(float(c))
    print(S[0])

Measured memory_bytes: 7444
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int x,y,z;
  cin >> x >> y >> z;
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << endl;


return 0;
}
///....


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

using namespace std;

const int INF=1e5+5;

int main(){
	int n,l;
	scanf("%d%d",&n,&l);
	int tot=0;
	for(int i=1;i<n+1;i++){
		tot+=(l+i-1);
	}
	int ans=INF,res=INF;
	for(int i=0;i<n;i++){
		int temp=tot-(l+i);
		if(abs(tot-temp)<ans){
			ans=abs(tot-temp);
			res=temp;
		}
	}
	printf("%d\n",res);
	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++)



int main(){
    int n; cin >> n;
    vector<long long int> l(n+1);
    l[0] = 2;
    l[1] = 1;
    if(n==1) cout << 1 << endl;
    else{
        for(int i=2; i<=n; i++){
            l[i] = l[i-1] + l[i-2]; 
        }
        cout << l[n] << endl;
    }

}

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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for(int i = 0; i <= A; ++i){
    for(int j = 0; j <= B; ++j){
      for(int k = 0; k <= C; ++k){
        if(500 * i + 100 * j + 50 * k == X) ++count;
    }
  }
}

cout << count << endl;

}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;

typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,s_pat=0;
    cin >> n;
    vll a(n),cnt(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    
    rep(i,n)s_pat += cnt[i]*(cnt[i] - 1) / 2;

    rep(i,n){
        cout << s_pat + 1 - cnt[a[i]] << endl;
    }

    return 0;
} 

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

long long dfs(int& idx, string s){
    if(s[idx + 1] == '+') return (int)s[idx] - '0';
    else{
        idx += 2;
        return ((int)s[idx - 2] - '0') * dfs(idx, s);
    }
}

int main(){

    string s; cin >> s;
    s = s + '+';
    long long n; cin >> n;
    long long rule1;
    long long rule2 = 0;
    //rule2
    int idx = 0;
    while(idx < s.size()){
        rule2 += dfs(idx, s);
        idx += 2;
    }

    //rule1
    for(int i = 0; i < s.size(); i += 2){
        if(i == 0) rule1 = (int)s[i] - '0';
        else{
            if(s[i - 1] == '+') rule1 += (int)s[i] - '0';
            else rule1 *= (int)s[i] - '0';
        }
    }

    if(rule1 == n && rule2 == n) cout << 'U' << endl;
    else if(rule1 == n) cout << 'L' << endl;
    else if(rule2 == n) cout << 'M' << endl;
    else cout << 'I' << endl;
    return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	int g = a[0];
	for(int i = 0; i < n; ++i){ g = __gcd(g, a[i]); }
	if(k % g != 0 || k > a.back()){
		cout << "IMPOSSIBLE" << endl;
	}else{
		cout << "POSSIBLE" << endl;
	}
	return 0;
}



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

int main(){
  int A, B, C;
  int sum = 0;
  cin >> A >> B >> C;
  for (int i=0; i<C; i++){
    if ((i + 1) % A == 0){
      sum += B;
    }
    else
    {
      continue;
    }
    continue;
  }
  cout << sum << endl;
  
};


Measured memory_bytes: 256
// Crt. 2020-01-07  21:24:40
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#define N 400005
using namespace std;

int n, rt[2], fa[2][N], iso[2][N], vis[N], ans[N];
vector<int> G[3][N];

inline void addE(int u, int v, int op) { G[op][u].push_back(v); }

int dfs(int u, int p, int op) {
    int son = 0; vector<int> stk;
    for (int i = G[op][u].size() - 1; ~i; --i) {
        int v = G[op][u][i];
        if (v == p) continue;
        int tmp = dfs(v, u, op);
        if (tmp) stk.push_back(tmp);
        ++son;
    } if (son % 2 == 0) stk.push_back(u), iso[op][u] = 1;
    for (int i = stk.size() - 1; i; i -= 2)
        addE(stk[i], stk[i - 1], 2), addE(stk[i - 1], stk[i], 2);
    int tmp = 0;
    if (stk.size() & 1) tmp = stk[0];
    return stk.clear(), tmp;
}

void dfs2(int u, int x) {
    vis[u] = 1, ans[u] = x;
    for (int i = G[2][u].size() - 1; ~i; --i) {
        int v = G[2][u][i];
        if (vis[v]) continue;
        dfs2(v, -x);
    }
}

int main(){
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    for (int k = 0; k < 2; ++k)
        for (int i = 1; i <= n; ++i) {
            scanf("%d", fa[k] + i);
            if (~fa[k][i]) addE(fa[k][i], i, k);
            else rt[k] = i;
        }

    for (int k = 0; k < 2; ++k)
        dfs(rt[k], 0, k);

    for (int i = 1; i <= n; ++i)
        if (iso[0][i] != iso[1][i])
            return puts("IMPOSSIBLE"), 0;

    for (int i = 1; i <= n; ++i)
        if ((iso[0][i] || iso[1][i]) && !vis[i])
            dfs2(i, -1);

    puts("POSSIBLE");
    for (int i = 1; i <= n; ++i)
        printf("%d ", ans[i]);

    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,x,n) for(int i=(x);i<(n);i++)
#define sortn(a) sort((a).begin(),(a).end())
#define sortr(a) sort((a).begin(),(a).end(),greater<int>())
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
    
    int n,m;
    ll ans=0;
    cin >> n >> m;
    //multiset<double> a; //v2
    //double tmp; //v2
    priority_queue<int> a;
    int tmp;
    rep(i,n){
        cin >> tmp;
        // a.insert(tmp); //v2
        a.push(tmp);
    }

    // ver.1(TLE) vector<double> a
    // int c;
    // rep(i,m){
    //     a.back() /= 2; 
    //     if(a.back() < 1){
    //         a.pop_back();
    //         if(a.size() == 0)break;
    //     }else{
    //         c = 0;
    //         while(a[a.size()-1-c] < a[a.size()-2-c]){
    //             swap(a[a.size()-1-c],a[a.size()-2-c]);
    //             c++;
    //         }
    //     }
    // }

    //ver.2(ac) multiset<double> a
    // rep(i,m){
    //     auto itr = a.end();
    //     itr--;
    //     tmp = *itr/2;
    //     a.erase(itr);
    //     if(tmp < 1){
    //         if(a.size() == 0)break;
    //     }else{
    //         a.insert(tmp);
    //     }
    // }

    //ver.3 priority_queue<double> a
    rep(i,m){
        tmp = a.top()/2;
        a.pop();
        if(tmp == 0){
            if(a.size() == 0)break;
        }else{
            a.push(tmp);
        }
    }


    // for(auto i=a.begin();i!=a.end();i++){ //v2
    //     ans += (int)(*i);
    // }

    int c = a.size();
    rep(i,c){
        ans += a.top();
        a.pop();
    }

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



Measured memory_bytes: 892
import sys
input=sys.stdin.readline

def fib(n):
    a, b = 1, 0
    for _ in range(n):
        a, b = a + b, a
    return b

n,m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))
if len(a) >= 2:
    for i in range(m-1):
        if a[i]+1 == a[i+1]:
            print(0)
            exit()

tmp = 0
ans = 1
for i in range(len(a)):
    ans *= fib(a[i]-tmp)
    tmp = a[i]+1
if tmp < n:
    ans *= fib(n-tmp+1)
print(ans%(10**9+7))


Measured memory_bytes: 7076
#include<stdio.h>

int BubbleSort(int* a, int n){
	int i,j,cnt=0,tmp;
	for(i=0;i+1<n;i++){
		for(j=n-1;j>=i+1;j--){
			if(a[j-1]>a[j]){
				cnt++;

				tmp=a[j];
				a[j]=a[j-1];
				a[j-1]=tmp;
			}
		}
	}

	return cnt;
}

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

	cnt=BubbleSort(a,n);

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



Measured memory_bytes: 2748