akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
 

int main() {
    int N, C;
    cin>>N>>C;
    int D[C][C];
    vector<int>zeroarr, onearr, twoarr;
    for(int i=0;i<C;++i){
        for(int j=0;j<C;++j){
            cin>>D[i][j];
        }
    }
    int tmp;
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            cin>>tmp;
            tmp--;
            if((i+j)%3==0) zeroarr.push_back(tmp);
            else if((i+j)%3==1) onearr.push_back(tmp);
            else twoarr.push_back(tmp);
        }
    }
    vector<int> zeroscore, onescore, twoscore;
    int zerotmp;
    for(int i=0;i<C;++i){
        zerotmp = 0;
        for(int j=0;j<zeroarr.size();++j){
            zerotmp += D[zeroarr[j]][i];
        }
        zeroscore.push_back(zerotmp);
    }
    int onetmp;
    for(int i=0;i<C;++i){
        onetmp = 0;
        for(int j=0;j<onearr.size();++j){
            onetmp += D[onearr[j]][i];
        }
        onescore.push_back(onetmp);
    }
    int twotmp;
    for(int i=0;i<C;++i){
        twotmp = 0;
        for(int j=0;j<twoarr.size();++j){
            twotmp += D[twoarr[j]][i];
        }
        twoscore.push_back(twotmp);
    }
 
    long ans = 1e9;
    for(int i=0;i<C;++i){
        for(int j=0;j<C;++j){
            for(int k=0;k<C;++k){
                if(i!=j & j!=k & k!=i & ans > zeroscore[i] + onescore[j] + twoscore[k]) ans = zeroscore[i] + onescore[j] + twoscore[k];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1520
#include <stdio.h>

int main()
{
    char a;
    scanf("%c", &a);
    if (a == 'R')
    {
        printf("%s\n", "Sunny");
    }
    else if (a == 'S')
    {
        printf("%s\n", "Cloudy");
    }
    else
    {
        printf("%s\n", "Rainy");
    }
    return 0;
}

Measured memory_bytes: 128
//36
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int c=0;
  while(n--){
    char p;
    int x;
    cin>>p>>x;
    if(p=='('){
      c+=x;
    }else{
      c-=x;
      if(c<0){
	break;
      }
    }
  }
  cout<<((c==0)?"YES":"NO")<<endl;
  return 0;
}

Measured memory_bytes: 1160
// 6/26 解き直し → 6/30
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll sum = 0;
    rep(i, N) sum += A[i];
    // sum /= 2;  // これが合計。

    vector<ll> B(N);

    B[0] = sum;
    for (int i = 1; i < N; i += 2) {
        B[0] -= (A[i] * 2);
    }

    for (int i = 0; i < N-1; i++) {
        B[i+1] = (A[i] * 2 - B[i]);
    }

    // cout << B[0] << endl;
    rep(i, N) {
        if (i != 0) cout << " ";
        cout << B[i];
    }
    cout << endl;
}

Measured memory_bytes: 4852
#include<stdio.h>
int main()
{
  int n;
  int y,m,d;
  int day=0;//count

  int date[3][10]={ {20,20,20,20,20,20,20,20,20,20},
		    {20,19,20,19,20,19,20,19,20,19},
		    {20,19,20,19,20,19,20,19,20,19} };

  scanf("%d",&n);
  for(;n>0;n--){
    scanf("%d %d %d",&y,&m,&d);
    day=date[y%3][m-1]-d;
    m++;
    d=0;
    if(m==11){
      y++;
      m=1;
    }
    if(y==1000)//999??´10?????????????????´???
      printf("%d\n", day+1);
    else{//????????\???

      while(1){
	day+=date[y%3][m-1];
	m++;   
	if(m==11){
	  y++;
	  m=1;
	}
	if(y==1000)	  
	  break;
      }
    printf("%d\n",day+1);
    }
  }
}

Measured memory_bytes: 596
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


# A
def A():
    r = I()
    print(r * r)
    return


# B
def B():
    N = I()
    s = S()
    if N % 2 != 0:
        print("No")
    elif ''.join(s[:N // 2]) == ''.join(s[N // 2:]):
        print("Yes")
    else:
        print("No")
    return


# C
def C():
    n = I()
    a = [LI() for i in range(n)]
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            ans += pow(pow(a[i][0] - a[j][0], 2) + pow(a[i][1] - a[j][1], 2), 0.5)
    avg = ans / (n*(n-1)/2)
    print(avg * (n - 1))
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    C()
    return


# Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 38384
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int64> A(N);
    REP(i,N) cin >> A[i];

    int ans=0;
    map<int64,int> cnt;
    REP(i,N){
        if(i&1){
            cnt[A[i]]++;
        }
    }
    sort(ALL(A));

    REP(i,N){
        if(i&1){
            if(cnt[A[i]]==0){
                ans++;
            }else{
                cnt[A[i]]--;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int f[30][30] = {0};
  for(;;){
    if(scanf("%1d%1d%1d%1d%1d%1d%1d%1d%",&f[10][10],&f[11][10],&f[12][10],&f[13][10],&f[14][10],&f[15][10],&f[16][10],&f[17][10]) == EOF){break;}
    for(int i=1; i<8; i++){
      scanf("%1d%1d%1d%1d%1d%1d%1d%1d%",&f[10][10+i],&f[11][10+i],&f[12][10+i],&f[13][10+i],&f[14][10+i],&f[15][10+i],&f[16][10+i],&f[17][10+i]);
    }
    bool flag = true;
    for(int i=0; i<8; i++){
      for(int j=0; j<8; j++){
	if(f[10+i][10+j] && flag){
	  if(f[11+i][10+j] && f[10+i][11+j] && f[11+i][11+j]){cout <<"A"<<endl;flag = false;}
	  if(f[10+i][11+j] && f[10+i][12+j] && f[10+i][13+j]){cout <<"B"<<endl;flag = false;}
	  if(f[11+i][10+j] && f[12+i][10+j] && f[13+i][10+j]){cout <<"C"<<endl;flag = false;}
	  if(f[11+i][10+j] && f[10+i][11+j] && f[11+i][9+j]){cout <<"D"<<endl;flag = false;}
	  if(f[11+i][10+j] && f[11+i][11+j] && f[12+i][11+j]){cout <<"E"<<endl;flag = false;}
	  if(f[10+i][11+j] && f[11+i][11+j] && f[11+i][12+j]){cout <<"F"<<endl;flag = false;}
	  if(f[11+i][10+j] && f[11+i][9+j] && f[12+i][9+j]){cout <<"G"<<endl;flag = false;}
	}
      }
    }
  }
  return 0;
}

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

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Pair>[] edges;
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] a = new long[n];
		for(int i=0;i<n;++i) a[i] = sc.nextLong();
		sort(a);
		Pair[] p = new Pair[m];
		for(int i=0;i<m;++i) p[i] = new Pair(sc.nextInt(),sc.nextInt());
		Arrays.sort(p,new Comparator<Pair>() {

			@Override
			public int compare(Pair o1, Pair o2) {
				if(o1.c!=o2.c) return o2.c-o1.c;
				return o2.b-o1.b;
			}
			
		});
	    int j=0;
		for(int i=0;i<m;++i) {
			int b = p[i].b;
			int c = p[i].c;
			while(j<n && a[j]<c && b>0) {
				a[j] = c;
				++j; --b;
			}
		}
		
		long ans = 0;
		for(long x : a) ans+=x;
		out.print(ans);
        out.close();
		
	}
	
	 static void sort(long[] A) {
         PriorityQueue<Long> pq = new PriorityQueue<>();
         int i = 0;
         for (i = 0; i < A.length; i++)
             pq.add(A[i]);
         for (i = 0; i < A.length; i++)
             A[i] = pq.poll();
     }

	static class Pair{
		int b;
		int c;
		Pair(int b,int c){
			this.b = b;
			this.c = c;
		}
	}
}


Measured memory_bytes: 50648
/*abc157C*/

#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int n, i, j, min=1000000, tmp;
  scanf(" %d", &n);
  int x[n];

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

  for(i=0; i <= 100; i++){
    tmp=0;
    for(j=0; j < n; j++){
      tmp+=(x[j] - i) * (x[j] - i);
    }
    if(tmp < min) min=tmp;
  }
  printf("%d", min);
}

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

bool posi(int a,int b,int c){
    if (a + b <= c || a + c <= b || b + c <= a)
        return 0;
    return 1;
}


int main(){
    int n;
    scanf(" %d",&n);
    int nums[n];
    for(int i = 0; i < n;++i) scanf(" %d",&nums[i]);
    int ans = 0;
    for(int i = 0; i < n;++i)
        for(int j = i + 1; j < n;++j)
            for(int k = j+1; k < n;++k)
                if(nums[i] != nums[j] && nums[j] != nums[k] && nums[i] != nums[k] && posi(nums[i],nums[j],nums[k]))
                    ++ans;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3824
ns=list(map(int,input().split()))
rs=input()

def rot(d, r):
    if r == 'N':
        return [d[1], d[5], d[2], d[3], d[0], d[4]]
    if r == 'E':
        return [d[3], d[1], d[0], d[5], d[4], d[2]]
    if r == 'W':
        return [d[2], d[1], d[5], d[0], d[4], d[3]]
    if r == 'S':
        return [d[4], d[0], d[2], d[3], d[5], d[1]]
    return d

for r in rs:
    ns = rot(ns, r)

print(ns[0])

Measured memory_bytes: 7764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D,a;
  cin>>N>>D;
  a = 2*D+1;
  if(N%a==0){
    cout<<N/a<<endl;
  }
  else if(N%a !=0){
    cout<<N/a +1<<endl;
  }
}
  

Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int x;
	cin>>x;
	if(400<=x&&x<600){
		cout<<8;
	}
	else if(600<=x&&x<800){
		cout<<7;
	}
	else if(800<=x&&x<1000){
		cout<<6;
	}
	else if(1000<=x&&x<1200){
		cout<<5;
	}
	else if(1200<=x&&x<1400){
		cout<<4;
	}
	else if(1400<=x&&x<1600){
		cout<<3;
	}
	else if(1600<=x&&x<1800){
		cout<<2;
	}
	else{
		cout<<1;
	}
	cout<<endl;
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int gcd( int a, int b) {
		if (!b) return a;
		else gcd(b, a % b);
}

int main() {
		int N;
		cin >> N;
		vector<int> A(N, 1);
		for ( int i = 0; i < N; i++ ) cin >> A[i];

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

		cout << ans << endl;

		return 0;
}


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

#define int long long
#define INF 1e18

int countDivisor(int n) {
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(n % i == 0) cnt++;
    }
    return cnt;
}

