akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<k;i++)
typedef long long ll;
typedef unsigned long long ull;

int main(){
    double num;
    while(~scanf("%lf",&num)){
        double ans = num;
        double bef = num;
        rep(i,9){
           if(i % 2 == 1){
                ans += bef / 3;
                bef = bef / 3;
           }
           else{
                ans += bef * 2;
                bef = bef * 2;
           }
        }
        printf("%lf\n",ans);
    }
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using namespace std;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  int v;
  map<int, int> mp1;
  map<int, int> mp2;
  for(int i = 0; i < n/2; i++){
    cin >> v;
    if(mp1[v] == 0){
      mp1[v] = 1;
    }else{
      mp1[v]++;
    }
    cin >> v;
    if(mp2[v] == 0){
      mp2[v] = 1;
    }else{
      mp2[v]++;
    }
  }
  
  vector<pair<int, int>> p1;
  vector<pair<int, int>> p2;
  for(auto itr = mp1.begin(); itr != mp1.end(); ++itr){
    //cout << itr->first << "," << itr->second << endl;
    p1.push_back(make_pair(itr->second, itr->first));
  }
  for(auto itr = mp2.begin(); itr != mp2.end(); ++itr){
    //cout << itr->first << "," << itr->second << endl;
    p2.push_back(make_pair(itr->second, itr->first));
  }
  sort(p1.begin(), p1.end());
  reverse(p1.begin(), p1.end());
  sort(p2.begin(), p2.end());
  reverse(p2.begin(), p2.end());


  if(p1.size() == 1 && p2.size() == 1 && p1[0].second == p2[0].second){
    cout << n/2 << endl;
  }else if(p1[0].second == p2[0].second){
    int ans = min(n - p1[0].first  - p2[1].first, n - p1[1].first  - p2[0].first);
    cout << ans << endl;
  }else{
    cout << n - p1[0].first  - p2[0].first << endl;
  }
  return 0;
}


Measured memory_bytes: 6136
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

//マクロ
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
//定数
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k; cin >> n >> k;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p, p + n);

    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        printf("a > b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    else{
        printf("a < b\n");
    }
}


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

using namespace std;

template <typename T>
int pow(int x, T n, int mod = std::numeric_limits<int>::max()) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<int64_t>(res) * static_cast<int64_t>(x) % mod;
    x = static_cast<int64_t>(x) * static_cast<int64_t>(x) % mod;
    n >>= 1;
  }
  return res;
}

