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

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long V, long long B, long long W, long long T)
{
    if (V <= W || abs(B - A) > abs(V - W) * T)
        cout << NO << endl;
    else
        cout << YES << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long V;
    scanf("%lld", &V);
    long long B;
    scanf("%lld", &B);
    long long W;
    scanf("%lld", &W);
    long long T;
    scanf("%lld", &T);
    solve(A, V, B, W, T);
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for(int i = 0; i < N; i++) {cin >> A.at(i);}
  for(int i = 0; i < N; i++) {cin >> B.at(i);}
  for(int i = 0; i < N - 1; i++) {cin >> C.at(i);}
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans += B.at(A.at(i) - 1);
    if(i != 0 && A.at(i) == A.at(i - 1) + 1) {ans += C.at(A.at(i - 1) - 1);}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int n;
  cin >> S;
  if(S=="SUN"){
      n=7;
  }else if(S=="MON"){
      n=6;
  }else if(S=="TUE"){
      n=5;
  }else if(S=="WED"){
      n=4;
  }else if(S=="THU"){
      n=3;
  }else if(S=="FRI"){
      n=2;
  }else if(S=="SAT"){
      n=1;
  }
  cout << n;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)	cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++)	sum+=a[i];
  cout<<sum<<"\n";
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 1e5+5;
LL N,C;

LL dis[maxn];
LL calo[maxn];
LL rest[maxn];
LL rest2[maxn];

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

    dis[0] = 0;
    calo[0] = 0;

    _rep(i,1,N){
        LL x,c;
        scanf("%lld %lld",&x,&c);
        dis[i] = x;
        calo[i] = c;

        rest[i] = rest[i-1];
        rest[i] += (c-(x-dis[i-1]));
    }

    rest2[0] = 0;
    dis[N+1] = C;
    calo[N+1] = 0;

    _rep(i,1,N){
        rest2[i] = rest2[i-1];
        rest2[i] += calo[N-i+1]-( (C-dis[N-i+1])- (C-dis[N-i+2]));
    }


    LL ans = 0;

    LL rev = 0;
    LL vsum = 0;
    _dec(i,0,N+1){
        LL R = rest[i];
        //cout <<"R:"<< R << endl;
        ans = max(ans,R);
        vsum += calo[i+1];
        LL val = -(C-dis[i+1]) + vsum;
        rev = max(rev,val);
        //cout <<"res:"<<R+rev-dis[i]<<endl;
        ans = max(ans,R+rev-dis[i]);

    }

    vsum = 0;
    rev = 0;
    _dec(i,0,N+1){
        LL L = rest2[i];
        //cout << "L:"<<L<<endl;
        ans = max(ans,L);
        LL val;
        vsum += calo[N-i];
        val = vsum - dis[N-i];
        rev = max(rev,val);
        //cout <<"res:"<<L + rev - (C-dis[N-i+1])<<endl;
        ans = max(ans,L + rev - (C-dis[N-i+1]));

    }

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

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

using namespace std;

int n;
double dp[310][310][310];

double dfs(int x3, int x2, int x1) {
    if(dp[x3][x2][x1] > 0)
        return dp[x3][x2][x1];
    else {
        double sum = (double)(x3 + x2 + x1);
        double ret = n / sum;
        if(x3 > 0) ret += (double)x3 * dfs(x3 - 1, x2 + 1, x1) / sum;
        if(x2 > 0) ret += (double)x2 * dfs(x3, x2 - 1, x1 + 1) / sum;
        if(x1 > 0) ret += (double)x1 * dfs(x3, x2, x1 - 1) / sum;
        return dp[x3][x2][x1] = ret;
    }
}

int main() {
    cin >> n;
    int a[n], x1 = 0, x2 = 0, x3 = 0, x;
    for(size_t i = 0; i < n; i++) {
        cin >> x;
        if(x == 3) x3++;
        if(x == 2) x2++;
        if(x == 1) x1++;
    }
    dp[0][0][0] = 1.0;
    int i, j, k, h;
    //cout << dfs(x3, x2, x1) << endl;
    printf("%.12f\n", dfs(x3, x2, x1)-1.0);
    return 0;
}

Measured memory_bytes: 225536
#include <iostream>
#include <stdio.h>
#include <stack>
#include <string>
using namespace std;
 