signed main() {
    int n; cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i+=2) {
        if(countDivisor(i) == 8) cnt++;
    }
    cout << cnt << endl;
}


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

int main(int argc, const char * argv[])
{
    int inputN = 0;
    char stringArray[10];
    
    // Checks if the imput value is between 100 and 1000. If not, asks again about inserting the value.
    
      scanf("%d", &inputN);
      if(inputN < 100 || inputN > 1000)
      {
          printf("Wrong Input \n");
          return 0;
      }
    
    
    // In order to find '7' digit inside the inputed int value it program converts from int to string array.
    sprintf(stringArray, "%d", inputN);
    
    long len = strlen(stringArray);
    int digitCounter = 0;
    
    for(int i = 0; i < len; i++)
    {
        if(stringArray[i] == '7')
        {
            digitCounter++;
        }
    }
    
    if(digitCounter > 0)
    {
        printf("Yes \n");
    }
    else
    {
        printf("No \n");
    }
    
    return 0;
}


Measured memory_bytes: 1732
n = int(input())
if 400 <= n <= 599:
  print('8')
elif 600 <= n <= 799:
  print('7')
elif 800 <= n <= 999:
  print('6')
elif 1000 <= n <= 1199:
  print('5')
elif 1200 <= n <= 1399:
  print('4')