template <typename T>
int64_t pow(int64_t x, T n, int64_t mod = std::numeric_limits<int64_t>::max()) {
  int64_t res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<__int128>(res) * static_cast<__int128>(x) % mod;
    x = static_cast<__int128>(x) * static_cast<__int128>(x) % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K;
  cin >> K;
  if (K % 7 == 0) K /= 7;
  K *= 9;
  int x = 1;
  for (int i = 0; i < K; i++) {
    x *= 10;
    x %= K;
    if (x - 1 == 0) {
      cout << i + 1 << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}


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

int main(){
int N, M, X;  cin >> N >> M >> X;
vector<int> A(M);
for (int i = 0; i < M; i++) {
    cin >> A[i]; 
}
int left = 0;
int right = 0;
for (int i = 0; i < M - 1; i++) {
    if (A[i] < X && A[i + 1] > X ) {
        left = i + 1;
        right = M - i - 1;
    }
}

cout << min(left, right) << endl; 

}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;
  string s,t;cin>>s>>t;

  string ans="";
  rep(i,0,n){
    ans+=s[i];
    ans+=t[i];
  }

  out(ans);

  return 0;
}


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

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

	n = s.length();
	for(int i = 0;i < n;i++)
		s[i] -= '0';

	long ans = 0;
	for(int i = 0;i < (1 << (n - 1));i++) {
		long a = s[0];
		for(int j = 0;j < n - 1;j++) {
			if(i & (1 << j)) {
				ans += a;
				a = s[j + 1];
			}else {
				a *= 10;
				a += s[j + 1];
			}
		}
		ans += a;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
s = input()

N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")


if (N == S == 0 or (N > 0 and S > 0)) and (E == W == 0 or (W > 0 and E > 0)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
ans = 0
list = [[ 0 for i in range(10)] for j in range(10)]

for i in range(1,N+1):
  left = int(str(i)[0])
  right = int(str(i)[-1])
  list[left][right] += 1

for i in range(10):
  for j in range(10):
    ans += list[i][j] * list[j][i]
print(ans)

Measured memory_bytes: 3064
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int[]A=nai(n);
        long sum=0,min=Integer.MAX_VALUE;
        for(int i=-100;i<=200;i++)
        {
            sum=0;
            for(int j=0;j<n;j++)
                sum+=(A[j]-i)*(A[j]-i);
            min=Math.min(min,sum);
        }
        pn(min);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

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

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define int long long
using namespace std;

int a, b, c, x, y;


inline int f(int z){
    return (z + z) * c + max(0ll, x - z) * a + max(0ll, y - z) * b;
}
main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> a >> b >> c >> x >> y;
    int l = 1, r = 1e10;
    while(r - l > 2){
        int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
        if(f(m1) > f(m2)){
            l = m1;
        }
        else{
            r = m2;
        }
    }
    int ans = f(0);
    for(int i = l; i <= r; i++){
        ans = min(ans, f(i));
    }
    l = 1, r = 1e10;
    while(r - l > 2){
        int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
        if(f(m1) >= f(m2)){
            l = m1;
        }
        else{
            r = m2;
        }
    }
    for(int i = l; i <= r; i++){
        ans = min(ans, f(i));
    }
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = input[0];
        var K = input[1];
        var Q = input[2];

        var list = Enumerable.Repeat(K, N).ToList();

        var A = new int[N];
        for (int i = 0; i < Q; i++)
        {
            A[int.Parse(Console.ReadLine()) - 1]++;
        }

        for (int i = 0; i < N; i++)
        {
            if (K - Q + A[i] > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 19036
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, T, S;
int cost[3001];
int fun[3001];
int dp[3001];
int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N  >> T >> S;
	for (int i = 1; i <= N; i++)cin >> fun[i] >> cost[i];
	for (int i = 1; i <= N; i++) {
		for (int j = T; j >= cost[i]; j--) {
			if (j - cost[i] >= S || j <= S)dp[j] = max(dp[j], dp[j - cost[i]] + fun[i]);
		}
	}
	for (int i = 1; i <= T; i++)ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>

using namespace std;

#define pb push_back
#define x  first
#define y  second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
	#include "debug.h"
#else
// #define debug(...) 42
#endif

const int MX =2e5+5;
const int MD= 1e9+7;
const ld PI=acos(-1);



int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		vector<int>pt;
		int n,a[MX],vs[MX]={0};
		ll k;
		cin>>n>>k;
		for(int i=1;i<=n;i++) cin>>a[i];
		int sr=1,cn=1,cy;
		while(1)
		{
			if(vs[sr]){
				cy=cn-vs[sr];
				break;
			}
			vs[sr]=cn;
			pt.pb(sr);
			sr=a[sr];
			cn++;
		}
		int sz=pt.size();
		// debug(cy,sz);
		if(k<sz){
			cout<<pt[k]<<"\n";
		}
		else{
			int rm=sz-cy;
			k-=rm;
			cout<<pt[rm+k%cy]<<"\n";
		}
	}
	return 0;	
}

Measured memory_bytes: 5884
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int n;
char s1[55], s2[55];

lli count(int num) {
  if ( num >= n ) return 1;
  if ( num == 0 ) {
    if ( s1[0] == s2[0] ) return count(1) * 3 % MOD;
    return count(2) * 6 % MOD;
  }
  if ( s1[num] == s2[num] ) {
    if ( s1[num-1] == s2[num-1] ) return count(num+1) * 2 % MOD;
    return count(num+1);
  }
  if ( s1[num-1] == s2[num-1] ) return count(num+2) * 2 % MOD;
  return count(num+2) * 3 % MOD;
}

int main(void) {
  scanf("%d", &n);
  scanf("%s %s", s1, s2);

  printf("%lld\n", count(0));
  return 0;
}


Measured memory_bytes: 128
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  val ref = "abcdefghijklmnopqrstuvwxyz".toCharArray()
  val s = br.readLine().toList()

  val res = ref.subtract(s).firstOrNull()
  val ans = if(res != null) res.toString() else "None"

  println(ans)
}

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

int main() {
    int n,k,q; cin >> n >> k >> q;
    vector<int> c(n, 0);
    for(int i=0; i<q; ++i) {
        int a; cin >> a;
        c[a - 1] += 1;
    }

    for(int i=0; i<n; ++i) {
        if(k - (q - c[i]) <= 0) cout << "No\n";
        else cout << "Yes\n";
    }
}

Measured memory_bytes: 1024
n = int(input())
a = input()
b = input()
c = input()
count = 0
for i in range(n):
    word = []
    word.append(a[i])
    word.append(b[i])
    word.append(c[i])
    word = list(set(word))
    count += len(word) - 1
    word.clear() 
print(count)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
const int Max = 1e6 + 5;
ll x, y, A, B, C, a[Max], b[Max], c[Max];
ll ans[Max];
struct cmpFunctor {
    inline bool operator() (const ll& x, const ll& y) {
        return x > y;
    }
};
int main() {
    scanf("%lld %lld %lld %lld %lld", &x, &y, &A, &B, &C);
    for (int i = 1; i <= A; i++)
        scanf("%lld", &a[i]);
    for (int i = 1; i <= B; i++)
        scanf("%lld", &b[i]);
    for (int i = 1; i <= C; i++)
        scanf("%lld", &c[i]);
    sort(a + 1, a + A + 1, cmpFunctor());
    sort(b + 1, b + B + 1, cmpFunctor());
    sort(c + 1, c + C + 1, cmpFunctor());
    int cnt = 0;
    for (int i = 1; i <= x; i++)
        ans[++cnt] = a[i];
    for (int i = 1; i <= y; i++)
        ans[++cnt] = b[i];
    sort(ans + 1, ans + cnt + 1, cmpFunctor());
    int tot = 1;
    for (int i = cnt; i >= 1; i--) {
        if(ans[i] < c[tot]) {
            ans[i] = c[tot];
            tot++;
        }
        if(tot > C)
            break;
    }
    ll Ans = 0;
    for (int i = 1; i <= cnt; i++)
        Ans += ans[i];
    printf("%lld\n", Ans);
        return 0;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int a[N],mx[N];
int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=n;i>=1;i--) mx[i]=max(mx[i+1],a[i]);
	int x=0,ans=0;
	for(int i=1;i<=n;i++){
		if(mx[i]-a[i]>x) x=mx[i]-a[i];
	}
	for(int i=1;i<=n;i++){
		if(mx[i]-a[i]==x) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4604
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    System.out.println(n % 1000 == 0 ? 0 : 1000 - (n % 1000));
  }
}


Measured memory_bytes: 27028
#include <stdio.h>
main()
{
 int a,b,c,d;
 scanf("%d %d %d",&a,&b,&c);

 if(a > b)
 {
  d=a,a=b,b=d;
 }
 if(b > c)
 {
  d=b,b=c,c=d;
 }
 if(a > b)
 {
  d=a,a=b,b=d;
 }

 printf("%d %d %d\n",a,b,c);

}

Measured memory_bytes: 1824
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    long r = sc.nextLong();
    long s = sc.nextLong();
    long p = sc.nextLong();
    String t = sc.next(); 
    ArrayList[] list = new ArrayList[k];
    for(int i = 0; i < k; i++) {
      list[i] = new ArrayList<Integer>();
    }
    for(int i = 0; i < t.length(); i++) {
      if(t.charAt(i) == 'r') {
        list[(i % k)].add(0);
      } else if(t.charAt(i) == 's') {
        list[(i % k)].add(1);
      } else {
        list[(i % k)].add(2);
      }
    }
    long ans = 0;
    for(int i = 0; i < k; i++) {
      int q = list[i].size();
      long[][] dp = new long[q][3];
      if((int)list[i].get(0) == 0) {
        dp[0][2] = p;
      } else if((int)list[i].get(0) == 1) {
        dp[0][0] = r;
      } else {
        dp[0][1] = s;
      }
      for(int j = 1; j < q; j++) {
        for(int l = 0; l < 3; l++) {
          if(l == 0) {
            if((int)list[i].get(j) == 1) {
              dp[j][l] = r + Math.max(dp[j - 1][1], dp[j - 1][2]);
            } else {
              dp[j][l] = Math.max(dp[j - 1][1], dp[j - 1][2]);
            }
          } else if(l == 1) {
            if((int)list[i].get(j) == 2) {
              dp[j][l] = s + Math.max(dp[j - 1][0], dp[j - 1][2]);
            } else {
              dp[j][l] = Math.max(dp[j - 1][0], dp[j - 1][2]);
            }
          } else {
            if((int)list[i].get(j) == 0) {
              dp[j][l] = p + Math.max(dp[j - 1][0], dp[j - 1][1]);
            } else {
              dp[j][l] = Math.max(dp[j - 1][0], dp[j - 1][1]);
            }
          }         
        }
      }
      long w = Math.max(dp[q - 1][0], dp[q - 1][1]);
      w = Math.max(w, dp[q - 1][2]);
      ans += w;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 39248
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		int A =sc.nextInt();
		int B =sc.nextInt();
		int K;
		K=A+B;
		if(K>=24){
			K=K-24;
		}
		System.out.println(K);
	}

}