int main() {
    while (true) {
        char s[101];
        int c;
        int j = 0;
        while (true) {
            c = getchar();
            if (c == '\n') break;
            s[j++] = c;
        }
        s[j] = '\0';
        if (s[0] == '.') return 0;
         
        stack<char> stk;
        for (int i = 0; s[i] != '\0'; i++) {
            if (s[i] == '(') stk.push('(');
            else if (s[i] == '[') stk.push('[');
            else if (s[i] == ')') {
                if (!stk.empty()) {
                    if (stk.top() == '(') stk.pop();
                    else stk.push(')');
                } else stk.push(')');
            } else if (s[i] == ']') {
                if (!stk.empty()) {
                    if (stk.top() == '[') stk.pop();
                    else stk.push(']');
                } else stk.push(']');
            }
        }
         
        if (stk.empty()) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <string>
#include <map>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)
#define pb push_back
#define x first
#define y second

using namespace std;

const int N = 200010;

typedef long long LL;

char S[N];
int n, cnt[30];

int main(){
	scanf("%s", S + 1);
	n = strlen(S + 1);

	LL ans = 1LL * n * (n - 1) / 2 + 1;

	For(i, 1, n){
		ans -= cnt[S[i] - 'a'];
		cnt[S[i] - 'a']++;
	}

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

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N, D;

    cin >> N >> D;

    vector<vector<double>> X(N);

    int tmp_X;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> tmp_X;
            X[i].push_back(tmp_X);
        }
    }

    int ans = 0;
    double sum = 0;
    for(int i = 0; i < (N-1); i++){
        for(int j = i+1; j < N; j++){
            sum = 0.0;
            for(int d = 0; d < D; d++){
                sum += pow(abs(X[i][d] - X[j][d]), 2);
            }
            if(abs(sqrt(sum) - round(sqrt(sum))) < 1e-5){
                //cout << sqrt(sum) << round(sqrt(sum)) << endl;
                ans++;
            }
        }
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_5_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();

            long comparisonTimes = 0;
            long swaptimes = 0;
            MergeSort(line, 0, n - 1, ref comparisonTimes, ref swaptimes);

            Console.WriteLine(swaptimes);
        }


        /// </summary>
        /// マージソート
        /// </summary>
        /// <param name="array">対象の配列</param>
        /// <param name="left">開始インデックス</param>
        /// <param name="right">終了インデックス</param>
        /// <param name="comparisonTimes">out 比較回数</param>
        /// <param name="swaptimes">out 反転数</param>
        public static void MergeSort(int[] array, int left, int right, ref long comparisonTimes, ref long swaptimes)
        {

            if (left == right) return;
            int mid = (left + right) / 2;

            MergeSort(array, left, mid, ref comparisonTimes, ref swaptimes);
            MergeSort(array, mid + 1, right, ref comparisonTimes, ref swaptimes);
            Merge(array, left, mid, right, ref comparisonTimes, ref swaptimes);

            return;
        }

        private static void Merge(int[] array, int left, int mid, int right, ref long comparisonTimes, ref long swaptimes)
        {

            int n1 = mid - left + 1;
            int n2 = right - (mid + 1) + 1;
            int[] L = new int[n1 + 1];
            int[] R = new int[n2 + 1];
            for (int a = 0 ; a < n1 ; a++) { L[a] = array[left + a]; }
            for (int a = 0 ; a < n2 ; a++) { R[a] = array[(mid + 1) + a]; }
            L[n1] = int.MaxValue;
            R[n2] = int.MaxValue;

            int i = 0, j = 0;
            for (int k = left ; k <= right ; k++)
            {
                if (L[i] <= R[j])
                {
                    array[k] = L[i];
                    i++;
                }
                else
                {
                    array[k] = R[j];
                    j++;
                    swaptimes += (n1 - i);
                }
                comparisonTimes++;
            }

            return;
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 43140
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=2e5+10;
vector<int>G[N];
int n,a[N];
int X[N],len,ans[N];
void dfs(int u,int fa)
{
    for(int v:G[u]){
        if(v==fa) continue;
        int tlen=len,flag=0,now=0;
        if(X[len]<a[v])X[++len]=a[v];
        else{
            int l=1,r=len;
            while(l<=r){
                int mid=l+r>>1;
                if  (X[mid]>=a[v]) r=mid-1,now=mid;
                else l=mid+1;
            }
            flag=X[now];
            X[now]=a[v];
        }
        ans[v]=len;

        dfs(v,u);
        len=tlen;
        if(flag) X[now]=flag;
    }
}
void solve()
{
    scanf("%d",&n);
    rep(i,1,n) cin>>a[i];
    rep(i,2,n){
        int u,v;cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ans[1]=1;
    X[len=1]=a[1];
    dfs(1,-1);
    rep(i,1,n) printf("%d\n",ans[i]);
}
int main()
{
	solve();
}


Measured memory_bytes: 30580
package main

import (
  "fmt"
  "sort"
)

func sumInt(a ...int) int {s := 0; for _, v := range a {s += v}; return s}
func reverseSortIntSlice(a []int) {sort.Sort(sort.Reverse(sort.IntSlice(a)))}

func main() {
  var n, k int 
  fmt.Scan(&n, &k)
  l := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&l[i])
  }
  reverseSortIntSlice(l)
  fmt.Println(sumInt(l[:k]...))
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a,const void* b)
{return (*(int*)a-*(int*)b);}
int main()
{
	int i,a[10];
	for(i=0;i<10;i++) scanf("%d\n",&a[i]);
	qsort(a,10,sizeof(int),cmp);
	for(i=1;i<=3;i++) printf("%d\n",a[10-i]);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int to_int(char ch)
{
    int res;
    if(ch == 'A') res = 0;
    if(ch == 'B') res = 1;
    if(ch == 'C') res = 2;
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    string t = "#??";
    while(cin >> s)
    {
        int a = to_int(s[0]);
        int b = to_int(s[2]);
        swap(t[a], t[b]);
    }
    if(t[0] == '#') cout << 'A' << "\n";
    else if(t[1] == '#') cout << 'B' << "\n";
    else cout << 'C' << "\n";
    return 0;
}




Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_set>
#include <iterator>
using namespace std;

int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    unordered_set<int> sqmod;
    for(int i = 1; i < N; ++i)
      sqmod.insert((i*i)%N);
    // sort(begin(sqmod), end(sqmod));
    // sqmod.erase(unique(begin(sqmod), end(sqmod)), end(sqmod));
    vector<int> cnt((N - 1) / 2 + 1, 0);
    for(int i : sqmod) {
      for(int j : sqmod) {
        if(i == j) continue;
        int diff = i - j;
        if(diff < 0) diff += N;
        if(diff > (N - 1)/2) diff = N - diff;
        cnt[diff]++;
      }
    }
    for(int i = 1; i < (int)cnt.size(); ++i) {
      cout << cnt[i] << endl;
    }
  }
}