elif 1400 <= n <= 1599:
  print('3')
elif 1600 <= n <= 1799:
  print('2')
else :
  print('1')

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

int main() {
  int N[3], K; cin >> N[0] >> N[1] >> N[2] >> K;
  sort(begin(N), end(N));
  cout << N[0] + N[1] + N[2] * pow(2, K) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int H, W, K; cin >> H >> W >> K;
  string S[H];
  rep(i,H) cin >> S[i];
  bool done[H] = {};

  int a[H][W] = {};
  int num = 1;
  string kara = string(W,'.');
  for (int row=0;row<H;row++){
    if (S[row]==kara) continue;
    bool find = false;

    for (int col=0;col<W;col++){
      if (find && S[row][col]=='#') num++;
      a[row][col] = num;

      if (S[row][col]=='#') find = true;

    }
    num++;
    done[row] = true;
    
  }

  for (int row=0;row<H;row++){
    if (S[row]==kara && !done[row]) {
      int r = row;
      while (r<H && !done[r]) r++;
      if (r==H) {
        r--;
        while (r>=0 && !done[r]) r--;
      }
      for (int col=0;col<W;col++){
        a[row][col] = a[r][col];
        done[row] = true;
      }
    }
  }
  rep(i,H) {
    rep(j,W) {
      if (j>0) cout << " ";
      cout << a[i][j];
    }
    cout << endl;
  }





  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4092
#include<bits/stdc++.h>
#pragma warning(disable:4996)
using namespace std;
using ll = long long;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
//#define int long long
vector<int> sieve(int n) {
	vector<int> prime;
	vector<bool> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return prime;
}
map<ll, int> prime_factrorize(ll n, vector<int> const & primes) {
	map<ll, int> result;
	for (int p : primes) {
		if (n < p *(ll)p) break;
		while (n % p == 0) {
			result[p] += 1;
			n /= p;
		}
	}
	if (n != 1) result[n] += 1;
	return result;
}
const ll mod = 1e9 + 7;
signed main() {
	ll n;
	cin >> n;
	vector<int>primes = sieve(n);
	map<ll, int> factors;
	for (int i = 1; i <= n; i++) {
		for (auto e : prime_factrorize(i, primes)) {
			int p, cnt; tie(p, cnt) = e;
			factors[p] += cnt;
		}
	}
	ll ans = 1;
	for (auto e : factors) {
		int cnt = e.second;
		ans = ans * (1 + cnt) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define max(l,r) ((l)>(r)?(l):(r))
#define min(l,r) ((l)<(r)?(l):(r))

int main(){
    int n; scanf("%d", &n);
    printf("%d",(n==1?0:1));
    //rep(i, n) scanf("%lld", ans+i);
    //if(ans){ puts("YES"); rep(i,n) printf("%lld ", a[i]);}else puts("NO");
}


Measured memory_bytes: 1732
import numpy as np
tmp = [int(i) for i in input().split()]
n=tmp[0]
k=tmp[1]
q=tmp[2]
a=[]
for i in range(q):
  a.append(int(input()))
  
A = np.zeros(n)
A = [i+k-q for i in A]
for m in a:
  A[m-1] += 1
for j in range(len(A)):
  if A[j] <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 21332
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{

      public static void main(String args[])throws IOException
    {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));	
	String line;
	while(true)
	    {
		line = in.readLine();
		String[] elements = line.split(" ");
		int[] cards = new int[elements.length+1];

		if(elements[0].equals("0") && elements.length == 1)
		break;

		int one_counter = 0;		
		int sum = 0;


		for(int i=0;i<elements.length;i++)
		    {
			cards[i] = Integer.parseInt(elements[i]);
			if(cards[i] == 1)
			    {
				one_counter++;
			    }
			if(cards[i] <= 9)
			    sum += cards[i];
			else 
			    sum += 10;
		    }

		if(sum > 21)
		    {
			System.out.println(0);
			continue;
		    }
		else
		    {
			if(one_counter == 0)
			    {
				System.out.println(sum);
			    }
			else 
			    {
				while(one_counter>0 && sum-1+11 <= 21)
				    {
					one_counter--;
					sum--;
					sum += 11;
				    }
				System.out.println(sum);
			    }
		    }
	    }
    }
    
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B, C; cin >> A >> B >> C;
  ll ans = LLONG_MAX;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << 0 << endl;
  }else {
    ans = min(ans, B * C);
    ans = min(ans, B * A);
    ans = min(ans, A * C);
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3640
h,w = map(int,input().split())
s=["."*(w+2)]
for _ in [0]*h:
  s += ["."+input()+"."]
s += ["."*(w+2)]
for i in range(h):
  for j in range(w):
    if s[i+1][j+1] == "#" and (not "#" in [s[i][j+1],s[i+1][j],s[i+2][j+1],s[i+1][j+2]]):
      print("No")
      exit()
print("Yes")

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

int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  
  bool judge = false;
  for (int i = 0; i < N; i++) {
    if (S.at(i)=='Y') {
      judge = true;
      break;
    }
  }
  
  if(judge) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define pai 3.14159265359
#define mod 1000000007

int main()
{
    long long int n, l;
    cin >> n >> l;
    long long int rope[100001];
    for(int i = 1; i <= n; i++){
        cin >> rope[i];
    }
    for(int i = 1; i <= n - 1; i++){
        if(rope[i] + rope[i + 1] >= l){
            cout << "Possible" << endl;
            for(int j = 1; j < i; j++){
                cout << j << endl;
            }
            for(int j = n - 1; j > i; j--){
                cout << j << endl;
            }
            cout << i << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}

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

int main()
{





   int N,C0=0,C1=0,C2=0,C3=0;
cin>>N;
string s[N];

for(int i=0;i<N;i++)
{ cin>>s[i];
if(s[i]=="AC")
    C0++;
    else if(s[i]=="WA")
        C1++;
    else if(s[i]=="TLE")
        C2++;
    else if(s[i]=="RE")
        C3++;

}

cout<<"AC x "<<C0<<endl;
cout<<"WA x "<<C1<<endl;
cout<<"TLE x "<<C2<<endl;
cout<<"RE x "<<C3<<endl;
    return 0;
}


Measured memory_bytes: 6684
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
#define mp make_pair
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

vl v,w;
vvl dp(512,vl(1e5+1,0));//頂点,コスト->価値のまっくす

ll bfs(ll V,ll W,ll c){
  if(W<0){
    return 0;
  }
  else if(V<=511){
    return c+dp[V][W];
  }
  else{
    ll x=bfs(V/2,W,c);
    ll y=bfs(V/2,W-w[V],c+v[V]);
    return max(x,y);
  }
}

int main() {
  ll N;
  cin >> N;
  v.resize(N+1),w.resize(N+1);
  rep(i,N){
    cin >> v[i+1] >> w[i+1];
  }
  ll q;
  cin >> q;
  ll x;
  dp[1][w[1]]=v[1];
  FOR(i,1,min(N+1,(ll)512)){
    rep(j,1e5+1){
      if(j==0||(i==1&&j==w[1])){
        continue;
      }
      if(j>=w[i]){
        dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i]]+v[i]);
      }
      else{
        dp[i][j]=dp[i/2][j];
      }
    }
  }
  rep(i,q){
    ll V,W;
    cin >> V >> W;
    x=bfs(V,W,0);
    cout << x << endl;
  }
}


Measured memory_bytes: 408764
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, lc;

  for ( lc = 0; ; ++lc )
  {
    int a, b;
    int c = 0;

    scanf ( "%d%d", &a, &b );
    if ( !( a | b ) ) break ;
    if ( lc )         puts ( "" );

    for ( i = a; i <=b; ++i )
    {
      if ( ( !( i % 4 ) && !!( i % 100 ) )
        || !( i % 400 ) )
      {
        printf ( "%d\n", i );
        ++c;
      }
    }

    if ( !c )
    {
      puts ( "NA" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    K = int(rl())
    S = rl().rstrip()
    MOD = 10 ** 9 + 7
    
    com = Combination(2 * 10 ** 6, MOD)
    n = len(S)
    m = n + K
    ans = 0
    for i in range(n, m + 1):
        j = m - i
        ans += com.ncr(n + K - j - 1, n - 1) * pow(25, K - j, MOD) * pow(26, j, MOD)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 123112
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << t/a*b << endl;
}

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

int cnt_digits(long long N) {
    int digits = 0;

    while(N > 0) {
        N /= 10;
        digits++;
    }
    return digits;
}

int main() {
    long long N;
    cin >> N;
    
    int ans = cnt_digits(N);
    
    for(long long A = 1; A*A <= N; A++) {
        if(N%A != 0) continue;
        const long long B = N/A;
        
        const int cur = max(cnt_digits(A), cnt_digits(B));
        if(ans > cur) {
            ans = cur;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

ll n, m;
ll x[1050];
ll y[1050];
ll z[1050];
ll bx[1050];
ll by[1050];
ll bz[1050];


ll dp[1050][1050];

ll solve(ll pos, ll cnt) {
    if(pos >= n) {
        if(cnt == m) {
            return 0;
        } else if(cnt < m) {
            return -1e18;            
        }
    }
    if(cnt == m) return 0;

    ll& ret = dp[pos][cnt];
    if(ret != -1) return ret;
    ret = solve(pos+1, cnt);
    if(cnt < m) {
        ret = max(ret, solve(pos+1, cnt+1) + x[pos] + y[pos] + z[pos]);
    }
    return ret;
}

void dpreset() {
    rep(i,0,1050) rep(j,0,1050) dp[i][j] = -1;
}

void myreset(int a, int b, int c) {
    if(!a) {
        a = -1;
    }
    if(!b) {
        b = -1;
    }
    if(!c) {
        c = -1;
    }
    rep(i,0,n) {
        x[i] = bx[i] * a;
        y[i] = by[i] * b;
        z[i] = bz[i] * c;
    }
}

int main(void) {
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
    rep(i,0,n) {
        cin >> bx[i] >> by[i] >> bz[i];
    }
    ll ret = 0;
    rep(i,0,2) rep(j,0,2) rep(k,0,2) {
        myreset(i,j,k);
        dpreset();
        ret = max(ret, abs(solve(0,0)));
    }
    cout << ret << '\n';
	return 0;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int func(int n){
  
  if ( n % 2 == 0 ){
    return n / 2;
  }else{
    return 3 * n + 1;
  }
  
}


int main() {
  
  int s;
  cin >> s;
  
  vector<int> a;
  a.push_back(s);
  
  int i = 1;
  
  while(true){
    a.push_back(func(a[i-1]));
    for ( int j = 0; j < i ; j++){
      if ( a[i] == a[j] ){
        cout << i+1 << endl;
        return 0;
      }
    }
    i++;
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<cmath>
#define ll long long
#define N 100100
#define MZ 1300
using namespace std;
 
ll n,a[N],b[N],zs[N],zz,ans;
bool P[N];
map<ll,ll>cnt;
map<ll,bool>vis;
 
inline void get()
{
	ll i,j;
	for(i=2;i<=100000;i++)
	{
		if(!P[i]) zs[++zz]=i;
		for(j=1;j<=zz&&zs[j]*i<=100000;j++) P[zs[j]*i]=1;
	}
}
 
int main()
{
//	freopen("2.txt","r",stdin);
	ll i,j,k,p,q,t,tmp;
	get();
//	cout<<zs[1300];
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		t=a[i];
		b[i]=q=1;
		for(j=1;j<=MZ&&t!=1;j++)
		{
			p=0;
			for(;t%zs[j]==0;t/=zs[j]) p++;
			p%=3;
			if(!p) continue;
			for(k=1;k<=p;k++) q*=zs[j];
			for(k=p+1;k<=3;k++) b[i]*=zs[j];
		}
		if(t)
		{
			tmp=sqrt(t);
			if(tmp*tmp==t)
			{
				q*=t;
				b[i]*=tmp;
			}
			else
			{
				q*=t;
				b[i]*=t*t;
			}
		}
		a[i]=q;
		cnt[a[i]]++;
//		if(i%1000==0) cout<<i<<endl;
	}
//	return 0;
//	for(i=1;i<=n;i++) cout<<a[i]<<" ";puts("");
//	for(i=1;i<=n;i++) cout<<b[i]<<" ";puts("");
	for(i=1;i<=n;i++)
	{
		if(vis[a[i]] || vis[b[i]] || a[i]==1) continue;
		vis[a[i]]=1;
		ans+=max(cnt[a[i]],cnt[b[i]]);
	}
	cout<<ans+(!!cnt[1]);
}

Measured memory_bytes: 27008
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>

using namespace std;

#define NIL -1
#define MAX 100005

struct Node {
    int parent;	    //???
    int left;	    //????????\?????????
    int right;	    //?????´
};

struct Node T[MAX];
int Depth[MAX];
int n;

void rec(int u, int depth) {
    Depth[u] = depth;
    if (T[u].right != NIL) {
	rec(T[u].right, depth);
    }
    if (T[u].left != NIL) {
	rec(T[u].left, depth + 1);
    }
}

void print(int u) {
    int i, c;

    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("depth = %d, ", Depth[u]);

    if (T[u].parent == NIL) {
	printf("root, ");
    }
    else if (T[u].left == NIL) {
	printf("leaf, ");
    }
    else {
	printf("internal node, ");
    }
    
    printf("[");
    for (i = 0, c = T[u].left; c != NIL; i++,c=T[c].right) {
	if (i) {
	    printf(", ");
	}
	printf("%d", c);
    }
    printf("]\n");
}

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

    int id;
    int degree;
    int chilId;
    int left;
    int r;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
	T[i].left = T[i].right = T[i].parent = NIL;
    }

    for (int i = 0; i < n; i++) {
	scanf("%d", &id);
	scanf("%d", &degree);
	for (int j = 0; j < degree; j++) {
	    scanf("%d", &chilId);
	    if (j == 0) {
		T[id].left = chilId;
	    }
	    else {
		T[left].right = chilId;
	    }
	    left = chilId;
	    T[chilId].parent = id;
	}
    }
    for (int i = 0; i < n; i++) {
	if (T[i].parent == NIL) {
	    r = i;
	}
    }

    rec(r, 0);
    
    for (int i = 0; i < n; i++) {
	print(i);
    }

    return 0;
}

Measured memory_bytes: 7852
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
string s1,s2;
long n,i,j,h=1e9+7,ans=0;
long dp[55][4][4]={0};
void sol(long i)
{
    if(i==0)
    {
        if(s1[i]==s2[i])
        {
            dp[i][0][0]=1;
            dp[i][1][1]=1;
            dp[i][2][2]=1;
        }
        else
        {
            dp[i][0][1]=1;
            dp[i][1][0]=1;
            dp[i][0][2]=1;
            dp[i][2][0]=1;
            dp[i][1][2]=1;
            dp[i][2][1]=1;
        }
        return ;
    }
    if(s1[i-1]==s2[i-1])
    {
        if(s1[i]==s2[i])
        {
            dp[i][0][0]=(dp[i-1][1][1]+dp[i-1][2][2])%h;
            dp[i][1][1]=(dp[i-1][0][0]+dp[i-1][2][2])%h;
            dp[i][2][2]=(dp[i-1][1][1]+dp[i-1][0][0])%h;
        }
        else
        {
            dp[i][0][1]=dp[i-1][2][2];
            dp[i][1][0]=dp[i-1][2][2];
            dp[i][2][1]=dp[i-1][0][0];
            dp[i][1][2]=dp[i-1][0][0];
            dp[i][0][2]=dp[i-1][1][1];
            dp[i][2][0]=dp[i-1][1][1];
        }
    }
    else
    {
        if(s1[i]==s2[i])
        {
            dp[i][0][0]=(dp[i-1][1][2]+dp[i-1][2][1])%h;
            dp[i][1][1]=(dp[i-1][0][2]+dp[i-1][2][0])%h;
            dp[i][2][2]=(dp[i-1][1][0]+dp[i-1][0][1])%h;
        }
        else if(s1[i]==s1[i-1])
        {
            dp[i][0][1]=dp[i-1][0][1];
            dp[i][1][0]=dp[i-1][1][0];
            dp[i][2][1]=dp[i-1][2][1];
            dp[i][1][2]=dp[i-1][1][2];
            dp[i][0][2]=dp[i-1][0][2];
            dp[i][2][0]=dp[i-1][2][0];
        }
        else
        {
            dp[i][0][1]=(dp[i-1][1][0]+dp[i-1][2][0]+dp[i-1][1][2])%h;
            dp[i][1][0]=(dp[i-1][0][1]+dp[i-1][0][2]+dp[i-1][2][1])%h;
            dp[i][2][1]=(dp[i-1][1][2]+dp[i-1][0][2]+dp[i-1][1][0])%h;
            dp[i][1][2]=(dp[i-1][2][1]+dp[i-1][2][0]+dp[i-1][0][1])%h;
            dp[i][0][2]=(dp[i-1][1][0]+dp[i-1][2][0]+dp[i-1][2][1])%h;
            dp[i][2][0]=(dp[i-1][0][1]+dp[i-1][0][2]+dp[i-1][1][2])%h;
        }
    }
}
int main()
{
    io
    cin>>n>>s1>>s2;
    for(i=0;i<n;++i)
    sol(i);
    for(i=0;i<3;++i)
    for(j=0;j<3;++j)
    ans=(ans+dp[n-1][i][j])%h;
    cout<<ans;
    return 0;
}


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

int main(){
  int a[3];
  
  for (int i = 0; i < 3; i++){
    cin >> a[i];
  }
  
  if (a[0] == a[1] && a[1] == a[2] && a[0] == a[2]){
    cout << 1 << endl;
  } else if (a[0] != a[1] && a[1] != a[2] && a[0] != a[2]){
    cout << 3 << endl;
  } else {
    cout << 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import javax.sound.midi.Soundbank;
import java.util.*;
import java.lang.*;

public class Main
{
    static int gcd(int a, int b)
    {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    static int lcm(int a, int b)
    {
        return (a*b)/gcd(a, b);
    }
    public static void main (String[] args) {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        System.out.println(lcm(360, n) / n);
    }
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pi;

int n;
const int maxn = 1e5 + 5;
ll a[maxn];
vector<int> G[maxn];
int deg[maxn];

bool dfs(int u, int fa){
    ll up = 0;
    if(deg[u] == 1){
        return true;
    }
    ll mx = 0;
    for(auto v : G[u]){
        if(v == fa)
            continue;
        if(!dfs(v, u))
            return false;
        up += a[v];
        mx = max(mx, a[v]);
    } 
    if(up < a[u])
        return false;
    ll ub = 0;
    if(mx > up - mx){
        ub = up - mx; 
    }else{
        ub = up / 2;
    }
    ll delta = up - a[u];
    if(delta  > ub)
        return false;
    a[u] -= delta;
    return true;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    for(int i = 1;i < n;i++){
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    if(n == 2){
        if(a[1] != a[2]){
            cout << "NO" << endl;
        }else{
            cout << "YES" << endl;
        }
    }else{
        int root = 0;
        for(int i = 1;i <= n;i++){
            if(deg[i] != 1){
                root = i;
            }
        } 
        if(dfs(root, root)){
            if(a[root] == 0){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 14080
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int64 n, k; cin >> n >> k;
	vector<int64> h(n);
	rep (i, n) {
		cin >> h[i];
	}
	sort(all(h));
	int64 ans = 0;
	if (n <= k) {
		cout << 0 << endl;
		return;
	}
	for (int i = h.size() - 1 - k; i >= 0; --i) {
		ans += h[i];
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 1792
class SegmentTree: #1-indexed
    def __init__(self,list,a,f=lambda x,y:x+y,inf=0):
        self.height=(len(list)-1).bit_length()+1 #木の高さ
        self.id=inf #単位元
        self.tree=[self.id]*(2**self.height) #木を単位元で初期化
        self.f=f
        for i in range(len(list)):
            if list[i]==a:
                self.tree[2**(self.height-1)+i]=1
        for i in range(2**(self.height-1)-1,0,-1):
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
        
    def update(self,i,x): #i番目の要素をxに変更(0-indexed)
        i+=2**(self.height-1)
        self.tree[i]=x
        while i>1:
            i//=2
            self.tree[i]=self.f(self.tree[2*i],self.tree[2*i+1])
    
    def query(self,l,r): #0-indexed
        l+=2**(self.height-1)
        r+=2**(self.height-1)
        lf,rf=self.id,self.id
        while l<r:
            if l&1:
                lf=self.f(lf,self.tree[l])
                l+=1
            if r&1:
                r-=1
                rf=self.f(self.tree[r],rf)
            l//=2
            r//=2
        return self.f(lf,rf)
n=int(input())
s=list(input())
q=int(input())
l=[]
for i in range(26):
    l.append(SegmentTree(s,chr(97+i),f=lambda x,y:x or y))
for _ in range(q):
    a,b,c=input().split()
    if a=="1":
        b=int(b)-1
        l[ord(s[b])-97].update(b,0)
        l[ord(c)-97].update(b,1)
        s[b]=c
    else:
        b,c=int(b)-1,int(c)
        count=0
        for i in range(26):
            if l[i].query(b,c):
                count+=1
        print(count)

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

int ssort(int A[],int N){
  int i,j,t,sw=0,minj;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]) minj=j;
    }
    t=A[i]; A[i]=A[minj]; A[minj]=t;
    if(i!=minj) sw++;
  }
  return sw;
}
int main(){
  int i,A[100],N,sw;

  cin>>N;
  for(i=0;i<N;i++) cin>>A[i];
  sw=ssort(A,N);
  for(i=0;i<N;i++){
    if(i>0) cout<<(" ");
    cout<<A[i];
  }
  cout<<endl;
  cout<<sw<<endl;

  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(){ 
    int n;
    cin >> n;
    int s;
    int cnt = 0;
    int ans = 100000000000;
    
    for (int i = 0; i < n; i++){
        cnt = 0;
        cin >> s;
        while (1) {
            if (s % 2 == 0){
                cnt += 1;
                s /= 2;
                continue;
            }
            break;
        }
        if (ans > cnt) {
            ans = cnt;
        }
    }
    
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println(Math.max(a + b, Math.max(a * b, a - b)));
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    int s[7];
    int c[7];
    for(int i = 1; i <= M; i++) {
        cin >> s[i] >> c[i];
    }
    int min = 0;

    int ans[4] = {0};
    if(N==2) ans[1] = 1;
    if(N==3) ans[2] = 1;
    for(int i = 1; i <= M; i++) {
        if((N==3||N==2)&&s[i]==1&&c[i]==0) {
            min = 1000;
            break;
        }
        ans[N-s[i]] = c[i];
    }

    for(int i = 1; i <= N; i++){
        int judge = 0;
        int tag = 10;
        for(int j = 1; j <= M; j++){
            if(s[j]==i) tag = c[j];
            //cout << tag << endl;
            break;
        }
        if(tag!=10){
            //cout << tag << endl;
            for(int j = 1; j <= M; j++){
                //cout << s[j] << endl;                
                if(s[j]==i&&c[j]!=tag) {                    
                    judge = 1;
                }
            } 
        }
        if(judge==1) {
            //cout << -1 << endl; 
            min = 1000; 
            break;
        } 
    }

    //cout << min << endl;
    if(min==1000) cout << -1 << endl;
    else {
        int answer = ans[0] + ans[1]*10 + ans[2]*100;
        cout << answer << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
int a,b,c,d,e,f;
double noudo;
int ban[3600][3200];

int main(){
  cin >> a >> b >> c >> d >> e >> f;
  ban[0][0] = 1;
  REP(j,f+1){
    REP(i,f+1){
      if(i-100*a>=0)ban[i][j] = max(ban[i][j],ban[i-100*a][j]);
      if(i-100*b>=0)ban[i][j] = max(ban[i][j],ban[i-100*b][j]);
      if(i-c>=0&&j-c>=0)ban[i][j] = max(ban[i][j],ban[i-c][j-c]);
      if(i-d>=0&&j-d>=0)ban[i][j] = max(ban[i][j],ban[i-d][j-d]);
    }
  }
  noudo = -10.0;
  int ans1 = -1;
  int ans2 = -1;
  /*
  REP(i,f+1){
    cout << i << endl;
    REP(j,f+1){
      cout << ban[i][j];
    }
    cout << endl;
  }
  */
  REP(j,f+1){
    REP(i,f+1){
      if((i-j)*e<100*j) continue;
      if(ban[i][j]==0) continue;
      double t;
      t = 100.0*j/i;
      if(t>noudo){
        noudo = t;
        ans1 = i;
        ans2 = j;
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 37120
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<string>
using namespace std;

static int N;
static vector<int> balls;
static vector<int> A, B;
static bool flag;

void dfs(int id)
{
	if (flag) return;
	if (id >= 10)
	{
		flag = true;
		return;
	}
	//printf("%d\n", id);
	if ((A.size() > 0 && balls[id] > A.back()) || A.size() == 0)
	{
		A.push_back(balls[id]);
		dfs(id + 1);
	}
	else if ((B.size() > 0 && balls[id] > B.back()) || B.size() == 0)
	{
		B.push_back(balls[id]);
		dfs(id + 1);
	}
	
}




int main()
{
	while (scanf("%d", &N) != EOF)
	{
		while (N--)
		{
			balls.clear();
			balls.resize(10);
			for (int i = 0; i < 10; i++) scanf("%d", &balls[i]);
			A.clear();
			B.clear();
			flag = false;
			dfs(0);
			printf(flag ? "YES\n" : "NO\n");
		}
	}
	return 0;
}


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

int main() {
  string s;
  cin>>s;
  int count = 0;
  if(s.at(0)=='1') count++;
  if(s.at(1)=='1') count++;
  if(s.at(2)=='1') count++;
 
  cout<<count<<endl;
  
}
    
  
  


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  int i;
  for(i=0;i<N;i++)cin >> A[i];
  for(i=0;i<N-K;i++) {
    if(A[i] < A[K+i])cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

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

    if(a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;

    return 0;
}

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

# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput (string in = "s") {
  if (fopen (in.c_str(), "r"))
    freopen (in.c_str(), "r", stdin);
  else
    cerr << "Input file not found" << endl;
}
const int N = 5e4 + 1;

int dp[N];

int n, m; 

int main()
{
	Read_rap();             
  cin >> n >> m;            
  fill (dp + 1, dp + n + 1, MX);
          
  for (int i = 1; i <= m; i++) {
  	int x; cin >> x;
  	for (int j = 0; j + x <= n; j++)
  		dp[j + x] = min (dp[j + x], dp[j] + 1);
  }        
  cout << dp[n];


  cout << endl;

  return 0;
}










// Coded by Z..



Measured memory_bytes: 3348
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif


typedef long long lint;

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

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


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

	int n, in, sum = 0; cin >> n;
	rep(i, n) {
		cin >> in; sum += in;
	}
	cout << sum - n;
	gc();
}

Measured memory_bytes: 256