Measured memory_bytes: 21844
#!/usr/bin/env python


def selectionSort(line, size):
    """Rerutn sorted list.

    >>> selectionSort([1, 2, 3, 4], 4)
    ([1, 2, 3, 4], 0)

    >>> selectionSort([5,6,4,2,1,3], 6)
    ([1, 2, 3, 4, 5, 6], 4)
    """
    count = 0
    for i in range(0, size):
        minj = i
        for j in range(i, size):
            if line[j] < line[minj]:
                minj = j
        if line[i] != line[minj]:
            tmp = line[i]
            line[i] = line[minj]
            line[minj] = tmp
            count += 1
    return line, count


def main():
    size = int(input())
    line = list(map(int, input().split()))
    ans_list, count = selectionSort(line, size)
    ans = " ".join(map(str, ans_list))
    print(ans)
    print(count)


if __name__ == '__main__':
    import doctest
    doctest.testmod()
    main()

Measured memory_bytes: 12244
#include <stdio.h>

unsigned long long int gcd(unsigned long long int x, unsigned long long int y)
{
	if(x<y) return gcd(y,x);
    if(y == 0)  // 引数チェック
    {
        return x;
    }

    // ユーグリッドの互除法
    return gcd(y, x % y);
}


unsigned long long int lcm(unsigned long long int x, unsigned long long int y)
{
	unsigned long long int r = gcd(x, y);
	return (x / r * y);
}