Measured memory_bytes: 1440
#include<iostream>
using namespace std;
int main(){
  int k[10][10]={0};
  int x,y,s,i,j;
  char c;
  int d=0,w=0;
  int S[4]={0,5,9,13};
  int X[]={0,1,-1,0,0,1,-1,1,-1,2,-2,0,0};
  int Y[]={0,0,0,1,-1,1,-1,-1,1,0,0,2,-2};
  while(cin>>x>>c>>y>>c>>s){
    for(i=0;i<S[s];i++){
      
      if(-1<x&&x<10&&-1<y&&y<10){
	if(-1<x+X[i]&&x+X[i]<10&&-1<y+Y[i]&&y+Y[i]<10){
	  k[x+X[i]][y+Y[i]]++;
	  if(k[x+X[i]][y+Y[i]]>d){
	    d=k[x+X[i]][y+Y[i]];
	  }
	}
      }
    }
  }
  for(i=0;i<10;i++){
    for(j=0;j<10;j++){
      if(k[i][j]==0)w++;
    }
  }
  if(d!=0){
    cout<<w<<"\n"<<d<<endl;
  }
  return 0;
} 

Measured memory_bytes: 1164
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    int n,ans=INF,sum;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=-100; i<=100; i++){
        sum=0;
        for(int j=0; j<n; j++){
            sum+=(i-a[j])*(i-a[j]);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
if a < b < d < c:
    ok = True
    for i in range(a, c):
        if s[i] == '#' and s[i+1] == '#':
            ok = False
            break

    ok2 = True
    for i in range(b, d):
        if s[i] == '#' and s[i+1] == '#':
            ok2 = False
            break

    ok3 = False
    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            ok3 = True
            break

    if ok and ok2 and ok3:
        print('Yes')
    else:
        print('No')
else:
    ok = True
    for i in range(a, c):
        if s[i] == '#' and s[i+1] == '#':
            ok = False
            break

    ok2 = True
    for i in range(b, d):
        if s[i] == '#' and s[i+1] == '#':
            ok2 = False
            break

    if ok and ok2:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cout << std::setprecision(10) << std::fixed;
  int N; std::cin >> N;
  double ans = 0;
  for(int i = 0; i < N; ++i) {
    double A; std::cin >> A;
    ans += 1.0/A;
  }
  fin(1.0/ans);
  return 0;
}


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

using namespace std;

int digits(long long a) {
	int digit = 0;
	while (a) {
		a /= 10;
		digit++;
	}
	return digit;
}

int main() {
	long long n;
	scanf("%lld", &n);
	int mn = INT_MAX;
	for (long long i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			long long a = n / i;
			long long b = i;
			mn = min(mn, max(digits(a), digits(b)));
		}
	}
	printf("%d\n", mn);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

      int A = scan.nextInt();
      int B = scan.nextInt();
      int C = scan.nextInt();

      if(A + B >= C){
         System.out.println("Yes");
         }
      else{
          System.out.println("No");
          }
   }
}


