akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split(" "))
a = [0 for i in range(M)]
b = [0 for i in range(M)]
for i in range(M):
    a[i], b[i] = map(int, input().split(" "))

adj_matrix = [[0 for i in range(N)] for j in range(N)]
visited_flag = [0 for i in range(N)]
visited_flag[0] = 1

for i in range(M):
    adj_matrix[a[i]-1][b[i]-1] = 1
    adj_matrix[b[i]-1][a[i]-1] = 1

def find_next(idx, matrix, flag, nb_ans):
    if sum(flag) == N:
        return nb_ans+1
    for j in range(N):
        if matrix[idx][j] == 1 and flag[j] == 0:
            flag[j] = 1
            nb_ans = find_next(j, matrix, flag, nb_ans)
            flag[j] = 0

    return nb_ans

nb_ans = find_next(0, adj_matrix, visited_flag, 0)
print(nb_ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,d;
  cin>>n>>k;
  ll b[n+1]={};
  for(ll i=0;i<k;i++){
  	cin>>d;
  	ll a[d];
  	for(ll y=0;y<d;y++){
  		cin>>a[y];
  		b[a[y]]++;
	  }
	  
  }
  ll c=0;
  for(ll p=1;p<n+1;p++){
  	if(b[p]==0){c++;
	  }
  }
  cout<<c;
  return 0;}

Measured memory_bytes: 3560
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let mut  i = read::<isize>();

    i.sort();
    
    let ans = i[0] + i[1] + i[2] * 10;

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


Measured memory_bytes: 4352
a, b, c, d = map(int, input().split())

if c%b != 0:
    taka = c//b + 1
else:
    taka = c//b

if a%d != 0:
    ao = a//d + 1
else:
    ao = a//d

if taka > ao:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main() {
	ll X, A;
	cin >> X >> A;
	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def main():
    A = int(input())
    B = [int(i) for i in input().split()]
    res = 0
    cur = 0
    for i in range(A - 1):
        if B[i] >= B[i+1]:
            cur += 1
        else:
            res = max(res, cur)
            cur = 0
    res = max(res, cur)
    print(res)
main()

Measured memory_bytes: 63984
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main() {
    int x[3000],y[3000];
    for (int i = 1; i <= 3000;i++) {
        cin >> x[i] >> y[i];
        if (x[i] == 0 && y[i] == 0) {
            for (int j = 1; j < i; j++) {
                if (x[j] > y[j]) {
                    cout << y[j] << " " << x[j] << endl;
                }
                else {
                    cout << x[j] << " " << y[j] << endl;
                }
            }
            break;
        }
    }

}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 2007 , __ = _*_ , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[__],rjc[__];

inline void fuck(int n=__-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,m;
lint f[_][_]={0};

int main()
{
	n=ty(),m=ty();
	if(m<=1){puts("1");return 0;}

	fuck();
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>0)f[i][j]=(f[i][j]+f[i][j-1]*(n-j+1)%mo*C(n*m-i-(j-1)*(m-1)-1,m-2)%mo)%mo;
		}
	}
	printf("%lld\n",f[n][n]);

	return 0;
}


Measured memory_bytes: 93184
from collections import Counter

M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  try:
    while n > 1:
      x = c.get(i)
      r = r * pow(p, x, M) % M
      p = x; n -= p; i += 1
  except:
    pass
print((r, 0)[n > 1])

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	int ans = 0;
	while(n--){
		int x; cin>>x;
		while(x%2 == 0){
			ans++; x >>= 1;
		}
	}
	cout<<ans<<endl;

	return 0;
}

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


int main(){
  int n;
  cin >> n;
  int b;
  int xmin = 1000001;
  int xmax = -1000001;
  long long int sum = 0;
  
  for(int i = 0;i<n;i++){
    cin >> b;
    
    xmin = min(xmin, b);

    xmax = max(xmax, b);
      
    sum += b;
    
   
    
  }
    
  
  cout << xmin << ' ' << xmax << ' ' << sum << endl;
}


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

using namespace std;
using ll = long long;