int main(){
	int i, N;
	unsigned long long int min, T[101];

	scanf("%d", &N);

	for(i = 1; i <= N; i++) {
		scanf("%lld", &T[i]);
	}

	min = 1;

	for(i = 1; i <= N; i++) {
		min = lcm(T[i], min);
	}

	printf("%lld", min);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

int num[8];
int a[8];
int p[8];
int ans;
int n,m;
vector<int> v[8];
int q[8];

void solve(int h) {
  bool f = 0;
  REP(i,n) {
    if (num[i]) f= 1;
  }
  if (!f) {
    REP(i,n) q[i] = i;
    REP(i,h) {
      FOR(it, v[i]) {
        swap(q[*it],q[*it+1]);
      }
    }
    bool ok = 1;
    REP(i,n) if (p[i] != q[i]) ok = 0;
    if (ok) chmin(ans,h);
    return;
  }
  REP(S,1<<n-1) {
    if (S == 0) continue;
    bool f = 1;
    vector<int> vec;
    REP(i,n-1) {
      if (S>>i&1) {
        if (i<n-2 && S>>i+1&1) f = 0;
        if (num[i]==0) f = 0;
        num[i]--;
        vec.push_back(i);
      }
    }
    if (f) {
      v[h] = vec;
      solve(h+1);
    }
    REP(i,n) {
      if (S>>i&1) {
        num[i]++;
      }
    }
  }
}

int main() {
  while(cin>>n>>m) {
    REP(i,n) num[i] = 0;
    REP(i,m) {
      cin >> a[i];
      num[a[i]-1]++;
    }
    REP(i,n) p[i] = i;
    REP(i,m) {
      swap(p[a[i]-1],p[a[i]]);
    }
    ans = INF;
    solve(0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int k, x; scanf("%d%d", &k, &x);
	if(k*500 >= x) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

double Euclid(pair<double, double> x, pair<double, double> y) {
    return sqrt((x.first - y.first) * (x.first - y.first) +
                (x.second - y.second) * (x.second - y.second));
}
int main() {
    int N;
    cin >> N;
    vint x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    vint bits(N, 0);
    rep(i, N - 1) bits[i + 1] += bits[i] + 1;
    double count = 0;
    double ans = 0.0;
    do {
        double sum = 0;
        rep(i, N - 1) {
            sum += Euclid({x[bits[i]], y[bits[i]]},
                          {x[bits[i + 1]], y[bits[i + 1]]});
        }
        ans += sum;
        count++;
    } while (next_permutation(all(bits)));
    cout << setprecision(12) << ans / count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll _rand() {
	static random_device rd;
	static mt19937_64 mt(rd());
	return mt();
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin>>N;
	vector<ll> a(N);
	REP(i,N) cin>>a[i];
	map<ll,__int128> hash;
	REP(i,N) hash[a[i]]=-1;
	REP(i,N) if(hash[a[i]]==-1) hash[a[i]]=_rand();
	__int128 h1=1,h2=1;
	vector<ll> ans;
	REP(i,N) {
		h1*=hash[a[i]];
		h2*=hash[a[N-1-i]];
		h1%=MOD; h2%=MOD;
		if(h1==h2) ans.pb(i+1);
	}
	if((ll)ans.size()==0) cout<<endl;
	DUMP(ans);
}



Measured memory_bytes: 7512
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=2001;

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3 ;
  if(s1[s1.length()-1]==s2[0] && s2[s2.length()-1]==s3[0])  cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, x = ril()
ls = ril()
s = 0
count = 0
for l in ls:
    s += l
    if s <= x:
        count += 1
    else:
        break
print(count + 1)

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll a, b;
  cin >> a >> b;
  cout << max(ll(0), a-2*b) << endl;
  return 0;
}


Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    bars = []
    for _ in range(M):
        a, b = LI_()
        bars.append((a,b))
    bars = sorted(bars, key=lambda x: x[0])
    l_max = bars[0][0]
    r_min = bars[0][1]

    count = 1 
    for bar in bars[1:]:
        l, r = bar
        if r_min <= l:
            count += 1
            r_min = r
        else:
            r_min = min(r, r_min)
        l_max = l

    print(count)
main()



Measured memory_bytes: 21496
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	vi a(3);
	for(int i=0; i<3; ++i){
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	if(a[0]==a[1] and a[1]==a[2]){
		cout<<"No";
		return 0;	
	}else if(a[0]==a[1] or a[1]==a[2]){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	
	
	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

if 1 in a:
    i = a.index(1)
    now = 1
    while i < n:
        if a[i] == now + 1:
            now += 1
        i += 1
    print(n - now)
else:
    print(-1)


Measured memory_bytes: 26268
#include <iostream>
using namespace std;
int a, b;
int main(void){
    // Your code here!
    cin >> a >> b;
    
    int tmp1, tmp2, tmp3;
    
    tmp1 = 2 * a -1;
    tmp2 = a + b;
    tmp3 = 2 * b - 1;
    
    int max = tmp1;
    if(max < tmp2) max = tmp2;
    if(max < tmp3) max = tmp3;
    
    cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    int n;
    cin>>n;
    int sum=0,big=0;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l.at(i);
        sum+=l.at(i);
        big=max(big,l.at(i));
    }
    if(big<sum-big){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n, ans = 0LL;
    cin >> n;
    vector<ll> a(n);
    rep(n) cin >> a[i];
    

    vector<ll> total(n+1, 0LL);
    total[1] = a[0];
    reppp(i, 2, n+1) total[i] = total[i-1] + a[i-1];
    
    map<ll, ll> mp;
    rep(n+1){
        ans += mp[total[i]];
        mp[total[i]]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <iostream>

namespace ABC172
{
  class A
  {
  public:
    A() = default;
    ~A() = default;


    void Run()
    {
      int a = {};
      std::cin >> a;

      int answer = a + a * a + a * a*a;

      std::cout << answer << std::endl;
    }
  };


}
int main()
{

  ABC172::A prob;
  prob.Run();

  return 0;
}




Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int N, X;
int L[100];

int main() {
    cin >> N >> X;
    rep(i, N) cin >> L[i];
    int d = 0, prev;
    int i = 0;
    for(; i < N + 1; i ++) {
        if (d > X) break;
        int p = d;
        prev = d;
        d = p + L[i];
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
char A[60][60];
char B[60][60];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",A[i]);
	for(int i=0;i<b;i++)scanf("%s",B[i]);
	for(int i=0;i<=a-b;i++)for(int j=0;j<=a-b;j++){
		bool ok=true;
		for(int k=0;k<b;k++)for(int l=0;l<b;l++){
			if(B[k][l]!=A[i+k][j+l])ok=false;
		}
		if(ok){
			printf("Yes\n");return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
//typedef pair<int, int> P;

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

//from http://drken1215.hatenablog.com/entry/2019/09/16/014600

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

int main() { 
    int N;
    string S;
    cin >> N >> S;

    int res = 0;
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);//T=s[i:]
        auto lcp = Zalgo(T);//T自身とT[j:]との最大共通接頭辞の長さ(=lcp)を計算?

        for (int j = 0; j < T.size(); ++j) {
            int l = min(lcp[j], j);//lcp<=j
            res = max(res, l);
        }
    }
        
    cout << res << endl;
}

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

int main(){
    string S;  cin >> S;
    int N = S.length();
    vector<int> ans(N, 0);

    int cnt = 0;
    for(int i=0; i<N; i++){
        if(S[i]=='R'){
            cnt++;
            continue;
        }

        if(cnt%2==0){
            ans[i-1] += cnt/2;
            ans[i] += cnt/2;
        }else{
            ans[i-1] += cnt/2 + 1;
            ans[i] += cnt/2;
        }
        cnt = 0;
    }
    for(int i=N-1; i>=0; i--){
        if(S[i]=='L'){
            cnt++;
            continue;
        }

        if(cnt%2==0){
            ans[i+1] += cnt/2;
            ans[i] += cnt/2;
        }else{
            ans[i+1] += cnt/2 + 1;
            ans[i] += cnt/2;
        }
        cnt = 0;
    }

    for(int a: ans){
        cout << a << " ";
    }cout << endl;
}


Measured memory_bytes: 1024
//05
#include<iostream>

using namespace std;

int main(){
  for(int t;cin>>t,t;){
    int n;
    int sm=0;
    cin>>n;
    while(n--){
      int s,f;
      cin>>s>>f;
      sm+=f-s;
    }
    if(sm>=t){
      cout<<"OK"<<endl;
    }else{
      cout<<t-sm<<endl;
    }
  }
  return 0;
}
    

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(){
  std::vector<ll> v(3);
  rep(i,3)std::cin >> v[i];
  sort(v.begin(),v.end());

  ll S=v[0]*v[1];

  ll mi=S*(v[2]/2+1);
  ll ma=S*(v[2]/2);


  if(v[0]%2==0 || v[1]%2==0 || v[2]%2==0)std::cout << "0" << '\n';
  else std::cout << mi-ma << '\n';


  return 0;
}


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

        String a = scan.next();
        char[] c = a.toCharArray();
        int cou=0;
        for(int i=0;i<c.length;i++){
            if(i>=c.length-i-1)break;
            if(c[i]==c[c.length-i-1]){

            }else{
                cou++;
            }
        }
        System.out.println(cou);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
#define DBG cout << '!' << endl;	

bool is_p(int n)
{
	for(int i = 2;i * i <= n;i++)
	{
		if(n % i == 0)return false;
	}
	return n != 1;
}

int main()
{
	int a,d,n;
	while(cin >> a >> d >> n,a)
	{
		int _count = 0;
		if(is_p(a))_count++;
		while(_count != n)
		{
			a += d;
			if(is_p(a))_count++;
		}
		cout << a << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3020
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.nextLine();
    char[] cs = s.toCharArray();

    List<Character> rud = Arrays.asList('R', 'U', 'D');
    List<Character> lud = Arrays.asList('L', 'U', 'D');

    boolean isEasy = true;
    for (int i = 0; i < cs.length; i++) {
        if ((i % 2 == 0 && !rud.contains(cs[i]))
            ||
            (i % 2 != 0 && !lud.contains(cs[i]))) {
            isEasy = false;
            break;
        };
    }

    System.out.println(isEasy ? "Yes" : "No");
  }
}

Measured memory_bytes: 23892
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
  char s[7];

  scanf("%s",&s);

  if (s[2] == s[3] && s[4] == s[5]){
      printf("Yes\n");
  }
  else{
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
using PII = pair<int, int>;
using VP  = vector<PII>;
using VVP = vector<VP>;
int n, a, x, y, res;
bool ok;
VVP v;
inline void Check(int mask) {
    int nrb = __builtin_popcount(mask);
    if (nrb <= res)
        return;
    for (int i = 0; i < n; ++i)
        if (mask & (1 << i))
            for (const PII& P : v[i]) {
                tie(x, y) = P;
                if ((!(mask & (1 << x)) && y) || ((mask & (1 << x)) && !y))
                    return;
            }
    res = nrb;
    return;
}
int main() {
    DAU
    cin >> n;
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        v[i].resize(a);
        for (PII& P : v[i]) {
            cin >> P.first >> P.second;
            --P.first;
        }
    }
    for (int mask = 0; mask < (1 << n); ++mask)
        Check(mask);
    cout << res;
    PLEC
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  int x[100000];
  int s[100000];
  int ans = 0;
  
  cin >> n >> m;

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

  sort(x, x + m);

  for(int i = 0;i < m - 1;i++){
	s[i] = abs(x[i] - x[i + 1]);
	ans += abs(x[i] - x[i + 1]);
  }

  sort(s, s + m - 1);

  for(int i = 1;i < m && i <= n - 1; i++){
	ans -= s[m - i - 1];
  }

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


Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    scanf("%d", &N);
    vector<int> A(N);
    for(auto it=A.begin(); it!=A.end(); it++){
        scanf("%d", &(*it));
    }

    auto print=[&A]{
        for(auto it=A.begin(); it!=A.end(); it++){
            if(it!=A.begin()){
                printf(" ");
            }
            printf("%d", *it);
        }
        printf("\n");
    };

    bool flag=true;
    int cnt=0;
    while(flag){
        flag=false;
        for(int j=N-1; j; j--){
            if(A[j]<A[j-1]){
                swap(A[j], A[j-1]);
                flag=true;
                cnt++;
            }
        }
    }
    print();
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2744
//****author RKN
//DATE 5/2/2020 5.15 AM
 
 
// ***************DREAM IS NOT THAT YOU SEE WHILE SLEEPING BUT IT IS WHAT DONT LET YOU SLEEP************//
 
 
///////////////////////    machayenge......sala hoga apne se bhi ek din    ///////////////////////////////////////////////////////////
 
#include<bits/stdc++.h>
#include <utility> 
using namespace std;
 
/////////////////////////////   %   variable  %   //////////////////////////////////////////////////////////////
 
#define ll long long
#define pb push_back 
#define pof pop_front
#define f1 first
#define s2 second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pr pair<ll,ll>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define loop(start,end,inc) for(int i=start;i<=end;i+=inc)
typedef std::vector<std::vector<int>> vec2d;
#define pr1 pair<ll,pair<ll,ll>>
//#define prm pair<ll,map<ll,ll>>
int dir1[8]={1,-1,0,0,-1,1,-1,1};
int dir2[8]={0,0,-1,1,-1,1,1,-1};
#define en "\n"

//void rtime(){time_p=clock()-time_p;cerr<<"******************\nTime taken : "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";}

ll MAX=1000000007;
//ll MAX=13;
vector<ll>prime(1000001);
vector<ll>getprm;
ll power(ll a,ll b)
{
       if(b == 0)
       return 1;
       auto q= (power( a, (b/2) ));
       q=q%MAX;
       q = (q * q) % MAX;
       if ( b%2 == 0)
       return q%MAX;
       else
       return ((q%MAX)*(a%MAX)) % MAX;
}

ll modinv ( ll val )
{
       return power ( val, MAX-2 );
}
 
void primecalc()
{
       fill(all(prime),1);
       prime[0]=0;prime[1]=0;
       for(int i=2;i<=sqrt(1000001);i++)
       {
              if(prime[i])
              {
                     //cout<<i<<" ";
                     getprm.pb(i);
                     for(int j=i+i;j<=1000000;j+=i)
                     prime[j]=0;
              }
       }
}

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

ll n,m;
vector<vector<int>>v(100001);
bool visited[100001];
vector<int>mp(100001);

int dfs(ll val)
{
    visited[val]=1;
    int cnt=0;
    for(int i=0;i<v[val].size();i++)
    {
        ll ele=v[val][i];
       // cout<<val<<" "<<ele<<en;
        if(!visited[ele])
        cnt=max(dfs(ele),cnt);
        else
        cnt=max(mp[ele]+1,cnt);
        //cout<<"cnt "<<cnt<<en;
    }
    mp[val]=cnt;
    return cnt+1;
}

int main()
{
    fast;
    ll a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].pb(b);
    }
    int r=0;
    for(int i=1;i<=n;i++)
    {
    if(!visited[i])
    r=max(dfs(i),r);
    }
    cout<<r-1;
    return 0;
}


Measured memory_bytes: 16128
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var list = new List<string>();
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ');
        if(n % 2 == 1){
            for(var i = n - 1;i >= 0;i -= 2){
                list.Add(a[i]);
            }
            for(var i = 1;i < n;i += 2){
                list.Add(a[i]);
            }
        }else{
            for(var i = n - 1;i >= 0;i -= 2){
                list.Add(a[i]);
            }
            for(var i = 0;i < n;i += 2){
                list.Add(a[i]);
            }
        }
        var ans = String.Join(" ",list);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 44224
#include <stdio.h>
#include <string.h>

void lowc(char *c) {
    while (*c != '\0') {
        if (*c >= 'A' && *c <= 'Z')
            *c += 32;
        c++;
    }
    return;
}

int main() {
    char w[15], t[1005];
    char nd[] = "END_OF_TEXT";
    int cnt = 0;
    scanf("%s", w);
    lowc(w);
    while (1) {
        scanf("%s", t);
        if (strcmp(t, nd) == 0) break;
        lowc(t);
        if (strcmp(t, w) == 0) cnt++;
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 2112
num = input().split(' ')
lifeTakahashi = int(num[0])
attackTakahashi = int(num[1])
lifeAoki = int(num[2])
attackAoki = int(num[3])

while lifeTakahashi > 0:
  lifeAoki = lifeAoki - attackTakahashi
  if(lifeAoki > 0):
    lifeTakahashi = lifeTakahashi - attackAoki
    continue
  else:
    print('Yes')
    break

if(lifeTakahashi <= 0):
  print('No')

Measured memory_bytes: 61688
A = list(map(int,input().split(" ")))
num = len(A)

for i in range(1,num):
	v = A[i]

	for j in range(i-1,-1,-1):
		if A[j] > v:
			#値移動
			A[j+1] = A[j]
		else:
			#何もしない
			A[j+1] = v
			break
	else:
		A[0] = v

list2 = [str(k) for k in A]
print(" ".join(list2))



Measured memory_bytes: 5600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define num sizeof(a)/sizeof(int)
#define N 100000

int main(){
    char s[3*N],add[2],sagyou[3*N],emp[3*N];
    int q,size,t,f,number=0,i,ins,distin=0;
    scanf("%s%d",s,&q);
    s[N-1]='\0';
    strcpy(sagyou,s);
    for(size=0;s[size]!='\0';size++);

    while(q!=0){
        scanf("%d",&t);
        if(t==1){//反転
            distin+=1;
            distin%=2;
        }else if(t==2){//追加
            scanf("%d",&f);
            if((f==1 && distin%2==0) || (f==2 && distin%2)==1){
                //先頭追加(末尾追加でないと遅いので二つの配列を用いる)
                scanf("%s",add);
                strcat(emp,add);
                number++;
            }else if((f==2 && distin%2==0) || (f==1 && distin%2==1)){
                //末尾追加
                scanf("%s",add);
                strcat(sagyou,add);
                size++;
            }
        }
        q--;
    }

    if(distin%2==0){//後ろからか前からか
        for(i=number-1;i>=0;i--){
            putchar(emp[i]);
        }
        printf("%s\n",sagyou);
    }else{
        for(i=size-1;i>=0;i--){
            putchar(sagyou[i]);
        }
        printf("%s\n",emp);
    }
    return 0;
}

Measured memory_bytes: 896