Measured memory_bytes: 24916
def B():
    N, K = map(int, input().split())
    snukes = set([i for i in range(1, N+1)])
    seen = set()
    for i in range(K):
        d = int(input())
        seen = seen.union(set([int(n) for n in input().split()])) 
    print(len(snukes.difference(seen)))
        
B()

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
LL a,b,k;
int main() {
    ios::sync_with_stdio(false);
    cin>>a>>b>>k;
    LL c=min(a,k);
    k-=c;
    a-=c;
    c=min(b,k);
    b-=c;
    cout<<a<<' '<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut n:usize = text_io::read!();
    let mut b:usize = 0;
    let mut c:usize = 0;
    let mut bi:usize = 0;
    for i in 0..n {
        let a:usize = text_io::read!();
        if a>=b {
            c=b;
            b=a;
            bi=i;
        }
        else if a>c {
            c=a;
        }
    }
    for i in 0..n {
        if i!=bi {
            println!("{}",b);
        }
        else {
            println!("{}",c);
        }
    }
}

Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 100005
typedef long long int ll;
ll dp[100][N];
int main()
{
    int n,W,i,j;
    in2(n,W);
    vi w(n),v(n);
    rep(i,n)
        in2(w[i],v[i]);
    fill(dp[0],dp[0]+N,W+1);
    dp[0][v[0]]=w[0];
    dp[0][0]=0;
    lp(i,1,n)
    {
        rep(j,v[i])
            dp[i][j]=dp[i-1][j];
        lp(j,v[i],N)
            dp[i][j]=min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]);
    }
    rep(i,N)
        if(dp[n-1][i]<=W)j=i;
    out(j);
}


Measured memory_bytes: 78336
import java.util.*;

public class Main {
  private static char[] op1 = { '+', '+', '+', '+', '-', '-', '-', '-' };
  private static char[] op2 = { '+', '+', '-', '-', '+', '+', '-', '-' };
  private static char[] op3 = { '+', '-', '+', '-', '+', '-', '+', '-' };
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] n = sc.next().toCharArray();
    int A = n[0] - '0';
    int B = n[1] - '0';
    int C = n[2] - '0';
    int D = n[3] - '0';
    for (int i = 0; i < 8; i++) {
      int sum = A;
      if (op1[i] == '+') {
        sum += B;
      } else {
        sum -= B;
      }
      if (op2[i] == '+') {
        sum += C;
      } else {
        sum -= C;
      }
      if (op3[i] == '+') {
        sum += D;
      } else {
        sum -= D;
      }
      if (sum == 7) {
        System.out.println(""+A+op1[i]+B+op2[i]+C+op3[i]+D+"=7");
        return;
      }
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> py(m);
  rep (i, m) cin >> py[i].first >> py[i].second;
  vector<vector<int>> ken(n + 1);
  rep (i, m) ken[py[i].first].push_back(py[i].second);
  rep1 (i, n) sort(all(ken[i]));
  vector<string> ans(m);
  rep (i, m) {
    int rank = lower_bound(all(ken[py[i].first]), py[i].second) - ken[py[i].first].begin() + 1;
    stringstream ss;
    ss << setfill('0') << right << setw(6) << py[i].first;
    ss << setfill('0') << right << setw(6) << rank;
    ss >> ans[i];
  }
  rep (i, m) cout << ans[i] << "\n";
  return 0;
}

Measured memory_bytes: 13184
//Ki

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int n,q;
graph g;
vector<int>d;
vector<bool>seen;
map<int,int>m{};

int dfs(int t,int o){
    if(seen[t])return 0;
    else seen[t]=true;
    d[t]=d[o]+m[t];
    for(auto i:g[t]){
        dfs(i,t);
    }
    return 0;
}

