akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int n,m,e[55][55],num[55],low[55];
int root,index,ans=0;
void dfs(int cur,int dad)
{
    int i;
    index++;
    num[cur]=low[cur]=index;
    for(i=1;i<=n;i++)
    {
        if(e[cur][i]==1)
        {
            if(num[i]==0)
            {
                dfs(i,cur);
                low[cur]=min(low[cur],low[i]);
                if(low[i]>num[cur])
                   ans++;
            }
            else if(i!=dad)
                low[cur]=min(low[cur],num[i]);
        }
    }
}
int main()
{
    int i,a,b;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
       cin>>a>>b;
        e[a][b]=1;
        e[b][a]=1;
    }
    root=1;
    dfs(1,root);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// 電子レンジ

#include <iostream>
using namespace std;

bool cond1(bool frozen, int tmp_t);
bool cond2(bool frozen, int tmp_t);
bool cond3(bool frozen);


int main() {
    int Ac; // 元の温度 Ac < Bc
    int Bc; // 目的の温度
    int Ct; // 凍った肉を1度温める時間
    int Dt; // 凍った肉を解凍するのにかかる時間
    int Et; // 凍ってない肉を1度温める時間

    int time = 0; // 肉を温めるのにかかる時間
    int tmp_t; // 途中の温度
    bool frozen; // 凍ってるか？

    cin >> Ac >> Bc >> Ct >> Dt >> Et;
    tmp_t = Ac;

    // set frozen, Aは0じゃない
    if (Ac > 0) frozen = false;
    if (Ac < 0) frozen = true;
    if (Ac == 0) return 1;


    while (tmp_t != Bc) {
        if (cond1(frozen, tmp_t)) {
            time += Ct;
            tmp_t++;
        } else if (cond2(frozen, tmp_t)) {
            time += Dt;
            frozen = false;
        } else if (cond3(frozen)) {
            time += Et;
            tmp_t++;
        }
    }
    cout << time << "\n";
    return 0;
}

bool cond1(bool frozen, int tmp_t) {
    // 肉が凍っていて、温度が0度より小さい
    return (frozen & (tmp_t < 0));
}

bool cond2(bool frozen, int tmp_t) {
    // 肉が凍っていて、温度がちょうど0度
    return (frozen & (tmp_t == 0));
}

bool cond3(bool frozen) {
    // 肉が凍っていない
    return !(frozen);
}


Measured memory_bytes: 3124
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			long a = in.nextLong();
			long b = in.nextLong();
			int k = 2;
			long lcm = 1;
			while(k < a || k < b){
				while(a%k == 0 && b%k == 0){
					a = a/k;
					b = b/k;
					lcm = lcm*k;
				}
				k++;
			}
			System.out.println(lcm+" "+(lcm*a*b));
		}
	}
}

Measured memory_bytes: 12000
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    map<int, int> mp;
    FOR(i, 0, N){
        int a;
        cin >> a;
        mp[a]++;
    }

    int sum = 0;
    for(auto p : mp){
        int key = p.first;
        int count = p.second;

        int delete_num;
        if(key <= count){
            delete_num = count - key;            
        }else{
            delete_num = count;
        }
        sum+= delete_num;
    }

    p(sum);
    
    return 0;
}

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

