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

int main() {
int x,y;
  cin >> x >> y;
  for (int i=0; i <= x; i++){
    if (i*2+(x-i)*4 == y){
      cout << "Yes" << endl;
      break;
    }
    if (i==x){
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int N = 0, X = 0, T = 0, tot_time = 0, a = 0, b = 0;

    cin >> N >> X >> T;
     a = (N/X);
    b = N%X;
    if(N <= X){
        tot_time = T;
    }
    if(N > X){
      if(b==0){
        tot_time = a*T;
      }
      if(b != 0){
        tot_time = (a+1)*T;
      }
    }
    cout << tot_time << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
using namespace std;
int a[1010];
int main(){
	int n,k,i,ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(i=1;i<=k;i++)ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

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

Measured memory_bytes: 3592
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [map(int,input().split()) for _ in range(Q)]
B, C = [i for i in zip(*BC)]
#print(B,C)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1

ans = sum(A)
for q in range(Q):
  bc = C[q] - B[q]
  ans = ans + bc * dic.get(B[q],0)
  dic[C[q]] = dic.get(C[q],0) + dic.get(B[q],0)
  dic[B[q]] = 0
  print(ans)


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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void init(){
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if (n <= k) cout << s << '\n';
    else{
        cout << s.substr(0, k) + "...\n";
    }
}

int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  ll X;
  cin >> N >> X;
  vector<ll> x(N);
  REP(i, N) cin >> x[i];
  vector<ll> dis(N);
  REP(i, N) dis[i] = abs(x[i] - X);
  sort(dis.begin(), dis.end());
  ll ans = dis[0];
  int i = 1;
  while(ans>1&&i<N){
    while(dis[i]%ans!=0){
      ans--;
    }
    auto Iter = upper_bound(dis.begin(),dis.end(), dis[i]);
    i = Iter-dis.begin();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int data[N];
    bool jugde = 0;
    for (int i = 0; i < N; i++){
        cin >>data[i];
    }
    for (int i = 0; i < N; i++){
        if(data[i] % 2 == 0){
            if(!(data[i] % 3 == 0 || data[i] % 5 == 0)){
                    jugde = 1;
            }
        }
    }
    if(jugde)cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
while 1:
    a = input().split()
    if a[1] == "+":
        print(int(a[0]) + int(a[2]))
    elif a[1] == "-":
        print(int(a[0]) - int(a[2]))
    elif a[1] == "*":
        print(int(a[0]) * int(a[2]))
    elif a[1] == "/":
        print(int(a[0]) // int(a[2]))

    if a[1] == "?":
        break

Measured memory_bytes: 7712
# -*- coding: utf-8 -*-
import numpy as np

def saiki(matrix, fin_l, pos, count):
    for i in range(N):
        move = int(matrix[i, pos])
        if move == 1 and i!=pos and fin_l[i]==0:
            next_pos = i
            fin_l[i] = 1
            if 0 not in fin_l:
                count += 1
                fin_l[i] = 0
                continue
            count = saiki(matrix, fin_l, next_pos, count)
            fin_l[i] = 0

    return count

if __name__ == '__main__':


    N, M = map(int, input().split(' '))
    matrix = np.zeros((N, N))

    for i in range(M):
        a, b = map(int, input().split(' '))
        matrix[a-1, b-1] = 1
        matrix[b-1, a-1] = 1

    for i in range(N):
        matrix[i, i] = 1

    # 訪問済み 配列
    fin_l = [1]
    fin_l.extend([0]*(N-1))
    count = 0
    count = saiki(matrix, fin_l, 0, count)

    print(count)

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

int make_min(int M,int m){
    if(M % m == 0) return m;
    else return make_min(m, M % m);
}

int main(){
  int N;
  cin >> N;
  int A[N];
  int dp[N+1];
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  dp[1] = A[0];
  for(int i = 1; i < N; i++){
    dp[i+1] = make_min(dp[i], A[i]);
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k,n,m;
	scanf("%d%d%d",&k,&n,&m);
	int x=k-n;
	if(x<0)
	x=-x;
	int y=k-m;
	if(y<0)
	y=-y;
	if(x<y)
	printf("A\n");
	else
	printf("B\n");
	return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

int main() {
	int w, h, c;
	cin >> w >> h >> c;

	int tmp = GCD(w, h);

	cout << (w * h) / (tmp * tmp) * c << endl;
}


Measured memory_bytes: 3104
#include<iostream>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a == 1){
		a += 13;
	}
	if(b == 1){
		b += 13;
	}
	if(a == b){
		cout << "Draw" << endl;
	}else if(a > b){
		cout << "Alice" << endl;
	}else{
		cout << "Bob" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n;
		n = sc.nextInt();
		
		int a[][] = new int[2][n];
		
		for (int i = 0; i < n; i++) {
			a[0][i] = sc.nextInt();
			a[1][i] = i + 1;
		}
		
		quickSort(a, 0, n - 1);
		
		for (int i = 0; i < n; i++) {
			System.out.print( a[1][i] + " " );
		}
		
		return;
	}
	
	public static void quickSort(int array[][], int left, int right) {
	
		
		if ( left > right ) {
			return;
		}
		
		
		int pivotValue = array[0][(left + right) / 2];
		
		int i = left;
		int j = right;
		
		while ( i <= j ) {
			while (array[0][i] < pivotValue) {
				i++;
			}
			
			while (array[0][j] > pivotValue) {
				j--;
			}
			
			if ( i <= j ) {
				quickSortSwap(array, i, j);
				
				i++;
				j--;
			}
		}
		
		quickSort(array, left, j);
		quickSort(array, i, right);
	}
		
		
	public static void quickSortSwap(int array[][], int i, int j) {
		int temp0 = array[0][i];
		int temp1 = array[1][i];
		
		array[0][i] = array[0][j];
		array[1][i] = array[1][j];
		
		array[0][j] = temp0;
		array[1][j] = temp1;
		
		return;
	}

}


Measured memory_bytes: 62216
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int inf = (1 << 30) - 1;

int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;

  cout << fixed << setprecision(10) << W * H / 2.0 << " ";
  cout << (2*x == W && 2*y == H)<< endl;
  return 0;
}

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

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(gcd(a, b));
  }
  public static int gcd(int a, int b) {
    int smaller = Math.min(a, b);
    int bigger = Math.max(a, b);
    int surplus = bigger % smaller;
    if (surplus == 0) return smaller;
    surplus = gcd(smaller, surplus);
    return surplus;
  }
}


Measured memory_bytes: 26280
s = input()
chars = [0, 0, 0]

for i in range(len(s)):
    if s[i] == "a":
        chars[0] += 1
    elif s[i] == "b":
        chars[1] += 1
    else:
        chars[2] += 1

chars = sorted(chars)

if chars[0] == chars[1]:
    if chars[1] == chars[2]:
        print("YES")
    elif chars[2] == chars[1] + 1:
        print("YES")
    else:
        print("NO")
elif (chars[1] == chars[2]) and (chars[0] == chars[1] - 1):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9224
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int s;
    cin>>s;
    set<int>se;
    se.insert(s);
    int cnt=1;
    while(1){
        cnt++;
        if(s%2!=0)s=3*s+1;
        else s/=2;
        if(se.find(s)!=se.end())break;
        se.insert(s);
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int,int>> V;
    int A[200100],B[200100];
    REP(i,N){
        cin >> A[i] >> B[i];
        V.pb({B[i],A[i]});
    }
    sort ALL(V);
    ll cnt = 0;
    REP(i,N){
        cnt += V[i].second;
        if(cnt > V[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1100000;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int x, y;
  cin >> x >> y;
  int tmp = min(x, y) / 3;
  int c = -1;
  rep(i, tmp + 1) {
    int a = x - 3 * i;
    int b = y - 3 * i;
    if (a == 2 * b || b == 2 * a) {
      c = i;
      break;
    }
  }
  if (c == -1) {
    cout << 0 << endl;
  } else {
    int d = min(x - 3 * c, y - 3 * c);
    COMinit();

    cout << COM(2 * c + d, c) << endl;
  }

  return 0;
}

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

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

    int res = 1;
    for (int i=1; i<n; i++) {
        bool flag = true;
        for (int j=0; j<i; j++) {
            if (h[i] < h[j]) flag = false;
        }
        if (flag == true) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n;
  cin >> n;
  vector<ll> conv(n + 1);
  conv[0] = 0;
  for (int i = 1; i <= n; i++) {
    ll a;
    cin >> a;
    conv[i] = conv[i - 1] + a;
  }
  ll ans = INF;
  for (int i = 1; i <= n - 1; i++) {
    chmin(ans, abs(conv[i] - conv[n] + conv[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for(auto i : s){
        if(i == '2') ans++;
    }
    cout << ans << endl;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    if(a>=10||b>=10){cout << -1 << endl;return 0;}

    cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let (H, W) = get!(i64, i64);
    let a = get!(String; H);

    let x = (0..(W + 2)).map(|_| "#")
        .collect::<Vec<_>>()
        .join("");
    let ans = [
        &x[..],
        &a.into_iter().map(|b| format!("#{}#", b))
            .collect::<Vec<_>>()
            .join("\n"),
        &x[..]
    ].join("\n");
    // 出力
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;

  string rec;
  REP(i, s.size()){
    if(s[i] != 'A') rec += s[i];
  }
  if(rec != "KIHBR"){
    cout << "NO" << endl;
    return 0;
  }
  ll p = 0, q = 0;
  REP(i, s.size() - 2){
    if(s.substr(i, 3) == "KIH") p++;
  }
  REP(i, s.size() - 1){
    if(s.substr(i, 2) == "AA") q++;
  }
  if(p == 0 || q){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  return 0;
}


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

#define N 200000
#define MAX 1000000001

long int cnt;
void Merge( int[], int, int, int );
void MergeSort( int[], int, int );

int L[N/2+2], R[N/2+2];

int main( void ){
	int i, L;
	int A[N];
	
	scanf("%d", &L );
	for( i = 0; i < L; i++ ){
		scanf("%d", &A[i] );
	}
	
	MergeSort( A, 0, L );
	
	printf("%ld\n", cnt );
	
	return 0;
}

void Merge( int a[], int left, int mid, int right ){
	int i, j, k;
	int n_1 = mid-left;
	int n_2 = right-mid;
	
	for( i = 0; i < n_1; i++ ){
		L[i] = a[left+i];
	}
	for( i = 0; i < n_2; i++ ){
		R[i] = a[mid+i];
	}
	
	L[n_1] = MAX;
	R[n_2] = MAX;
	
	i = 0; j = 0;
	for( k = left; k < right; k++ ){
		if( L[i] <= R[j] ){
			a[k] = L[i];
			i++;
		}
		else{
			a[k] = R[j];
			j++;
			cnt += n_1 - i;
		}
	}
}

void MergeSort( int a[], int left, int right ){
	int mid;
	if( left+1 < right ){
		mid = (left+right)/2;
		MergeSort( a, left, mid );
		MergeSort( a, mid, right );
		Merge( a, left, mid, right );
	}
}


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

int main() {
	int N; cin >> N;
	int a[100010];
	for(int i=0; i<N; ++i) cin >> a[i];
	bool existodd=false;
	for(int i=0; i<N; ++i){
	    if(a[i]%2){
	        existodd=true;
	        break;}}
	if(existodd) cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
  int n;
  int h[100005];
  int dp[100005];
  cin >> n;
  for(int i=0; i<n; ++i) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for(int i=2; i<n; ++i) dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int D = sc.nextInt();
		final int G = sc.nextInt();
		
		int p[] = new int[D];
		int c[] = new int[D];
		for(int i = 0; i < D; i++) {
			p[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		int answer = Integer.MAX_VALUE;
		boolean flag[] = new boolean[D];
		for(int i = 0; i < Math.pow(2, D); i++) {
			Arrays.fill(flag, true);
			int score = 0;
			int cnt = 0;
			for(int j = 0; j < D; j++) {
				if((1 & i >> j) == 1) {
					score += p[j] * (j + 1) * 100 + c[j];
					cnt += p[j];
					flag[j] = false;
				}
			}
			while(score < G) {
				boolean end_flag = false;
				if(score >= G) {
					break;
				}
				for(int k = D - 1; k >= 0; k--) {
					if(flag[k]) {
						int n = 0;
						while(n != p[k] && score < G) {
							score += (k + 1) * 100;
							cnt++;
							n++;
							if(n == p[k]) {
								score += c[k];
								flag[k] = false;
							}
						}
					}
					if(score >= G) break;
				}
			}
			answer = Math.min(answer, cnt);
		}
		System.out.println(answer);
	}
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define PI 3.14159265358979323846

ll N,L;
ll T[3030];
ll i, j, k;
double ansx, ansy;



int main(){
    scanf("%lld%lld", &N,&L);
    fornum(i,0,N){
        scanf("%lld", &T[i]);
    }
    fornum(i,0,N){
        fornum(j,i+1,N){
            ansx += cos(PI * (double)(T[i] + T[j]) / L) * (N - 1 - j + i);
            ansy += sin(PI * (double)(T[i] + T[j]) / L) * (N - 1 - j + i);
            ansx += cos(PI * (double)(T[i] + T[j]) / L + PI) * (j - i - 1);
            ansy += sin(PI * (double)(T[i] + T[j]) / L + PI) * (j - i - 1);
        }
    }
    ansx /= N * (N - 1) * (N - 2) / 6;
    ansy /= N * (N - 1) * (N - 2) / 6;
    printf("%.12lf %.12lf", ansx, ansy);

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{

int a,b; 
cin >> a >> b ;

if (a < b){
    cout << "a < b" << endl;
}
else if (a==b) {
    cout << "a == b" << endl;
}
else {
    cout <<"a > b" << endl;
}

return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int x;
  cin >> x;
  if (x <= 599)
    cout << "8" << endl;
  else if (600 <= x && x <= 799)
    cout << "7" << endl;
  else if (800 <= x && x <= 999)
    cout << "6" << endl;
  else if (1000 <= x && x <= 1199)
    cout << "5" << endl;
  else if (1200 <= x && x <= 1399)
    cout << "4" << endl;
  else if (1400 <= x && x <= 1599)
    cout << "3" << endl;
  else if (1600 <= x && x <= 1799)
    cout << "2" << endl;
  else if (1800 <= x && x <= 1999)
    cout << "1" << endl;
}


Measured memory_bytes: 3600
// Problem : A - A?C
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_a
// 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 int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		string s;
		cin>>s;
		if(s=="ABC")
		cout<<"ARC";
		else
		cout<<"ABC";    	
    }
    return 0;
}



Measured memory_bytes: 3572
from sys import stdin,stdout                           #
import math                                            #
import heapq                                           #
                                                       #
t = 1                                                  #
def aint():                                            #
	return int(input().strip())                        #
def lint():                                            #
	return list(map(int,input().split()))              #
def fint():                                            #
	return list(map(int,stdin.readline().split()))     #
                                                       #	
########################################################

def main():
	l,r,d=lint()
	print(r//d-(l-1)//d)
	#code here
	return

#t=int(input())

########################################################
for i in range(t):                                     #
	#print("Case #"+str(i+1)+":",end=" ")		       #
	main()                                             #

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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 1005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
int n,m;
const ll INF = 1LL << 60;
ll dp[MAX][MAX];
char grid[MAX][MAX];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>grid[i][j];
		}
	}
	dp[1][1]=1;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(grid[i][j]!='#')
			{
				
					if(grid[i-1][j]!='#')
						dp[i][j]+=(dp[i-1][j]%M);
					if(grid[i][j-1]!='#')
						dp[i][j]+=(dp[i][j-1]%M);
							
			}
		}
	}
	cout<<(dp[h][w]%M)<<endl;
	return 0;	
}


Measured memory_bytes: 9088
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
m=10**9+7
ans=pow(10,n)-pow(9,n)*2+pow(8,n)
print(ans%m)

Measured memory_bytes: 86328
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
const ll mod2= 998244353;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll dp[3300][3300];
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    rep(i,a,c+1){
        rep(j,b,d+1){
            if(i==a&&j==b)dp[i][j]=1;
            else if(i==a)dp[i][j]=(dp[i][j]%mod2+dp[i][j-1]*i%mod2)%mod2;
            else if(j==b)dp[i][j]=(dp[i][j]%mod2+dp[i-1][j]*j%mod2)%mod2;
            else{
                dp[i][j]=(dp[i][j-1]*i%mod2+dp[i-1][j]*j%mod2+mod2-(i-1)*(j-1)*dp[i-1][j-1]%mod2)%mod2;
            }
        }
    }
    cout<<dp[c][d];
}



Measured memory_bytes: 80916
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())

    for i in range(100):
        for j in range(100):
            if i * 4 + j * 7 == N:
                print(Yes)
                return 

    print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int x1, y1, x2, y2, x3, y3, x4, y4;

	std::cin >> x1 >> y1 >> x2 >> y2;

	y4 = (x2 - x1) + y1;
	x4 = (y1 - y2) + x1;
	y3 = (y2 - y1) + y4;
	x3 = (x2 - x1) + x4;

	std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int x;


vector<bool> primeTable(int n){
    vector<bool> res(n+1, true);
    if(n >= 0) res[0] = false;
    if(n >= 1) res[1] = false;
    for(int i = 2;i*i <= n;i++){
        if(!res[i]) continue;
        for(int j = i+i;j <= n;j += i) res[j] = false;
    }
    return res;
}


vector<int> enumPrime(int n){
    vector<int> res;
    auto prime = primeTable(n);
    for(int i = 0;i <= n;i++) if(prime[i]) res.push_back(i);
    return res;
}


signed main(){
    cin >> x;

    auto p = enumPrime(1e6);

    for(int a : p) if(x <= a){ cout << a << endl; return 0; }

    return 0;
}

Measured memory_bytes: 1656
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a == b && b == c)
		printf("1\n");
	else if(a != b && b != c && a != c)
		printf("3\n");
	else
		printf("2\n");
	return 0;
}


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


int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l=0,m,n,p,x,y,sum=0,cnt=0,diff;
    cin>>n;
string s;
    cin>>s;
    string s1="red";
    if(n<3200)
        cout<<s1<<endl;
    else
        cout<<s<<endl;

}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    x: usize,
  }
  if x == 1 || x == 2 * n - 1 {
    println!("No");
    return;
  }
  println!("Yes");
  if n == 2 {
    println!("1\n2\n3");
    return;
  }
  let mut ans = vec![0; 2 * n - 1];
  if x == 2 {
    ans[n-2] = x + 1;
    ans[n-1] = x;
    ans[n] = x - 1;
    ans[n+1] = x + 2;
    let mut v = 1;
    for i in 0 .. n - 2 {
      if v == x - 1 {
        v += 4;
      }
      ans[i] = v;
      v += 1;
    }
    for i in n + 2 .. 2 * n - 1 {
      if v == x - 1 {
        v += 4;
      }
      ans[i] = v;
      v += 1;
    }
  } else {
    ans[n-2] = x - 1;
    ans[n-1] = x;
    ans[n] = x + 1;
    ans[n+1] = x - 2;
    let mut v = 1;
    for i in 0 .. n - 2 {
      if v == x - 2 {
        v += 4;
      }
      ans[i] = v;
      v += 1;
    }
    for i in n + 2 .. 2 * n - 1 {
      if v == x - 2 {
        v += 4;
      }
      ans[i] = v;
      v += 1;
    }
  }

  for &a in ans.iter() {
    println!("{}", a);
  }
}


Measured memory_bytes: 7676
def main():
    n, m = map(int, input().split())
    if n > m:
        n, m = m, n
    if m == 1:
        print(0)
    elif n == 1:
        print(m*(m-1)//2)
    else:
        print(n*(n-1)//2+m*(m-1)//2)


main()

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


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

    vector<ll> A(N+1, 0);
    for(int i = 1; i <= K; i++){
        ll d;
        cin >> d;
        for(int j = 1; j <= d; j++){
            ll a;
            cin >> a;
            A[a]++;
        }
    }

    ll ans = 0;
    for(int i = 1; i <= N; i++){
        if(A[i] == 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e6+2;
const ll mod = 1e9+7;



int main(){ 
	speedhack()
	string s; cin >> s;
	vector<int> v(s.size()+2,0);
	int it = 0;
	int rcnt = 0;
	int lcnt = 0;
	int pos = 0;
	while(it < s.size()){
		if(s[it] == 'R'){
			rcnt++;
			it++;
		}else{
			pos = it;
			while(s[it] == 'L'){
				lcnt++;
				it++;
				if(it == s.size()){
					break;
				}
			}
		v[pos] = (rcnt+lcnt)/2;
		v[pos-1] = v[pos];
		if((rcnt+lcnt)%2 == 1){
			if(lcnt%2 == 1)
			v[pos]++;
			else if(rcnt%2 == 1)
			v[pos-1]++;
		}
		rcnt = lcnt = 0;
		}
	}
	for(int i = 0; i < s.size(); i++){
		cout << v[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int p=a;p<b;p++)
#define modulo 1000000007

int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int taka,akoi;
   taka=c/b;
   if(c%b!=0)
   {
       taka++;
   }
   akoi=a/d;
   if(a%d!=0)
   {
       akoi++;
   }
   //cout<<taka<<" "<<akoi<<endl;
   if(taka>akoi)
   {
       cout<<"No\n";
   }
   else{
    cout<<"Yes\n";
   }


    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

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

    int ans = 0;

    for (int i = 0; i < 1000; i++) {
        string t;
        if (i < 10) t = "00" + to_string(i);
        else if (i < 100) t = "0" + to_string(i);
        else t = to_string(i);
        int count = 0;
        int j = 0;
        while (j < N && count < 3) {
            if (S[j] == t[count]) count++;
            j++;
        }
        if (count >= 3) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "m_solutions2020_c.cpp"

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

  int n, k;
  cin >> n >> k;
  vi a(n);
  cin >> a;

  FOR(i, k, n) { say(a[i] > a[i - k]); }
}


Measured memory_bytes: 3984
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;


int main() {
  int N;

  scanf("%d", &N);

  vector<int> a(N);
  for(int i = 0; i < N; i++){
    scanf("%d", &a[i]);
  }

  int min = 1000000000, max = 1;
  for(int i = 0; i < N; i++){
    if(a[i] > max){
      max = a[i];
    }

    if(a[i] < min){
      min = a[i];
    }
  }

  printf("%d", abs(max - min));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin >> arr[i];
  int c=0;
  int i=0;
  while(i<n){
    if(i==(n-1)){
      if(arr[i]==(i+1)){
        int temp = arr[i-1];
        arr[i-1]=arr[i];
        arr[i]=temp;
        c++;
        i++;
      }
      else{
        i++;
      }
    }
    else{
      if(arr[i]==(i+1)){
        int temp = arr[i+1];
        arr[i+1]=arr[i];
        arr[i]=temp;
        c++;
        i++;
      }
      else{
        i++;
      }
    }
    // for(int i=0;i<n;i++)
    //   cout << arr[i] << ' ';
    // cout << endl;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 640
<?php
fscanf(STDIN, '%d',$s);
$a[0] = $s;
for ($i=0; $i <1000000 ; $i++) {
  // code...
  if($a[$i]%2==0){
    $a[$i+1] = $a[$i]/2;
  }else {
    $a[$i+1] = $a[$i]*3+1;
  }
  for ($m=0; $m <$i ; $m++) {
    // code...
    if($a[$i+1]==$a[$m]){
      echo $i+2;
      break 2;
    }

  }
}

 ?>


Measured memory_bytes: 3576
#include<stdio.h>
#define LIM 100

void *bubs(int *,int *);

int main() {

  int N,num[LIM];
  int i,j;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&num[i]);

  j=N;
  bubs(num,&N);
  
  for(i=0;i<j;i++) {
    if(i>0) printf(" ");
    printf("%d",num[i]);
  }

  printf("\n%d\n",N);

  return 0;

}

void *bubs(int *num,int *a) {

  int N=*a;
  int flag=1;
  int i,j;
  *a=0;

  while(flag==1) {

    flag=0;

    for(i=N-1;i>0;i--) {
      if(num[i] < num[i-1]) {
	j = num[i];
	num[i] = num[i-1];
	num[i-1] = j;
	flag=1;
	*a=*a+1;
      }
    }

  }
}


Measured memory_bytes: 2048
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

int main()
{ long long int a;
  scanf("%lld",&a);
  if(a%1000==0)
  {
      printf("0");
  }
  else
  {
      long long int b,c,d,result;
      b=a/1000;
      c=b*1000;
      d=a-c;
      result=1000-d;
      printf("%lld",result);
      
  }


    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

double calc(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    double X[N], Y[N]; rep(i, N) cin >> X[i] >> Y[i];
    double dist[N][N]; rep(i, N) rep(j, N) dist[i][j] = calc(X[i], Y[i], X[j], Y[j]);
    //ans = (美しさの総和)/n^m
    vector<int> lst; rep(i, N) lst.push_back(i);
    double fac[N+1]; fac[0] = 1;
    for(int i = 1; i <= N; i++) fac[i] = i*fac[i-1];
    double acc = 0.0;
    do{
        rep(i, lst.size()-1) acc += dist[lst[i]][lst[i+1]];
    }while(next_permutation(lst.begin(), lst.end()));
    printf("%.10f\n", acc/fac[N]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int a,b,q;
  scanf("%lld %lld %lld",&a,&b,&q);
  vector<long long int> s(a+2),t(b+2),x(q);
  for(int i=1;i<=a;i++)
    scanf("%lld",&s[i]);
  for(int i=1;i<=b;i++)
    scanf("%lld",&t[i]);
  for(int i=0;i<q;i++)
    scanf("%lld",&x[i]);
  s[0]=-2e10;
  s[a+1]=2e10;
  t[0]=-2e10;
  t[b+1]=2e10;
  long long int ans;
  
  for(int i=0;i<q;i++){
    int sl=lower_bound(s.begin(),s.end(),x[i])-s.begin();
    int tl=lower_bound(t.begin(),t.end(),x[i])-t.begin();
    
    long long int west,east,uwest,ueast;
    west=x[i]-min(s[sl-1],t[tl-1]);
    east=max(s[sl],t[tl])-x[i];
    uwest=min( 2*s[sl]-x[i]-t[tl-1] , 2*t[tl]-x[i]-s[sl-1]);
    ueast=min( x[i]-2*s[sl-1]+t[tl] , x[i]-2*t[tl-1]+s[sl]);
    
    ans=min( min(west,east) , min(uwest,ueast) );
 
    
    printf("%lld\n",ans);;
  }
 
}

Measured memory_bytes: 3712
s = [input() for i in range(2)]
l0 = int(s[0])
l1 = list(map(int, s[1].split()))
t = [input() for i in range(l0)]
for i in range(l0):
    l2 = list(map(int, t[i].split()))
    print(l2.index(max(l2))+1)


Measured memory_bytes: 9204
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

ll calc(ll a) {
    ll x = (a + 1) / 2;
    if (a % 2 == 0) {
        return a ^ (x % 2);
    } else {
        return x % 2;
    }
}

int main(void) {
    ll A, B;
    cin >> A >> B;

    ll a = calc(A - 1);
    ll b = calc(B);
    cout << (b ^ a) << endl;

    return 0;
}


Measured memory_bytes: 3564
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   string n;
 
   cin >> n;
   int i = n.find("7");
   if(i!=-1){
   cout << "Yes" <<endl;
 
   }else{
     cout << "No" <<endl;
   }
  
  return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	
	public static Integer encryptStep = null;
	public static String encryptedMessage = "";
	public static String decryptedMessage = "";
	
	public static void main(String args[]) throws IOException{
		BufferedReader inMsg = new BufferedReader(new InputStreamReader(System.in));
		
		while ((encryptedMessage = inMsg.readLine()) != null) {
			decryptedMessage = "";
			encryptStep = null;
			
			findEncryptStep(encryptedMessage);
			
			if(encryptStep != null){
				convertMsg();
				System.out.println(decryptedMessage);
			} 
		}

		return;
	}
	
	/**
	 * ?????????????????¨??????????????????????????¢??????
	 * @param msg
	 */
	public static void findEncryptStep(String msg){
		String[] words;
		String newString = msg;
		
		if(newString.contains(".")){
			newString = msg.replace(".", "");
		}
		
		words = newString.split(" ");
		
        for (String word : words) {
        	checkWords(word);
        	if(encryptStep!=null){
	    		break;
	    	}
        }
		
	}
	
	/**
	 *  ???????????????????????????
	 */
	public static void convertMsg(){
		
		int len = encryptedMessage.length();
		
		for(int i = 0; i<len ; i++){
			decryptedMessage = decryptedMessage + shiftChars(encryptedMessage.charAt(i), encryptStep);
		}
	}
	
	/**
	 * ???????????????????????§??????????????????
	 * @param chr
	 * @return
	 */
	public static char shiftChars(char chr, int step){
		
		int shifted = 0;
		
		if(chr == ' ' || chr == '.'){
			return chr;
		}

		if(chr >= 'a' && chr <= 'z'){
			shifted = chr - step;
			
			if(shifted > 'z'){
				shifted = ('a' - 1)  + (shifted - 'z');
			} else if(shifted < 'a'){
				shifted  = ('z' + 1) - ('a' - shifted);
			}
		}
		
		return (char)shifted;
	}
	
	/**
	 * ?????????THE???THIS???THAT?????????????????§???????????¨????¢??????????
	 * ?????????????????¨???????????????????????????????????????
	 * @param words
	 */
	public static void checkWords(String words){
		
		int wordLen = words.length();
		String tempWord = "";
		
    	if(wordLen == 3 || wordLen == 4){
    		for(int matchShift = 0; matchShift < 27; matchShift ++ ){
    			tempWord = "";
    			
    			for(int j = 0; j < wordLen; j++){
    				tempWord = tempWord + shiftChars(words.charAt(j), matchShift);
    			}
    			
    			if(!tempWord.isEmpty()){
    				if("the".equals(tempWord) || "this".equals(tempWord) || "that".equals(tempWord)){
    					encryptStep = matchShift;
    					break;
    				}
    			}
    		}
    	}
    	
	}

}

Measured memory_bytes: 24436