signed main (){
    cin>>n>>q;
    g.resize(n+1);
    d.resize(n+1);
    seen.resize(n+1);
    rep(i,0,n+1){
        d[i]=0;
        seen[i]=false;
    }
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    rep(i,0,q){
        int a,b;cin>>a>>b;
        m[a]+=b;
    }
    dfs(1,0);
    rep(i,1,n+1){
        cout<<d[i]<<nnn;
    }
    return 0;
}

Measured memory_bytes: 43884
import numpy as np
import sys
readlines = sys.stdin.readlines()

N, M, Q = map(int, readlines[0].split())
city = np.zeros((N + 1, N + 1), dtype='int32')
L, R = np.array([i.split() for i in readlines[1:M + 1]], dtype='int32').T
p, q = np.array([i.split() for i in readlines[M + 1:]], dtype='int32').T

np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print('\n'.join(answer.astype(str)))

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007

int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d){
        cout<<"Yes";
    }else{
    cout<<"No";
    }

}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    prin("Yay!");
  }
  else prin(":(");

  return 0;
}


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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

int n, d;
map<int, int> m;
set<int> s;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    scanf("%d" , &n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d" , &d);
        m[d]++;
        s.insert(d);
    }

    int ans = 0;
    forc(s, it){
        int x = *it;
        if(m[x] > x)
            ans += m[x] - x;
        else if(m[x] < x)
            ans += m[x];
    }
    printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 9344