int main(void) {
    int a, b, c, d;
    cin >> a >> b >>c >> d;

    while(a > 0 || c > 0) {
        c -= b;
        if (c <= 0) {
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3624
from collections import defaultdict

N = int(input())

dd = defaultdict(list)
for _ in range(N-1):
    u, v, w = map(int, input().split())
    dd[u].append((v, w))
    dd[v].append((u, w))

colorDict = defaultdict(int)
stack = [1]
colorDict[1] = 1
while(stack):
    key = stack.pop() 
    for ew in dd[key]:
        e, w = ew
        if colorDict[e] == 0:
            if colorDict[key] == 1:
                colorDict[e] = 1 if w % 2 == 0 else 2
            else:
                colorDict[e] = 2 if w % 2 == 0 else 1
            stack.append(e)

for k, v in sorted(colorDict.items()):
    print(str(v - 1))


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  */


signed main() {
  int n, max_w;
  cin >> n >> max_w;
  
  V<int> w(n), v(n);
  rep(i, 0, n) cin >> w[i] >> v[i];

  int base_w = w[0];
  rep(i, 0, n) w[i] -= base_w;

  int lim_w = n*3+1;
  V<V<V<int>>> dp(n+1, V<V<int>>(n+1, V<int>(lim_w+1)));
  rep(i, 0, n) rep(j, 0, n) rep(k, 0, lim_w+1){
    chmax(dp[i+1][j][k], dp[i][j][k]);
    if(k+w[i] <= lim_w) chmax(dp[i+1][j+1][k+w[i]], dp[i][j][k]+v[i]);
  }

  int ans = 0;
  rep(j, 0, n+1) rep(k, 0, lim_w+1) {
    if(j*base_w + k <= max_w){
      chmax(ans, dp[n][j][k]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 24960
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e7+1)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	int n;cin>>n;ll s=0;
	vector<ll> d(n+1,0);
	int i,j;for(i=1;i<=n;i++){
		for(j=i;j<=n;j+=i) d[j]++;
	}for(i=1;i<=n;i++){
		s+=(i*d[i]);
	}cout<<s<<endl;
}



Measured memory_bytes: 81372
n = int(input())
tmp = n
k = 0
while tmp > 0 :
    tmp = tmp//10
    k += 1 

ans = 1e10
for i in range(1,n) :
    tmp = n - i
    x = 0
    while tmp > 0 :
        x += tmp%10
        tmp = tmp//10
    tmp = i
    while tmp > 0 :
        x += tmp%10
        tmp = tmp//10
    ans = min(ans, x)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#define N 100
#define INF 1000000
using namespace std;

int main(){
  int n,g[N][N],used[N]={},d[N]={},p[N];
  cin>>n;
  for(int i=0;i<n;i++){
    d[i]=INF,p[i]=-1;
    for(int j=0;j<n;j++){
      cin>>g[i][j];
      if(g[i][j]==-1) g[i][j]=INF;
    }
  }
  d[0]=0;
  
  while(1){
    int j=-1,min=INF;
    for(int i=0;i<n;i++)if(!used[i] && d[i]<min)min=d[i],j=i;
    if(j==-1) break;
    used[j]=1;
    for(int k=0;k<n;k++)
      if(!used[k] && g[j][k]!=INF)if(g[j][k]<d[k])d[k]=g[j][k],p[k]=j;
  }
int ans=0;
for(int i=0;i<n;i++)if(p[i]!=-1)ans+=g[i][p[i]];
cout<<ans<<endl;
 
 return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int n,h,a[100000],b[100000],ans=0;
    cin>>n>>h;
    rep(i,n)cin>>a[i]>>b[i];
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    int i=0;
    while(1){
        if(n==i)break;
        if(a[0]>b[i])break;
        if(h<=0)break;
        h-=b[i];
        i++;
        ans++;
    }
    if(h>0)ans+=(h+a[0]-1)/a[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import scala.io.StdIn.{readLine,readInt}
import scala.math.pow

object Main {
  def main(args: Array[String]) = {
    val l = readLine() split " " map (_.toDouble)
    val (vx, vy) = (l(2)-l(0), l(3)-l(1))
    val n = readInt()

    for( i <- 1 to n ) {
      val l2 = readLine() split " " map (_.toDouble)
      val (vx2, vy2) = (l2(0)-l(0), l2(1)-l(1))
      val sqr = pow(vx,2) + pow(vy,2)
      val in_p = vx*vx2 + vy*vy2
      val (xt, yt) = ( in_p*vx/sqr + l(0), in_p*vy/sqr + l(1) )

      println(xt+" "+yt)
    }
  }
}

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

int main()
{
    ll n,x,y;
    cin >> n;
    vector<pair<ll,ll>> point;

    rep(i,n){
        cin >> x >> y;
        point.push_back({x, y});
    }
    sort(point.begin(),point.end());

    rep(i,n) cout << point[i].first << " " << point[i].second << endl;

    return 0;
}


Measured memory_bytes: 4916
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  double p = 0.5*(-1+pow(4*n+1,0.5));
  for(long long i=1;i<p;i++){
    if(n%i==0){
      ans += n/i-1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# 英小文字からなる 3 つの単語 s1, s2, s3 が空白区切りで与えられるので、
# 単語の先頭の文字をつなげ、大文字にした略語を出力してください。

s = gets.chomp.split
3.times do |i|
    print s[i][0].upcase
end
print "\n"

Measured memory_bytes: 1788
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
n,k = MAP()
a = LIST()
b = [0 for _ in range(n)] #その配列のあとで
c = [0 for _ in range(n)] #配列全体で
for i in range(n):
    for j in range(i+1, n):
        if a[i] > a[j]:
            b[i] += 1
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            c[i] += 1
tt = k * (k - 1) // 2
ans = (k * sum(b) % mod + tt * sum(c) % mod) % mod
print(ans)

Measured memory_bytes: 63848
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  vi b(n+1),w(n+1);
  rep(i,n){
    b[i+1] = (s[i]=='#');
    w[i] = (s[i]=='.');
  }
  rep(i,n){
    b[i+1] += b[i];
    w[i+1] += w[i];
  }
  int ans = INF;
  rep(i,n+1) chmin(ans,b[i]+w[n]-w[i]);
  cout << ans;
  cout << endl;
  return 0;
}


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

struct edge{int to,cost;};
typedef pair<int,int> P;

int V;
vector<edge> g[210];
int d[210];
int inf = 2000000007;

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  for(int i = 0;i <= V;i++){
    d[i] = inf;
  }
  d[s] = 0;
  que.push(P(0,s));
  
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0;i < g[v].size();i++){
      edge e = g[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main() {
  int m,R;
  cin >> V >> m >> R;
  vector<int> r(R);
  for(int i = 0;i < R;i++){
    cin >> r.at(i);
  }
  sort(r.begin(),r.end());
  for(int i = 0;i < m;i++){
    int a;
    edge e;
    edge f;
    cin >> a >> e.to >> e.cost;
    f.to = a;
    f.cost = e.cost;
    g[a].push_back(e);
    g[e.to].push_back(f);
  }
  int distance[210][210];
  for(int i = 0;i < R;i++){
    dijkstra(r.at(i));
    for(int j = 0;j < R;j++){
      if(i == j) continue;
      distance[r.at(i)][r.at(j)] = d[r.at(j)];
    }
  }
  
  int zyu[50000][8];
  int k = 0;
  do {
    for(int i = 0;i < R;i++){
      zyu[k][i] = r.at(i);
    }
    k++;
  } while (std::next_permutation(r.begin(), r.end()));
  //cout << k << endl;
  
  int kekka;
  for(int i = 0;i < k;i++){
    int cur = 0;
    for(int j = 0;j < R-1;j++){
      cur += distance[zyu[i][j]][zyu[i][j+1]];
      //cout << zyu[i][j] << " " << zyu[i][j+1] << " " << distance[zyu[i][j]][zyu[i][j+1]] << endl;
    }
    if(i == 0){
      kekka = cur;
    }
    else{
      kekka = min(cur,kekka);
    }
  }
  cout << kekka << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;

    int ans = 0;
    while (N != 0)
    {
        N /= K;
        ans++;
    }
    cout << ans << endl;
    
    
  return 0;
}


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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int m = in.nextInt();
        int n = in.nextInt();
        out.println(m == n ? "Yes":  "No");
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;	cin>>n;
	int a[n],i,j;
	for(i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	ll ans=0;
	for(i=0;i<n;i++){
		ans+=abs(a[i]-a[n/2]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int p,fc[3030]={1},nv[3030]={1},ans[3030];

int rwpw(int x, int a){
	int ret=1;
	while(a){
		if(a&1){
			ret *= x;
			ret %= p;
		}
		x *= x; x %= p;
		a >>= 1;
	}
	return ret;
}

int main(void){
	int i,j,tmp,a;
	cin >> p;
	for(i=1; i<=p; ++i){
		fc[i] = (fc[i-1]*i)%p;
		nv[i] = rwpw(fc[i],p-2);
	}
	for(i=0; i<p; ++i){
		cin >> a;
		if(!a){
			continue;
		}
		++ans[0];
		for(j=0; j<p; ++j){
			tmp = fc[p-1];
			tmp *= nv[j]; tmp %= p;
			tmp *= nv[p-1-j]; tmp %= p;
			tmp *= rwpw(p-i,p-1-j); tmp %= p;
			ans[j] += (p-tmp); ans[j] %= p;
		}
	}
	for(i=0; i<p; ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	k, x := readI(), readI()
	if 500*k >= x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string o,e; cin>>o>>e;
	rep(i,e.size()){
		cout<<o[i]<<e[i];
	}
	if(o.size()>e.size()) cout<<o[o.size()-1];
	cout<<endl;
	return 0;
}


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

//写経
void doubling(ll N, ll K, const vector<ll> &A, vector<vector<ll>> &a){
  

  //先ずはa[0][i]を求めて行く
  vector<ll> used(200010,-1);
  
  for(ll k = 0; k < 2; k++){
   for(ll i = 0; i < N; i++){ 
    
    if(used[A[i]] != -1){
      
      a[0][(used[A[i]])%N] = k*N+i-used[A[i]]+1;
      
    }
    
    used[A[i]] = k*N+i;   //最後にその数字を使った位置を記録しておく
   }//for-i
  }// for-k
  
  
  for(ll k = 1; k < 60; k++){ 
    
    for(ll i = 0; i < N; i++){
    
    a[k][i] = a[k-1][i]+a[k-1][(i+a[k-1][i])%N];
    
    }
  } 
      
  
}// doubling-とじ

ll starting(ll N, ll K, const vector<vector<ll>> &a){
  
  ll sum = 0; ll now = 0;
  
  const ll SIZE = N*K;
  
  while(true){
    
    ll ind = 0;
    
    for(ll i = 0; i < 60;i++){
     if( a[i][now]+sum >= SIZE ){ 
        
        ind = i-1;
        
        break;
      }
    }
      
    if( ind == -1 ){ break;}
    
    sum += a[ind][now];
    now = sum%N;
    
  }
  
  
  return now;
  
}
        
      
deque<ll> simulate(ll start, ll N, vector<ll> A){
  // startからN-1にかけては愚直にシミュレートを行う
  
  deque<ll> Q; vector<bool> used(200010,false);
  
  for(ll i = start; i < N; i++){
    
    ll a = A[i];
    
    if( !used[a]  ){ Q.push_back(a); used[a] = true;}
    else{
      
      while(true){
        
        ll x = *Q.rbegin();
        used[x] = false;
        Q.pop_back();
        
        if( x == a ){ break;}
        
        
      }
    }
    
  }
  
  return Q;
}
    
   
           
          
           
       
           
  

int main(){ 
  ll N,K; cin >> N >> K;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  vector<vector<ll>> a(60,vector<ll>(200010));
  
  doubling(N,K,A,a);
  
  ll pos = starting(N,K,a);
  
  deque<ll> D = simulate(pos,N,A);
  
  for(auto ne : D){
    cout << ne << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 100196
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;

	vector<int> a(n);

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

	deque<int> b;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)b.push_front(a[i]);
		else b.push_back(a[i]);
	}

	vector<int> c(b.begin(), b.end());

	if (n % 2 == 0)reverse(c.begin(), c.end());

	for (int i = 0; i < n; i++) {
		cout << c[i];

		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
}

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

using namespace std;


int main(){
    int N, tmp, ans=0;
    vector<int> A;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> tmp;

        A.push_back(tmp);
    }
    
    for(int i = 0; i < A.size(); i++){
        ans += A[i]-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
  long long int price[81], N, i, stock, money, max;
  scanf("%lld", &N);
  for (i = 0; i < N; i++)
  {
    scanf("%lld", &price[i]);
  }
  money = 1000;
  max = 1000;
  stock = 0;
  for (i = 0; i < N - 1; i++)
  {
    if (price[i] < price[i + 1])
    {
      stock = money / price[i];
      money = money - price[i] * stock;
      money = money + price[i + 1] * stock;
      stock = 0;
    }

    if (money > max)
    {
      max = money;
    }
  }
  if (stock != 0)
  {
    money = money + price[N - 1] * stock;
    if (max < money)
    {
      max = money;
    }
  }

  printf("%lld", max);
  return 0;
}


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

using namespace std ;

int main()
{
    long n ;
    cin >> n ;
    long a[n] , i ;
    
    for( long i=0 ; i<n ; i++)
    cin >> a[i];
    
    long dp[n] ;
    
    dp[0] = 0 ;
    dp[1] = abs( a[1]-a[0] );
    
    for( long i=2 ; i<n ; i++)
    {
        dp[i] = min( dp[i-2]+abs(a[i]-a[i-2]) , dp[i-1]+abs(a[i]-a[i-1]) );
    }
    cout << dp[n-1] ;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

    public static final void main(String[] args) {
        Main m = new Main();
        m.init();
        m.solve();
    }

    // ========================================================================= //
    int a, b, c;

    public void init() {
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
    }

    public void solve() {
        if (a == b) System.out.println(c);
        if (b == c) System.out.println(a);
        if (c == a) System.out.println(b);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


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

    int x;
    cin >> x;
    if (x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 3664
fun main(args: Array<String>) {
    abc068c()
}

fun abc068c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val abList = (1..m).map { readLine()!!.split(' ').map { it.toInt() } }
        .map { Pair(it[0], it[1]) }

    val from1 = abList.filter { it.first == 1 }.map { it.second }.toSet()
    val toN = abList.filter { it.second == n }.map { it.first }.toSet()

    val answer = if ((from1 intersect toN).isNotEmpty()) "POSSIBLE" else "IMPOSSIBLE"

    println(answer)
}


Measured memory_bytes: 119948
#include <stdio.h>
int main()
{
    int min,max;
    int n;
    scanf("%d%d%d",&n,&min,&max);
    if(n==1)
    {
        if(min==max)

                printf("1\n");

        else
            printf("0\n");
    }
    else
    {
        if(min>max)
            printf("0\n");
            else
        printf("%lld\n",(long long)(max-min)*(n-2)+1);
    }
    return 0;

}


Measured memory_bytes: 128
def equa(ans,i,s,p):
  for e in (0,1):
    p[i] = e
    if i < len(p)-2:
      ans = equa(ans,i+1,s,p)
    else:
      #print(i,s,p)
      prii = 0
      for ii in range(len(p)):
        if p[ii] == 1:
          ans += int(s[prii:ii+1])
          #print(prii,ii+1,int(s[prii:ii+1]))
          prii = ii+1
  return ans
def main():
  s = input()
  p = [0]*(len(s)-1)
  p.append(1)
  i = 0
  ans = 0
  ans = equa(ans,i,s,p)
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int mxN = 102;
vector<int> adj[mxN], in(mxN, -1), out(mxN, -1);
int t = 0;

void dfs(int i) {
    t++;
    in[i] = t;
    for(auto v: adj[i]) {
        if(in[v]==-1) {
            dfs(v);
        }
    }
    t++;
    out[i] = t;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int v, k;
        cin >> v >> k;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            adj[i].push_back(a);
        }
    }
    for(int i = 0; i < n; i++) {
        if(in[i] == -1) dfs(i);
    }
    for(int i = 0; i < n; i++) {
        cout << i+1 << " " << in[i] << " " << out[i] << endl;
    }
}


Measured memory_bytes: 3152
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
d = [[((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5 for j in range(n)] for i in range(n)]
ans = 0
for i in range(n): ans += sum(d[i])/n
print(ans)

Measured memory_bytes: 9376
while True:
  n = int(input())
  if n == 0:
    break
  c=[]
  for i in range(n):
    c.append(int(input()))
  for i in range(10):
    s = c.count(i)
    if s != 0:
      for j in range(s):
        print("*",end='')
      print()
    else:
      print('-')


Measured memory_bytes: 7684
M, K = map(int, input().split())

if K >= 2 ** M:
    print(-1)
    exit()

if K == 0:
    a = []
    for i in range(2 ** M):
        a.append(i)
        a.append(i)
    print(*a)
    exit()

if M == 1 and K == 1:
    print(-1)
    exit()

a = []
a.append(K)
for i in range(2 ** M):
    if i == K:
        continue
    a.append(i)
a.append(K)
for i in range(2 ** M - 1, -1, -1):
    if i == K:
        continue
    a.append(i)
print(*a)


Measured memory_bytes: 66800
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e18
#define eps (1e-5)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

class Point{
public:
  double x,y;
  Point(double x=0.0,double y=0.0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return 1;
  if(cross(a,b)<-eps)return -1;
  if(dot(a,b)<-eps)return 2;
  if(a.norm()<b.norm())return -2;
  return 0;
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps || abs(B)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

double getPolygonArea(Polygon p){
  double area=0.0;
  int n=p.size();
  for(int i=0;i<n;i++)area+=cross(p[i%n],p[(i+1)%n])/2.0;
  return area;
}

Polygon convex_cut(Polygon p,Line l){
  Polygon ans;
  for(int i=0;i<p.size();i++){
    Point A=p[i],B=p[(i+1)%p.size()];
    if(ccw(l.p1,l.p2,A)!=-1)ans.push_back(A);
    if(ccw(l.p1,l.p2,A)*ccw(l.p1,l.p2,B)<0)
      ans.push_back(getCrossPointLL(l,Segment(A,B)));
  }
  return ans;
}

double getArea(Polygon t,Polygon s){
  FOR(i,0,s.size()){
    Point a=s[i],b=s[(i+1)%s.size()];
    t=convex_cut(t,Line(a,b));
  }
  return getPolygonArea(t);
}

double getCommonArea(Polygon p,Polygon s){
  int n=p.size();
  double res=0.0;
  Point a=p[0];
  FOR(i,1,n-1){
    Point b=p[i],c=p[(i+1)%n];
    Polygon t;
    t.pb(a);t.pb(b);t.pb(c);
    res+=getArea(t,s);
  }
  return res;
}

int main()
{
  int n;

  while(1){
    cin>>n;
    if(n==0)break;
    Polygon p;
    FOR(i,0,n){
      int x,y;
      cin>>x>>y;
      p.pb(Point(x,y));
    }
    Polygon s;
    FOR(i,0,4){
      int x,y;
      cin>>x>>y;
      s.pb(Point(x,y));
    }
    double ans=getPolygonArea(p)-getCommonArea(p,s)+eps;
    cout<<(int)ans<<endl;;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int K;
vector<string> ans[20];

void INIT() {
    for (int i = 0; i <= 9; i++) {
        ans[0].push_back(to_string(i));
    }
    for (int k = 0; k < 9; k++) {
        for (int i = 0; i < ans[k].size(); i++) {
            int tmp = ans[k][i][0] - '0';
            for (int j = -1; j <= 1; j++) {
                if (0 <= tmp + j && tmp + j <= 9) {
                    ans[k+1].push_back(to_string(tmp + j) + ans[k][i]);
                }
            }
        }
    }
    return;
}

int main() {
    cin >> K;

    INIT();

    vector<ll> tmp;

    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j < ans[i].size(); j++) {
            if (ans[i][j][0] != '0') {
                tmp.push_back(stoll(ans[i][j]));
            }
        }
    }
    
    sort(tmp.begin(), tmp.end());

    cout << tmp[K-1] << endl;
    

    return 0;
}

Measured memory_bytes: 15728
#include<iostream>
#include<list>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n,m;
	list<int> L;
	string s;
	cin>>n;
    while(n--){
    	cin>>s;
    	if(s[0]=='i'){cin>>m;L.push_front(m);}
    	else if(s.length()>6){
    	 if(s[6]=='F'){ L.pop_front();}
    	else if(s[6]=='L'){L.pop_back();}
        }
    	else {
    		cin>>m;
    		for(list<int>::iterator it=L.begin();it!=L.end();it++){
    			if(*it==m){

    			 L.erase(it);
    			break;
    			}
    		}
    	}
    }
    int i=0;
    for(list<int>::iterator it=L.begin();it!=L.end();it++){
    		if(i++)cout<<" ";
    		cout<<*it;
    	}
    cout<<endl;
    return 0;

}


Measured memory_bytes: 34424
n, a, b, c = map(int,input().split())
l = [ int(input()) for i in range(n) ]

ans = float('inf')
for i in range(4**n):
    t = [[],[],[],[]]
    for j in range(n):
        tmp = i//4**j
        t[tmp%4].append(l[j])
    if sum(t[0]) == 0 or sum(t[1]) == 0 or sum(t[2]) == 0:
        continue
    cost= abs(a - sum(t[0])) + abs(b - sum(t[1])) + abs(c - sum(t[2])) + 10*sum([len(t[0]),len(t[1]),len(t[2]),-3])
    ans = min(ans, cost)
print(int(ans))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long ll;

ll n,t;
string f;
const ll TLE = 1e9;

int main(){
  cin >> n >> t;
  cin >> f;

  ll pow[10];
  pow[0] = 1;
  for(int i=1;i<10;i++){
    if(pow[i-1]<0)pow[i] = -1;
    else pow[i] = pow[i-1] * n;
    if(pow[i] > TLE)pow[i] = -1;
  }

  ll ans = 0;
  for(int i=2;i<f.size();i+=4){
    int k = f[i]-'0';
    if(pow[k]<0){
      ans = -1;
      break;
    }
    ans += pow[k];
    if(ans>TLE)break;
  }
  if(ans<0 || ans>TLE)cout << "TLE\n";
  else if(ans*t>TLE)cout<< "TLE\n";
  else cout << ans*t << endl;
}

Measured memory_bytes: 1196
#include<stdio.h>
 
void swap(int x, int y, int a[])
{
	int temp;
	temp = a[x-1];
	a[x-1] = a[y-1];
	a[y-1] = temp;
}
 
int main(void)
{
	int val[30];
	int i;
	int w, n;
	int a, b;

	scanf("%d", &w);
	scanf("%d", &n);
	for(i = 0; i < w; val[i] = i + 1,i++);
 
	for(i = 0; i < n; i++)
	{
		scanf("%d,%d", &a, &b);
		swap(a, b, val);
	}
	for(i = 0; i < w; i++)
	printf("%d\n",val[i]);

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    string s; cin >> s;
    int n = (int)s.length();
    char keyence[] = {'k','e','y','e','n','c','e'};
    
    bool is_keyence_string = false;
    rep(i, 7){
        is_keyence_string = true;
        rep(j,i){
            if(s[j] != keyence[j]) is_keyence_string = false;
        }
        rep(j,7-i){
            if(s[n-1-j] != keyence[6-j]) is_keyence_string = false;
        }
        if(is_keyence_string) break;
    }
    
    cout << (is_keyence_string ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import bisect

n = int(input())

a = []
for _ in range(n):
  a.append(int(input()))

a2 = sorted(a)

max_a = a2[-1]
index = bisect.bisect_left(a2,max_a)
num = n-index

if num > 1:
  for _ in range(n):
    print(a2[-1])
else:
  for i in range(n):
    if a[i] == a2[-1]:
      print(a2[-2])
    else:
      print(a2[-1])


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

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

  vi ans(50);
  
  if(k < 50) rep(i, 0, k) ans[i] = 50-i;
  else{
    iota(all(ans), 1);
    reverse(all(ans));

    rep(i, 0, 50) ans[i] += k/50-1;
    rep(i, 0, k%50) ans[i]++;
  }

  cout << 50 << endl;
  rep(i, 0, 50) cout << ans[i] << " \n"[i==49];

  return 0;
}



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

#define ll long long
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
using namespace std;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
const ll MOD = 1e9+7;
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    string v;
    cin >> v;
 
    int sum[4][n+5];
    memset(sum, 0, sizeof sum);
    for(int i = 0; i < n; i++) {
        if(i) {
            sum[0][i] += sum[0][i-1];
            sum[1][i] += sum[1][i-1];
            sum[2][i] += sum[2][i-1];
        }
        if(v[i] == 'R') {
            v[i] = 0;
            sum[0][i]++;
        }
        if(v[i] == 'G') {
           v[i] = 1;
           sum[1][i]++;
        }
        if(v[i] == 'B'){
         v[i] = 2;
         sum[2][i]++;
        }
    }
 
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n-1; j++) {
            if(v[i] == v[j])
                continue;
            for(int k = 0; k < 3; k++) {
 
                if(k == v[i] or k == v[j])
                    continue;
 
                ans += sum[k][n-1]-sum[k][j];
 
 
 
                if(j+(j-i) < n && v[j+(j-i)] == k) 
                    ans--;
 
            }
 
 
        }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
int main(){
  int N,M;
  cin>>N>>M;
  int A=100001,B=-1;
  rep(i,0,M){
    int X,Y;
    cin>>X>>Y;
    A=min(A,Y);
    B=max(B,X);
  }
  int ans=A-B+1;
  if(ans>=1) cout<<ans<<endl;
  else cout<<"0"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string s;
    
    cin>>s;
    
    cout<<"ABC"<<s<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3624
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 1e-11
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif
#ifdef _DEBUG
#include "Union_Find.h"
#include "Graph.h"
#endif

int N, M;
bool G[8][8];
int main() {
	cin >> N >> M;
	REP(i, 0, M) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a][b] = 1;
		G[b][a] = 1;
	}
	int sum = 0;
	vector<int> P(N);
	iota(P.begin(), P.end(), 0);
	do {
		REP(i, 1, N) {
			if (!G[P[i - 1]][P[i]]) goto hoge;
		}
		++sum;
	hoge:
		;
	} while (next_permutation(P.begin() + 1, P.end()));
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Here your code !
N = int(input())

w = 0
for h in range(1 , int(3*N/4 )+ 1) : 
    if w != 0 : 
        h -= 1
        break
    x = 4 / N - 1 / h
    if x <= 0 : continue
    for n in range(1 , int(2/(4/N - 1/h)) + 1) : 
        if (4*h*n - N*n - N*h)  <= 0 : continue
        if (N*h*n) % (4*h*n - N*n - N*h)  == 0 : 
            w = int((N*h*n) / (4*h*n - N*n - N*h) )
            break
        
print(h ,n,w)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    string s; cin >> s;
    int s_cnt = 0,ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (s_cnt == 0 && s[i] == 'T'){
            ans++;
        } else if (s_cnt != 0 && s[i] == 'T'){
            s_cnt--;
        } else if (s[i] == 'S'){
            s_cnt++;
        }
    }
    ans += s_cnt;
    cout << ans << endl;
}




Measured memory_bytes: 640
n,k,s=map(int,input().split())
if s==10**9:
    for i in range(k):
        print(s)
    for i in range(k,n):
        print(1)
else:
    for i in range(k):
        print(s)
    for i in range(k,n):
        print(s+1)

Measured memory_bytes: 4212