int main()
{
    int n,a,b;

    cin>>n>>a>>b;
    if(n*a < b)
    {
        cout<<n*a<<endl;
    }
    else
    {
        cout<<b<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#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 PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000000+7;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  ll n, k;  cin >> n >> k;
  vector<int> teleport(n+1);
  vector<int> visited(n+1, -1);
  int cnt=0;
  REP(i, n){
    cin >> teleport[i+1];
  }

  {
    int now=1;
    int to=teleport[now];
    visited[now]=0;
    //cout << now << " : " << to << " : "<< visited[now] << endl;
    while(visited[to]==-1){
      now=to;
      cnt++;
      visited[now]=cnt;
      to = teleport[now];
      if(k-cnt==0){
        cout << now << endl;
        return 0;
      }
      //cout << "  ↓  " << endl;
      //cout << now << " : " << to << " : "<< visited[now] << endl;
    }
    now = to;
    cnt++;
    to = teleport[now];
    k -= visited[now];
    k %= (cnt-visited[now]);
    //cout << "  ↓  " << endl;
    //cout << now << " : " << to << endl;
    while(k>0){
      now = to;
      to = teleport[now];
      k--;
      //cout << "  ↓  " << endl;
      //cout << now << " : " << to << endl;
    }
    cout << now << endl;
  }
}


Measured memory_bytes: 4812
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    // double area, area1, area2, max1, max2, res;
    // area = (W -x)*H;
    // area1 = W*H - area;
    // if(area > area1){max1 = area1;}
    // else{max1 = area;}
    // area = W*(H-y);
    // area1 = W*H - area;
    // if(area > area1){max2 = area1;}
    // else{max2 = area;}
    // int fg= 0;
    // if(max1 > max2){res = max1;}
    // else if(max1 < max2){res = max2;}
    // else{res = max1; fg = 1;}

    // if(fg == 0){cout << res << " " << fg << endl;}
    // else{cout << res << " " << fg << endl;}
    double max;
    max = (double(W) * double(H)) / 2;
    int fg=0;
    if((2*x == W) && (2*y == H)){fg = 1;}
    cout << max << " " << fg << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 1000
void InsortionSort (int ,int *);//This function includes display procedure
void print (int, int*);

int main(){
    int array[N], *p = array;
    int i, n; // n is for storing number

    //input the number of data and data
    scanf("%d", &n);
    for (i = 0; i < n; i++)
	scanf("%d", &array[i]);
    
    print(n, p);
    //sort procedure
    InsortionSort(n, p);
    
    return 0;
}

void InsortionSort ( int n, int *p ){
    int i, j;
    int key;

    for (i = 1; i < n; i++){
	key = p[i];
	for (j = i-1; j >= 0 && p[j] > key; j--){
	    p[j+1] = p[j];
	    p[j] = key;
	}
	print(n, p);
    }
}

void print(int n, int* p ){
    int i;
    for (i = 0; i < n-1; i++)
	printf("%d ", p[i]);
    printf("%d\n", p[i]);
}


Measured memory_bytes: 2064
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

S = input()
#N = int(input())
#N, M = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

if ord(S) >= ord("a"):
    print("a")
else:
    print("A")

Measured memory_bytes: 65196
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let s: String = read!();
    let s = s.chars().collect_vec();

    let mut now = 0;
    for c in s {
        let i = c.to_digit(10).unwrap();
        now += i;
        now %= 9;
    }

    let ans = if now == 0 { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout<<sum;
    return 0;
}


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

int main()
{
    int H,W;
    for(int r=0; ; r++){
        cin >> H >> W;
        if(H==0 && W==0)
            break;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

int n, m, k;
char s[12][1111];
int sum[12][1111];

int check(int sta)
{
    vector<int> v;
    for(int i = 0; i < n - 1; i++)
        if((sta >> i) & 1)
            v.pb(i + 1);
    v.pb(n);

    int res = 0;
    int pre = 0;
    for(int j = 1; j <= m; j++)
    {
        int up = 0;
        bool ck = 0;
        for(auto x : v)
        {
            if(sum[x][j] - sum[up][j] - sum[x][pre] + sum[up][pre] > k) ck = 1;
            up = x;
        }
        if(ck == 1)
        {
            if(pre + 1 == j) return INF;
            res++;
            pre = j - 1;
        }
    }
    return res;
}

void work()
{
    cin >>n >>m >>k;
    for(int i = 1; i <= n; i++) scanf("%s", s[i] + 1);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (s[i][j] == '1');

    int tot = (n - 1) + (m - 1);

    for(int i = 0; i < (1 << (n - 1)); i++)
    {
        int t = check(i);
        int cnt = 0, j = i;
        while(j)
        {
            cnt++;
            j -= lowbit(j);
        }

        tot = min(tot, t + cnt);
    }
    cout <<tot <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
k,t = map(int,input().split())
ans = 0
l = list(map(int,input().split()))
m = max(l)
if m > k//2:
    if k%2:
        print(max(0,m-(k-m)-1))
    else:
        print(m-(k-m)-1)
else:
    print(0)

Measured memory_bytes: 9084
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		
		System.out.println(SecondtoHMS(Integer.parseInt(str)));
	}
	
	public static String SecondtoHMS(int second){
		int h = 0, m = 0, s = 0;
		
		while(second >= 60 * 60){
			second -= 60 * 60;
			h ++;
		}
		
		while(second >= 60){
			second -= 60;
			m ++;
		}
		
		s = second;
		
		return h + ":" + m + ":" + s;
	}
}

Measured memory_bytes: 26108
#include <stdio.h>
int main(){
	int a[1000000];
	int n,i;
	n=0;
	do{
		n=n+1;
		scanf("%d",&a[n]);
	}while(a[n]!=0);
	
	for(i=1;i<n;i++){
		printf("Case %d: %d\n",i,a[i]);
	}
return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	string S;

	cin >> N >> S;

	int ans = 0;
	int sum = 0;
	for(auto x : S){
		if(x == 'I')
			sum++;
		else
			sum--;
		ans = max(ans, sum);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> 
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

string S;
vector<int> changeAC(string &tmp){
    vector<int> t(tmp.size(),0);
    REP(i,tmp.size()-1){
        if(tmp[i]=='A' and tmp[i+1] == 'C'){
            //Sの1文字目からi文字目までに出現するaの数
            t[i+1] = t[i] + 1;
        }else{
            t[i+1] = t[i];
        }
    }
    return t;
}

int main(){
    int N,Q;cin>>N>>Q;
    cin>>S;
    vector<int> l(Q),r(Q);
    REP(i,Q){
        cin>>l[i]>>r[i];
    
    }
    //cout<<"-----"<<endl;
    vector<int> t = changeAC(S);
   // REP(i,N) cout<<t[i]<<endl;
    //cout<<"-----"<<endl;
    REP(i,Q){
        cout<<t[r[i]-1]-t[l[i]-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

class IntMutableList {
  private val initialCapacity = 10
  private var innerArray = IntArray(initialCapacity)
  var size = 0
    private set

  fun add(x: Int) {
    if (size == innerArray.size) {
      innerArray = innerArray.copyOf(innerArray.size * 2)
    }
    innerArray[size] = x
    size++
  }

  fun toIntArray(): IntArray = innerArray.copyOfRange(0, size)
}

fun main(args: Array<String>) {
  val (n, k, q) = fastReadInts(3)
  val xs = fastReadInts(n)

  var ans = Int.MAX_VALUE

  // Define here for performance.
  val forbidden = BooleanArray(n)
  for (l in xs) {
    forbidden.fill(false)

    for (i in 0 until n) {
      if (xs[i] < l) {
        forbidden[i] = true
      }
    }

    val mutCandidates = IntMutableList()
    var s = 0
    while (s < n) {
      if (forbidden[s]) {
        s++
      } else {
        var t = s
        while (t + 1 < n && !forbidden[t + 1]) {
          t++
        }
        // xs[s]..xs[t] is a valid range.
        val segmentLength = t - s + 1
        if (segmentLength >= k) {
          val mutSegmentValues = IntMutableList()
          for (i in s..t) {
            mutSegmentValues.add(xs[i])
          }
          val segmentValues = mutSegmentValues.toIntArray()
          segmentValues.sort()
          for (i in 0 until segmentLength - k + 1) {
            mutCandidates.add(segmentValues[i])
          }
        }
        s = t + 1
      }
    }

    if (mutCandidates.size < q) continue

    val candidates = mutCandidates.toIntArray()
    candidates.sort()
    val u = candidates[q - 1]
    ans = Math.min(u - l, ans)
  }
  println(ans)
}


Measured memory_bytes: 70944
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
    	int d=x-i;
    	int ans=2*i+d*4;
    	if(ans==y){
    		cout<<"Yes"<<endl;
    		return 0;
    	}
    }
    cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

long long solve(vector<long long>&v,int n,int k)
{
  vector<long long> dp(n);
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    dp[i]=INT_MAX;
    for(int j=1;j<=k&&i-j>=0;j++)
    {
      dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
    }
  }
  return dp[n-1];
}

int main()
{
  int n,k;
  cin>> n>>k;
  vector<long long> v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  cout<<solve(v,n,k);
  return 0;
}


Measured memory_bytes: 4808
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

const int MAX=1001;
const int INF=1<<29;

int dp[MAX][MAX];

int main(){

	int n;
	cin >> n;

	rep(i,n){
		string a,b;
		cin >> a >> b;
	
		fill_n((int *)dp,sizeof(dp)/sizeof(int),0);
		
		rep(i,a.size()+1){
			rep(j,b.size()+1){
				if(i==0||j==0) dp[i][j]=0;
				else if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
				else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			}
		
		}

		cout << dp[a.size()][b.size()] << endl;
	
	}

}

Measured memory_bytes: 5124
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll A[9];
    bool marked[9];
    ll N;
    ll b;
    bool bingo = false;

    for(ll i = 0; i < 9; i++){
        cin >> A[i];
        marked[i] = false;
    }
    cin >> N;
    for(ll i = 0; i < N; i++){
        cin >> b;
        for(ll j = 0; j < 9; j++){
            if(A[j] == b){
                marked[j] = true;
            }
        }
    }

    for(ll i = 0; i < 3; i++){
        if(marked[3 * i] && marked[3 * i + 1] && marked[3 * i + 2]){
            bingo = true;
        }
        if(marked[i] && marked[i + 3] && marked[i + 6]){
            bingo = true;
        }
    }
    if(marked[0] && marked[4] && marked[8]){
        bingo = true;
    }
    if(marked[2] && marked[4] && marked[6]){
        bingo = true;
    }

    if(bingo){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def gcd(a,b):
  if a>b:
    a,b = b,a
  if b%a == 0:
    return a
  else:
    return gcd(b%a,a)

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

from collections import defaultdict

L = defaultdict(lambda :1)
R = defaultdict(lambda :1)
L[1] = A[0]
R[1] = A[N-1]

for i in range(2,N):
  L[i] = gcd(L[i-1],A[i-1])
  R[i] = gcd(R[i-1],A[N-i])

ans = max(L[N-1],R[N-1])
for i in range(1,N-1):
  ans = max(ans,gcd(L[i],R[N-1-i]))

print(ans)

Measured memory_bytes: 27564
#include <iostream>
#include <stdio.h>
int m, f, r;

char grade(int m,int f,int r)
{
    if(m<0||f<0) return 'F';
    if(m+f>=80) return 'A';
    if(m+f>=65) return 'B';
    if(m+f>=50) return 'C';
    if(m+f>=30)
    {
        if(r>=50) return 'C';
        else return 'D';
    }
    return 'F';
}

int main()
{
    
while(true){
  scanf("%d %d %d", &m, &f, &r);

  if(m == -1 && f == -1 && r == -1) break;

  /* 入力された点数に対する処理... */
  char result=grade(m,f,r);
  std::cout<<result<<"\n";

}
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <map>

using namespace std;

int N;
string str;
const int M = 1000000000+7;

int main() {
  while (cin >> N >> str) {
    map<char, int> cnt;
    for (char ch : str) {
      ++cnt[ch];
    }
    long long ans = 1;
    for (auto it : cnt) {
      int m = it.second;
      ans = (ans * (m+1)) % M;
    }
    cout << ans-1 << endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll a,b;cin>>a>>b;
    ll ans=max(0,a-2*b);
    cout<<ans<<endl;
    
    return 0;
}


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

char str[1200];

main(){

  int n,i,j;

  scanf("%s",str);

  n=strlen(str);

  for(i=0;i<n;i++){
    str[i]=((str[i]+23)-65)%26+65;
  }
  printf("%s\n",str);

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int N = 5000;

int MOD;
int n, m;
ll g[N][N], f[N];
ll fac[N], inv_fac[N];

inline ll add( ll a, ll b ) {
	ll ret = a + b; 
	if( ret >= MOD ) ret -= MOD;
	if( ret < 0 ) ret += MOD;
	return ret;
}

ll C( int n, int m ) {
	return fac[n] * inv_fac[n-m] %MOD * inv_fac[m] %MOD;
}

inline ll ksm( ll a, ll b, ll mod ) {
	ll ret = 1;
	for( ; b; b >>= 1, a = a * a %mod )
		if( b & 1 ) ret = ret * a %mod;
	return ret;
}	

void calc_fac( int size )
{
	fac[0] = 1;
	for( int i = 1; i <= size; i ++ )
		fac[i] = fac[i-1] * i %MOD;
	
	for( int i = 0; i <= size; i ++ )
		inv_fac[i] = ksm( fac[i], MOD-2, MOD );
}

void calc_g()
{
	memset( g, 0, sizeof( g ) ); 
	for( int i = 0; i <= n; i ++ )
		g[i][0] = 1;
	
	for( int i = 1; i <= n; i ++ )
		for( int j = 1; j <= i; j ++ )
			g[i][j] = add( g[i-1][j-1], g[i-1][j] * ( j + 1 ) %MOD ); 
}

void calc_f()
{
	for( int i = 0; i <= n; i ++ )
	{
		ll tmp = ksm( 2, n-i, MOD ), tmp2 = 1;

		for( int j = 0; j <= i; j ++, tmp2 = tmp2 * tmp %MOD )
			f[i] = add( f[i], g[i][j] * tmp2 %MOD );
			
		tmp = ksm( 2, n-i, MOD-1 );
		f[i] = f[i] * ksm( 2, tmp, MOD ) %MOD;
	}
}

ll calc_ans() 
{
	ll ret = 0; int cur = 1;
	for( int i = 0; i <= n; i ++, cur = cur == 1 ? MOD-1 : 1 )
		ret = add( ret, C( n, i ) * f[i] %MOD * cur %MOD );
	return ret;
}

int main()
{
	scanf( "%d%d", &n, &MOD );
	
	calc_fac( n );
	calc_g();
	calc_f(); 
	
//	for( int i = 0; i <= n; i ++ )
//		printf( "%lld ", f[i] ); printf( "\n" );
	
	printf( "%d\n", calc_ans() );
	
	return 0;
}

Measured memory_bytes: 195584
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    cout << (N - 1) / 2 << "\n";
    return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


X = int(input())
A = int(input())
B = int(input())

X = X - A
while X >= 0:
    X = X - B

print(X + B)

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

int main(){
  vector<int> data(3);
  cin>>data.at(0);
  cin>>data.at(1);
  cin>>data.at(2);
  
  sort(data.begin(),data.end());
  cout<<data.at(2)-data.at(0)<<endl;
  
    
}
  













Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    while(true){
        int n, m;
        cin >> n >> m;

        if(n == 0 && m == 0){
            break;
        }

        vector<vector<int>> a(n, vector<int>(m));
        rep(i, n){
            rep(j, m){
                char c;
                cin >> c;
                a[i][j] = c - '0';
            }
        }

        if(n < m){
            int ans = 0;
            rep(s, (1 << n)){
                int c = 0;
                vector<int> tmp(m);
                rep(i, n){
                    if((s >> i) % 2 == 1){
                        c++;
                        rep(j, m){
                            tmp[j] ^= a[i][j];
                        }
                    }
                }

                bool ok = true;
                rep(i, m){
                    if(tmp[i] != 0){
                        ok = false;
                    }
                }
                if(ok && ans < c){
                    ans = c;
                }
            }
            cout << ans << endl;

            continue;
        }

        vector<int> x(n);
        rep(i, n){
            rep(j, m){
                x[i] *= 2;
                x[i] += a[i][j];
            }
        }

        vector<int> dp1((1 << m), -1);
        dp1[0] = 0;

        int ans = 0;
        for(int i = 0; i < n; i++){
            vector<int> dp2((1 << m), -1);
            rep(s, (1 << m)){
                if(dp1[s^x[i]] != -1){
                    dp2[s] = max(dp2[s], max(dp1[s], dp1[s^x[i]] + 1));
                }
                dp2[s] = max(dp2[s], dp1[s]);
            }
            dp1 = dp2;
        }
        cout << dp1[0] << endl;
    }

    return 0;
}



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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x : a)
        cin >> x;
    int cnt = 0;
    for(int i = 0; i < n - 1; ++i){
        cnt += (a[i] < a[i + 1]);
    }
    cout << cnt << endl;
}




Measured memory_bytes: 3240
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val A = Array.fill(sc.nextInt)(sc.nextInt)
    val B = Array.fill(A.size * (A.size + 1))(-1L)
    for (i <- Range(0, A.size)) (
      for (j <- Range(i, math.min(i + 8, A.size))) {
        var n = 0
        for (k <- Range(i, j + 1)) {
          n *= 10
          n += A(k)
        }
        B((A.size - j - 1) * A.size + i) = n
      })
    println(B.filter(_ >= 0).toSet.toList.sorted.zipWithIndex.filter(x => x._1 != x._2)(0)._2)
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 71684
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
 
auto solve(string s_)
{
    auto NK = s_.split.map!(to!int)();
    immutable N=NK[0], K=NK[1];
    auto as = readln.split.map!(x=>x.to!int()-1).array();
    auto g = new int[][N];
    foreach(int i,v;as) if(i!=0) g[v]~=i;
    int n=as[0]==0?0:1;
    int dfs(int v, int k)
    {
        int m=K-1;
        foreach(i;g[v]) m=min(m,dfs(i,k+1));
        if(m==0 && v!=0)
        {
            if(as[v]!=0) ++n;
            m=K;
        }
        return m-1;
    }
    dfs(0,0);
    return n;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 12476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(begin(a),end(a));
    cout<<accumulate(begin(a),begin(a)+k,0)<<endl;
    
}

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


int main(void){
  int n,i,a[3005],t;
  ll dp[3005][3005]={},s;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  
  for (i=0;i<n;i++) dp[i][i+1]=a[i]*(n%2*2-1);
  
  for (t=2;t<=n;t++){
    for (i=0;i+t<=n;i++){
      if ((n+t)%2==0) s=max(dp[i+1][i+t]+a[i],dp[i][i+t-1]+a[i+t-1]);
      else s=min(dp[i+1][i+t]-a[i],dp[i][i+t-1]-a[i+t-1]);
      dp[i][i+t]=s;
    }
  }
  
  cout << dp[0][n] << endl;
  
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll a,e,k;

int main(){
	cin >> a;
	rep(i,4)cin >> e;
	cin >> k;
	if(e - a <= k)cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[1000003],c;
int typ,f,loc=1,t,len,st,en;
int res(int loc)
{
	if(loc==1)
		return 2;
	return 1;
}
int main()
{
	scanf("%s",a);
	len=strlen(a);
	for(int i=0;i<len;i++)
		a[i+500000]=a[i];
	st=5e5-1,en=len+5e5;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&typ);
		if(typ==1)
			loc=res(loc);
		else
		{
			scanf("%d",&f);
			cin>>c;
			if(f==loc)
				a[st]=c,st--;
			else
				a[en]=c,en++;
		}
	}
	if(loc==1)
		for(int i=st+1;i<en;i++)
			cout<<a[i];
	else
		for(int i=en-1;i>st;i--)
			cout<<a[i];
	return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    ll m; cin>>m;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    ll l = 1;
    for(int i=0; i<n; i++){
        a[i] /= 2;
        l = (l / __gcd(l, a[i]) * a[i]);
        if(m < l){
            cout << 0 << endl;
            return 0;
        }
    }

    for(int i=0; i<n; i++){
        ll div = l / a[i];
        if(div % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (m / l - m / (2 * l)) << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = a+b==15 ? "+":a*b==15 ? "*":"x";
    System.out.println(s);
  } 
}

Measured memory_bytes: 20692
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[1000001];
char str[1010][1010];
vector<pair<int,int> > pc[5];
int ABS(int a){return max(a,-a);}
int main(){
    int n;
    int a,ans=0;
  cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ans+=a-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,x,t,i;
	scanf("%d %d %d",&n,&x,&t);
	for(i=1;;i++){
		n-=x;
		if(n<=0){
			break;
		}
	}
	printf("%d",i*t);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int s;
    cin >> s;
    int ans = 1;
    while (s > 4 || s == 3) {
        s = (s % 2 == 0 ? s / 2 : s * 3 + 1 );
        ans++;
    }
    cout << ans + 3 << endl;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> a0;
	vector<bool> flag(N,false);
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		if(a==0){
			a0.push_back(b);
		}
		if(b==N-1){
			flag.at(a)=true;
		}
	}

	for(int i=0;i<a0.size();i++){
		if(flag.at(a0.at(i))){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 896
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int count = 0;
    
    for (int i = 0; i < S.length() / 2; i++) {
      int a = S.charAt(i);
      int b = S.charAt(S.length()-i-1);
      if (a != b) {
        count++;
      }
    }
    System.out.print(count);
  }
}

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

#define ll long long 
#define f first
#define s second
#define test ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define a auto
#define st string
#define len length
#define pb push_back
#define v vector<ll>
#define vp vector<ll,ll>
#define bs binary_search
#define lb lower_bound
#define fr(a,b) for(ll i=a;i<b;i++)
#define mp make_pair
#define mod 1000000007

int main()
{
  ll x;
  cin>>x;
  
  if(x>=30)
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
}

Measured memory_bytes: 3564
from operator import mul
from functools import reduce


def cmb(n, r):
    if r > n:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())
R = N-K

for i in range(K):
    a = cmb(K-1, i)
    b = cmb(R+1, i+1)
    print((a*b) % (10**9+7))


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

int A,B;

int main()
{
    cin >> A >> B;

    int max;

    if(A+A-1>B+B-1)
    {
        max=A+A-1;
    }
    else max=B+B-1;
    if(max>A+B)cout << max << endl;
    else cout << A+B << endl;

    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, maxn = -1, wrong = 0, ans = 1;
const ll mod = 998244353;
ll A[100005];
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
	{
		long long x;
		scanf("%lld", &x);
		if (i == 1 && x != 0)
			wrong = 1;
		A[x]++;
		maxn = max(maxn, x);
	}
	for (int i = 1; i <= maxn; i++)
	{
		if (A[i] == 0)
		{
			wrong = 1;
			break;
		}
	}
	if (A[0] != 1)
		wrong = 1;
	if (wrong)
		printf("0\n");
	else
	{
		for (int i = 2; i <= maxn; i++)
		{
			for (int j = 1; j <= A[i]; j++)
			{
				ans = (ans * A[i - 1]) % mod;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

int main(){
    string s, t, u;
    cin >> s >> t >> u;
    cout << (char)(s[0]-'a'+'A') << (char)(t[0]-'a'+'A') << (char)(u[0]-'a'+'A');
    return 0;
}

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

int main() {
        int i, j, m, n, a[100][100], b[100], c[100];
        cin >> n >> m;
        for (i = 0; i < n; i++) {
                for (j = 0; j < m; j++) {
                        cin >> a[i][j];
                }
        }
        for (i = 0; i < m; i++) {
                cin >> b[i];
        }
        for (i = 0; i < n; i++) {
                for (j = 0; j < m; j++) {
                        c[i] += (a[i][j] * b[j]);
                }
        }
        for (i = 0; i < n; i++) cout << c[i] << endl;
        return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <math.h>
int main(){
  int a,b;
  double sum,sum2;
  sum=sum2=0;
  double ans;
  int count=0;
  while(scanf("%d,%d",&a,&b)!=EOF){
    sum+=a*b;
    sum2+=b;
    count++;
  }
  ans=sum2/count+0.5;
  printf("%d\n%d\n",(int)sum,(int)ans);
  return 0;
}

Measured memory_bytes: 592
n = int(input())

numbers = list(map(int, input().split(" ")))

cnt = 0

for i in range(n):
    for j in range(n - 1, i, -1):
        if numbers[j] < numbers[j - 1]:
            tmp = numbers[j]
            numbers[j] = numbers[j - 1]
            numbers[j - 1] = tmp
            cnt += 1

numbers = map(str, numbers)
print(" ".join(numbers))

print(cnt)

Measured memory_bytes: 7644
/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<cstdlib>
#include<stack>
using namespace std;
#define ll long long
#define N 100003
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson (rt<<1)|1, mid+1, r
#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)<(b)?(a):(b))
#define mkp make_pair
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
int n, d[N][2], vis[N];
vector<int>g[N];
void dfs(int cur, int dep, int type){
	int i, now;
	d[cur][type] = dep;
	for(i=0; i<g[cur].size(); i++){
		now = g[cur][i];
		if(vis[now])
			continue;
		vis[now] = 1;
		dfs(now, dep+1, type);
	}
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("fs.in", "r", stdin);
	//freopen("E1.out", "w", stdout);
	int i, j, t, x, y;
	cin>>n;
	for(i=1; i<n; i++){
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x); 
	}
	vis[1] = 1;
	dfs(1, 0, 0);
	memset(vis, 0, sizeof(vis));
	vis[n] = 1;
	dfs(n, 0, 1);
	int b=0;
	for(i=1; i<=n; i++)
		if(d[i][0]<=d[i][1])
			b++;
	//for(i=1; i<=n; i++)cout<<d[i][0]<<' ';cout<<endl;
	//for(i=1; i<=n; i++)cout<<d[i][1]<<' ';cout<<endl;
	if(b>n-b)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
	return 0;
}


Measured memory_bytes: 11648
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
T0 = sum(T)
INF = float("inf")
M = 2 * T0 + 1
l, r = 0, 0
maxv = [INF] * M
for i in range(N):
    l = r
    r += T[i]
    for k in range(2 * l, 2 * r + 1):
        maxv[k] = min(maxv[k], V[i])

maxv[0] = 0
maxv[M - 1] = 0
for i in range(1, M):
    maxv[i] = min(maxv[i], maxv[i - 1] + 0.5)

for i in range(M - 2, -1, -1):
    maxv[i] = min(maxv[i], maxv[i + 1] + 0.5)


ans = 0
for i in range(1, M):
    ans += 0.25 * (maxv[i] + maxv[i - 1])

print(ans)



Measured memory_bytes: 3316
N, M = map(int, input().split())
aset = set([int(input()) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in aset else 1
for i in range(2, N + 1):
    if i not in aset:
        dp[i] = dp[i - 1] + dp[i - 2]
print(dp[-1] % MOD)


Measured memory_bytes: 460020
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int r,g;
  cin>>r>>g;
  cout << 2 * g - r << endl;

  return 0;
}


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

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	string S;
	cin >> S;

	int r = 0, b = 0;
	REP(i, N){
		if(S[i] == 'R') r++;
		else b++;
	}

	if(b < r) cout << "Yes" << endl;
	else cout << "No" << endl;
 
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

typedef pair<int, int> pint;
typedef pair<pint, pint> ppint;

int main(){

    int H, W;
    cin >> H >> W;

    vector<vector<int>> a(H, vector<int>(W, 0));
    int odd = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
            if (a[i][j] & 1) ++odd;
        }
    }

    vector<ppint> res;
    int num = 0;
    int x = 0, y = 0;
    for (int iter = 0; iter < W*H; ++iter) {
        if (a[x][y] & 1) ++ num;

        int nx = x, ny = y;
        if (x % 2 == 0) {
            if (ny == W - 1) ++nx;
            else ++ny;
        } else {
            if (ny == 0) ++nx;
            else --ny;
        }
        if (num & 1) if (num < odd) res.push_back(ppint(pint(x, y), pint(nx, ny)));
        x = nx, y = ny;

    }

    cout << res.size() << endl;
    for (auto p: res) {
        cout << p.first.first + 1 << " " << p.first.second + 1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
    }



}


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

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

    set<int> se; // 3200 以下で登場する色の種類数
    int over_num = 0; // 3200 以上の人数
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a >= 3200) ++over_num;
        else se.insert(a/400);
    }
        
    int Max = (int)se.size() + over_num;
    int Min = 0;
    if (se.size() == 0) Min = 1;
    else Min = (int)se.size();
        
    cout << Min << " " << Max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, M;
  cin >> N >> M;
  long long ans;
  if (N == 1 && M == 1) {
    ans = 1;
  } else if (N == 1) {
    ans = (long long) M - 2;
  } else if (M == 1) {
    ans = (long long) N - 2;
  } else {
    ans = (long long)(N - 2) * (M - 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256