#include<stdio.h>
#include<math.h>
int main()
{
	int x,y,z,r,n;
	double a,b,c;
	for(;scanf("%d%d%d%d",&x,&y,&z,&n)==4;)
	{
		a=sqrt((double)x*x+y*y)/2;
		b=sqrt((double)y*y+z*z)/2;
		c=sqrt((double)z*z+x*x)/2;
		for(;n-->0;)
		{
			scanf("%d",&r);
			if(a>=r&&b>=r&&c>=r)
				puts("NA");
			else
				puts("OK");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 100;

int dp[10][N + 1] = {0};

int main(void){
    dp[0][0] = dp[1][0] = 1;
    for(int i = 1; i <= 9; i ++)
        for(int j = N; 0 <= j; j --)
            rep(k, 10) if(dp[k][j] && j + i <= N) dp[k + 1][j + i] += dp[k][j];

    for(int n, s; cin >> n >> s, n; cout << dp[n][s] << endl);
 
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <stdlib.h>
#define FAMILY -1
#define MAX 100000
int par[MAX], deg[MAX], *chil[MAX],i,j,n, id, k;
int dep(int);
void input(void);
void output(void);
int main(void){
    // node number
    scanf("%d", &n);
    // initialize
    for(i=0; i<n; i++)  par[i] = FAMILY;
    input();
    output();
    
}
void input(void){
    for(j=0; j<n; j++){
        scanf("%d%d", &id, &k);
        deg[id] = k;
        chil[id] = (int*)malloc(sizeof(int)*k);
        i=0;
        while(i<k){
            scanf("%d", &chil[id][i]);
            par[chil[id][i]] = id;
            i++;
        }
    }
}

void output(void){
    for(i=0; i<n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, par[i], dep(i));
        if(par[i] == FAMILY) printf("root, [");
        else if(deg[i] == 0) printf("leaf, [");
        else    printf("internal node, [");
        j=0;
        while(j<deg[i]){
            printf("%d", chil[i][j]);
            if(j < deg[i] - 1)   printf(", ");
            j++;
        }
        printf("]\n");
    }
}
int dep(int num){
    return (par[num] == FAMILY) ? 0 : (dep(par[num]) + 1);
}


Measured memory_bytes: 6776
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();
   int c = sc.nextInt();
   
   int k = sc.nextInt();
   
   for(int i = 0;i < k;i++){
    if(b <= a){
      b = 2*b;
    }else if(c <= b){
      c = 2*c;
    }else{
      break;
    }
   }
   
   
   
   if(a < b && b < c){
    System.out.println("Yes");
   }else{
    System.out.println("No");
   }
   
 }
}

Measured memory_bytes: 35608
moto=input()
henkan=moto.split()
if int(henkan[1]) <= int(henkan[2]):
    ooi=int(henkan[2])
    sukunai=int(henkan[1])
else:
    ooi=int(henkan[1])
    sukunai=int(henkan[2])
if ooi+sukunai-int(henkan[0])>0:
    sai=ooi+sukunai-int(henkan[0])
else:
    sai=0
print(str(sukunai)+" "+str(sai))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n, *abc = map(int, input().split())
s = [input().rstrip()for _ in range(n)]
cond = {'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}
legend = ('A', 'B', 'C')
ans = []


def dfs(i):
    if -1 in abc:
        return 0
    elif i == n:
        print('Yes')
        print(*ans, sep='\n')
        exit()
        # return 0
    else:
        idx1, idx2 = cond[s[i]]
        abc[idx1] += 1
        abc[idx2] -= 1
        ans.append(legend[idx1])
        dfs(i+1)
        ans.pop()
        abc[idx1] -= 1
        abc[idx2] += 1

        abc[idx1] -= 1
        abc[idx2] += 1
        ans.append(legend[idx2])
        dfs(i+1)
        ans.pop()
        abc[idx1] += 1
        abc[idx2] -= 1


dfs(0)
print('No')


Measured memory_bytes: 105208
#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;
int vis[100009] = {0};
int pen[100009] = {0}; 
int main()
{
	int n, m, res1, res2, id;
	res1 = res2 = 0;
	scanf("%d %d", &n, &m);
	string rec;
	for(int i = 1; i <= m; i++)
	{
		cin>>id>>rec;
		if(rec=="WA") pen[id]++;
		else
		{
			if(vis[id]==0)
			{
				vis[id] = 1;
				res1++;
				res2 += pen[id];
			}
		} 
	}
	printf("%d %d\n", res1, res2);
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
using namespace std;

int main(){
    
    string s;
    cin >> s;
    
    int ans = 1e9;

    for (int i = 0; i < s.length()-2; i++){

        int tmp = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        ans = min(ans,abs(tmp-753));
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var m = readLine.split(" ").map(_.toInt)
  while( m(0) != 0 || m(1) != 0 ){
    val Array(n,x) = m
    println( ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) => sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length })

    m = readLine.split(" ").map(_.toInt)
  }
}

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

int main(){

    ll n;

    cin >> n;
    string ans="";

    if(n==0){
        cout << 0 << endl;
        return 0;
    }

    while(n!=0){
        if(n<0){
            if(abs(n)%2==1){
                ans='1'+ans;
                n=abs(n)/2+1;
            }else{
                ans='0'+ans;
                n=abs(n)/2;
            }
        }else{
            if(n%2==1){
                ans='1'+ans;
            }else{
                ans='0'+ans;
            }
            n/=2;
            n*=-1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>

using namespace std;

int main() {

	int  h, b;
	char r[5], a[5];

	while(cin >> r >> a) {
		if(!strcmp(r, "0")&&!strcmp(a, "0"))
			break;
		h=0;
		b=0;
		for(int i=0; i<4; i++) {
			for(int j=0; j<4; j++) {
				if(r[i]==a[j])
					i==j ? h++ : b++;
			}
		}
		cout << h << " " << b << endl;
	}

	return 0;

}

Measured memory_bytes: 860
#include <stdio.h>
typedef long long ll;
ll mini(ll a, ll b)
{
    if(a>=b)return b;
    return a;
}
ll maxi(ll a, ll b)
{
    if(a>=b)return a;
    return b;
}
int dp[300005];
int a[105],b[105];
int main(void) {
	int n,w;
	scanf("%d%d",&n,&w);
	int i,j;
	ll hi = 1000000007;
	for(i=1; i<=200000;i++)
	dp[i] = w+15;
	for(i=1; i<=n; i++)
	scanf("%d%d",&a[i],&b[i]);
	// find minimum sum for w 
	ll ans = 0;
	for(j=1; j<=n; j++){
	for(i=100000; i>=0;i--)
	{
	    int nx = i + b[j];
	  
	    dp[nx] = mini(dp[nx], dp[i] + a[j]);
	    //printf("next is %d and is %lld\n",nx,dp[nx]);
	    if(dp[nx] <=w)ans = maxi(ans,nx);
	}
	}
	printf("%lld\n",ans);
	return 0;
}



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

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	int x; cin >> x;
	for(int i = x;; i++){
		int flag = 1;
		for(int j = 2; j * j <= x; j++){
			if(i % j == 0) {
				flag = 0;
				break;
			}
		}
		if(flag) {
			cout << i << endl;
			return 0;
		}
	}	
	return 0;
}

Measured memory_bytes: 256
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  ll N;
  ll K;
  ll ans = 0;
  cin >> N >> K;
  vector<ll> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }
  sort(all(list), greater<int>());
  K = min(N,K);
  for (int i = 0; i < K; i++) {
    list[i] = 0;
  }
  dout << "====listの内容====\n";
  for (int i = 0; i < N; i++) dout << list[i] << endl;
  dout << "====ここまで====\n";
  for (int i = 0; i < N; i++) {
    ans += list[i];
  }

  cout << ans;
  return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri(), k = ri();
	int s = ri();
	int none = 1000000000;
	if (s == none) none = 1;
	for (int i = 0; i < n; i++) {
		if (i < k) std::cout << s << std::endl;
		else std::cout << none << std::endl;
	}
	return 0;
}


Measured memory_bytes: 1280
from bisect import bisect_left as bt
n,m = map(int,input().split())
dm,ct = [[] for _ in range(n+1)],[]
for _ in range(m):
  a,b = map(int,input().split())
  dm[a].append(b); ct.append((a,b))
for i in range(1,n+1):
  dm[i].sort()
for c in ct:
  v,f = str(c[0]),str(bt(dm[c[0]],c[1])+1)
  print('0'*(6-len(v))+v+'0'*(6-len(f))+f)

Measured memory_bytes: 32568
#include <stdio.h>
#include <stdlib.h>
typedef struct data *node;
struct data
{
  int key;
  node par;
  node left;
  node right;
};

node root,NIL;
void insert(int k)
{
  node y=NIL;
  node x=root;
  node z;

  z=(node)malloc(sizeof(struct data));
  z->key=k;
  z->left=NIL;
  z->right=NIL;


  while(x!=NIL)
  {
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->par=y;
  if(y==NIL)root=z;
  else
  {
    if(z->key<y->key)y->left=z;
    else y->right=z;
  }
}
void InOrder(node u)
{
  if(u==NIL) return;//,
  InOrder(u->left);
  printf(" %d",u->key);
  InOrder(u->right);
}
void Preorder(node u)
{
  if(u==NIL)return;
  printf(" %d",u->key);
  Preorder(u->left);
  Preorder(u->right);
}
node find(node x,int k)
{
  while(x!=NIL&&k!=x->key)
  {
    if(k<x->key)x=x->left;
    else x=x->right;
  }
  return x;
}
int main()
{
  int n,i,x;
  char str[10];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%s",str);
    if(str[0]=='f')
    {
      scanf("%d",&x);
      node t=find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    if(str[0]=='i')
    {
      scanf("%d",&x);
      insert(x);
    }
    else if(str[0]=='p')
    {

      InOrder(root);
      printf("\n");
      Preorder(root);
      printf("\n");

    }
  }
  return 0;
}



Measured memory_bytes: 25240
import java.util.Scanner;
import java.util.Arrays;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int in;
		int count = 1;
		while(true)
		{
			in = sc.nextInt();
			if(in == 0)
			{
				break;
			}
			System.out.println("Case " + count++ + ": " + in);
		}
		sc.close();
	}
}


Measured memory_bytes: 40996
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    rep(i, S.size()) cout << (char)('A' + (S[i] - 'A' + N) % 26);
    write("");
}

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

int main(){
    char s[105],p[105];
    int slen,plen;
    int i,j;
    fgets(s,105,stdin);
    fgets(p,105,stdin);
    slen = strlen(s)-1;
    plen = strlen(p)-1;
    for(i=0;i<slen;i++){
        for(j=0;j<plen;j++){
            if(s[(i+j)%slen]!=p[j])break;
        }
        if(j==plen){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
#include<set>
#define ll long long 
using namespace std;
int main()
{
	int i,c=0,n;
	cin>>n;
	
	
  string s,s2="ABC",s3;
  cin>>s;
  
  for(i=0;i<=n-3;i++)
  {
  	s3=s.substr(i,3);
  	if (s3==s2)
  	c++;
     
  }
  cout<<c<<endl;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    vector<pair<int, int> > ai(n);
    REP(i,n){
        int a;
        cin >> a;
        ai[i] = make_pair(a, i);
    }
    sort(ALL(ai));
    REP(i,n){
        if(i%2==0){
            if(ai[i].se%2==1){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        char[] inpt = Reader.ReadLine().Select(a => Conv(a)).ToArray();
        Console.WriteLine(string.Join(string.Empty, inpt.Select(a=>a.ToString()).ToArray()));
    }

    private char Conv(char c) {
        if(c>='a'&&c<='z') {
            return (char)(c - 'a' + 'A');
        }
        if(c >='A'&& c<='Z') {
            return (char)(c - 'A' + 'a');
        }
        return c;
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


fAIR, LATER, OCCASIONALLY CLOUDY.


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9384
#include<stdio.h>
int main()
{
	int n,i,x=0,m=0;
	char s[1000];
	scanf("%d",&n);
	scanf("%s",s);
	for(i=0;i<n;i++)
	{
		if(s[i]=='I')
			x++;
		else if(s[i]=='D')
			x--;
		if(x>m)
			m=x;
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 128
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define nnn "\n"
const int inf = 2147483647;

int main (){
    string a;cin>>a;
    if(stoi(a)<100){cout << "0" << nnn;return 0;}
    int r = a.size();
    int s = stoi(a.substr(r-2,2));
    int d = stoi(a.substr(0,r-2));
    if(d*5>=s)cout << "1" << nnn;
    else cout << "0" << nnn;
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[3000][3000], n, x[3000][3000], maxn; char a;
int main() {
	while (true) {
		memset(dp, 0, sizeof(dp));
		cin >> n; if (!n) { break; }
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				cin >> a;
				if (a == '*') {
					x[i][j] = 1;
				}
				else { x[i][j] = 0; }
			}
		}
		maxn = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (x[i][j] == 1) { dp[i][j] = 0; }
				else {
					dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				}
				maxn = max(maxn, dp[i][j]);
			}
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 48288
import java.util.*;
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        for (int i = 0; i < K; i++) {
            if (A % 2 == 1) {
                A -= 1;
            }
            A /= 2;
            B += A;

            i++;
            if (i >= K) {
                break;
            }

            if (B % 2 == 1) {
                B -= 1;
            }
            B /= 2;
            A += B;
        }

        System.out.println(A + " " + B);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int hpInit, hpMax, r, c;
        cin >> hpInit >> hpMax >> r >> c;
        if(hpInit == 0)
            return 0;

        vector<string> grid(r);
        for(int i=0; i<r; ++i)
            cin >> grid[i];

        int t;
        cin >> t;
        vector<int> damage(26);
        for(int i=0; i<t; ++i){
            char c;
            cin >> c;
            cin >> damage[c-'A'];
        }

        int s;
        cin >> s;
        vector<char> dy, dx;
        for(int i=0; i<s; ++i){
            char c;
            int a;
            cin >> c >> a;
            for(int i=0; i<a; ++i){
                if(c == 'U'){
                    dy.push_back(-1);
                    dx.push_back(0);
                }else if(c == 'D'){
                    dy.push_back(1);
                    dx.push_back(0);
                }else if(c == 'R'){
                    dy.push_back(0);
                    dx.push_back(1);
                }else{
                    dy.push_back(0);
                    dx.push_back(-1);
                }
            }
        }
        s = dy.size();

        int p;
        cin >> p;
        vector<int> recover(p);
        for(int i=0; i<p; ++i)
            cin >> recover[i];

        vector<vector<int> > dp(s+1, vector<int>(1<<p, 0));
        dp[0][(1<<p)-1] = hpInit;
        int y0 = 0;
        int x0 = 0;
        for(int i=0; i<s; ++i){
            int y = y0 + dy[i];
            int x = x0 + dx[i];
            for(int j=(1<<p)-1; j>=0; --j){
                if(dp[i][j] == 0)
                    continue;

                dp[i+1][j] = max(dp[i+1][j], dp[i][j] - damage[grid[y][x]-'A']);

                bitset<12> bs(j);
                for(int k=0; k<p; ++k){
                    if(!bs[k])
                        continue;
                    bs[k] = false;
                    dp[i][bs.to_ulong()] = max(dp[i][bs.to_ulong()], min(dp[i][j] + recover[k], hpMax));
                    bs[k] = true;
                }
            }
            y0 = y;
            x0 = x;
        }

        if(dp[s][0] > 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 0
#include<stdio.h>

#define MAX_A 20
#define MAX_M 200
int n, A[MAX_A], M[MAX_M];
int solve(int,int);

int main(){

    int i, q;

    scanf("%d",&n);
    for(i=0; i<n;i++){
        scanf("%d", &A[i]);
    }

    scanf("%d",&q);
    for(i=0; i<q;i++){
        scanf("%d", &M[i]);
    }

    for(i=0;i<q;i++){
        if(solve(0,M[i])){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
   
    return 0;
}

int solve(int i, int m){
    if(m == 0)return 1;
    if(i >= n)return 0;
    return solve(i+1, m) || solve(i+1, m-A[i]);
}

Measured memory_bytes: 580
while 1:
  a, b = map(int, input().split())
  
  if a==0 and b==0:
    break
  
  for i in range(b):
    print("#", end="")

  print()
    
  for j in range(a-2):
    print("#", end="")
    
    for i in range(b-2):
      print(".", end="")
      
    print("#", end="")
    print()
    
  for i in range(b):
    print("#", end="")
  
  print()
    
  print()


Measured memory_bytes: 7000