akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h;
    cin >> h;
    ll tmp = 1;
    while(tmp <= h) {
        tmp *= 2;
    }
    tmp /= 2;
    ll ans = 0;
    for(ll bit = 1; bit <= tmp; bit *= 2) {
        ans += bit;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		if(check(s[0],s[1])) {
			if(check(s[2],s[3])) {
				System.out.println("AMBIGUOUS");
			}else {
				System.out.println("MMYY");
			}
		}else {
			if(check(s[2],s[3])) {
				System.out.println("YYMM");
			}else {
				System.out.println("NA");
			}
		}
	}
	
	public static boolean check(char a, char b) {
		int ch = (Character.getNumericValue(a))*10
				    +(Character.getNumericValue(b));
		if(1 <= ch && ch <= 12) {
			return true;
		}else {
			return false;
		}
	}
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 200005


#define PI 3.14159265358979323846264338327950

#define ll  long long int
vector<ll> v;
multiset<ll> ms;
multiset<ll>::iterator it;
ll a[MAXX], b[MAXX];
ll mod = 1000000007;
char c[MAXX];

int main()
{
	FAST;
	ll  ans = 0, a1 = 0, a2 = 0, n , mx = 0;
	cin >> n ;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		ans += a[i];
		mx = max(mx, a[i]);
	}
	ans -= mx;
	if(ans > mx){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}

Measured memory_bytes: 256
//cod2016_qualA_c.cpp
//Sun Aug  4 16:46:10 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	for (int i=0;i<s.size();i++){
		int tempc = (int)s[i]-'a';
		if (k>=26-tempc && tempc != 0){
			s[i] = 'a';
			k = k-(26-tempc);
		}
	}

	k=k%26;
	if (k>0){
		int tempc = (int)s[s.size()-1]-'a';
		tempc += k;
		s[s.size()-1] = (char)tempc+'a';
	}

	cout << s << endl;

}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back

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

    ll w,a,b,ans;
    cin >> w >> a >> b;
    if(b > a+w) ans = b - (a+w);
    else if(a > b+w) ans = a - (b+w);
    else ans = 0;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N,num,Nc;
	cin >> N;
	Nc = N;
	num = 0;
	do {
		num += N % 10;
		N /= 10;
	} while (N > 0);

	//cout << num << endl;

	if (Nc%num == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
char s[MAXN];
int N;
vector<int> c[30];
bool vis[MAXN];
int tr[MAXN];
void Init() {
    scanf("%s",s + 1);
    N = strlen(s + 1);
}
int lowbit(int x) {return x & -x;}
void Insert(int x,int v) {
    while(x <= N) {
	tr[x] += v;
	x += lowbit(x);
    }
}
int Query(int x) {
    int res = 0;
    while(x > 0) {
	res += tr[x];
	x -= lowbit(x);
    }
    return res;
} 
void Solve() {
    int cnt = 0;
    for(int i = N ; i >= 1 ; --i) {
	c[s[i] - 'a'].pb(i);
    }
    for(int i = 0 ; i < 26 ; ++i) {
	if(c[i].size() & 1) ++cnt;
    }
    if(cnt >= 2) {puts("-1");return;}
    for(int i = 1 ; i <= N ; ++i) Insert(i,1);
    int64 ans = 0;
    int k = 0;
    for(int i = N ; i >= 1 ; --i) {
	if(vis[i]) continue;
	int t = c[s[i] - 'a'].back();c[s[i] - 'a'].pop_back();
	if(t == i){ ++k;continue;}
	ans += Query(t - 1) + k;
	vis[t] = 1;
	Insert(t,-1);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
}


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

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

    vector<int> A1(N);
    vector<int> A2(N);
    rep(i, N){
        cin >> A1[i];
    }
    rep(i, N){
        cin >> A2[i];
    }

    int ans = 0;
    rep(i, N){
        int X = 0;
        rep(j, i + 1){
            X += A1[j];
        }
        for (int k = i; k < N; k++){
            X += A2[k];
        }
        if (X > ans)ans = X;
    }

    cout << ans << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int A1 = 60 * H1 + M1;
    int A2 = 60 * H2 + M2;
    dd(A1, A2);
    if (A2 < A1) { A2 += 60 * 24; }
    int ans = (A2 - K) - A1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

char origin_one[10][10];
char copy_one[10][10];
int H, W, K;

int counter(void){
  int count=0;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(copy_one[i][j]=='#') count++;
    }
  }
  return count;
}

void copy_origin(){
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      copy_one[i][j] = origin_one[i][j];
    }
  }
}

void red_raw(int n){
  for(int i=1;i<=W;i++){
    copy_one[n][i] = 'R';
  }
}

void red_column(int n){
  for(int i=1;i<=H;i++){
    copy_one[i][n] = 'R';
  }
}

void debug(){
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cout << copy_one[i][j] << " ";
    }
    cout << endl;
  }
  cout << counter() << endl;
}

int main(){
  int sum=0;
  cin >> H >> W >> K;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> origin_one[i][j];
    }
  }
  copy_origin();

  for(int s=0;s<(1<<H);s++){
    for(int t=0;t<(1<<W);t++){
      for(int i=0;i<H;i++){
        if((s>>i)&1) red_raw(i+1);
      }
      for(int i=0;i<W;i++){
        if((t>>i)&1) red_column(i+1);
      }
      if(counter()==K){
        // debug();
        sum++;
      }
      copy_origin();
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    string s; cin >> s;
    map<char, int> m;
    rep(i,s.size()){
        m[s[i]]++;
    }
    if(m.size()==1 || m.size()==3) cout << "No" << endl;
    else if(m.size()==4) cout << "Yes" << endl;
    else {
        if(m['N']!=0 && m['S']!=0) cout << "Yes" << endl;
        else if(m['W']!=0 && m['E']!=0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int A[3];
	int a,b,c;
	int N[3];
	scanf("%d %d %d",&A[0],&A[1],&A[2]);
	a=A[0]-A[1];
	b=A[0]-A[2];
	c=A[2]-A[1];
	if(a<0){
		a=-a;
	}
	if(b<0){
		b=-b;
	}
	if(c<0){
		c=-c;
	}
	N[0]=a+b;
	N[1]=b+c;
	N[2]=c+a;
	if(N[0]<N[1]){
		if(N[0]<N[2]){
			printf("%d",N[0]);
		}else{
			printf("%d",N[2]);
		}
	}else{
		if(N[1]<N[2]){
			printf("%d",N[1]);
		}else{
			printf("%d",N[2]);
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const ll maxn=1e5+1;
ll n,a[maxn],dp[maxn][2];
int main()
{
	cin>>n;
	for(ll i=0;i<n;i++)cin>>a[i];
	dp[0][0]=a[0];
	dp[0][1]=-a[0];
	for(ll i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]-a[i],dp[i-1][0]+a[i]);
		dp[i][1]=max(dp[i-1][1]+a[i],dp[i-1][0]-a[i]);
	}
	cout<<dp[n-1][0]<<endl;
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]

ab = sorted([x[0]+x[1] for x in AB], reverse=True)
ans = 0
for i in range(N):
    ans -= AB[i][1]

if N % 2 == 0:
    K = N // 2
else:
    K = N // 2 + 1
for i in range(K):
    ans += ab[2*i]


print(ans)

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

int main(){
  int N;
  char arr[100][15];
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%s",arr[i]);
  }
  bool kkk=true;
  for(int i=1;i<N;i++){
    bool ck=false;
    for(int j=0;j<i;j++){
      if(strcmp(arr[i],arr[j])==0) ck=true;
    }
    if(ck||arr[i-1][strlen(arr[i-1])-1]!=arr[i][0]){
      kkk=false;
    }
  }
  if(kkk) printf("Yes");
  else printf("No");
}


Measured memory_bytes: 128
#include <stdio.h>
int a[50]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},n;
int main () {
  int n;
  scanf ("%d",&n);
  printf ("%d\n",a[n-1]);
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    string s;
    cin >> s;
    int n = (int) s.size();
    long long cnt = 0;
    int a = 0;
    for (int i = 0; i + 2 < n; i++) {
        if (s[i] == 'A') {
            if (s[i + 1] == 'B' and s[i + 2] == 'C') {
                cnt += a + 1;
                s[i + 2] = 'A';
                i = i + 1;
            } else ++a;
        } else a = 0;
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N,K;
	cin >> N >> K;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int ret = INF;
	for(int i = 0;i < N - K + 1;i++) {
		int A = vec.at(i);
		int B = vec.at(i + K - 1);
		int ret2 = abs(B) + B - A;
		int ret3 = abs(A) + B - A;
		ret = min(ret,min(ret2,ret3));
	}
	cout << ret << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T... ar) {
        for (T i : ar) {
            out.print(i + " ");
        }
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException {

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc) {
        int n = sc.ni();
        long[] ar = sc.nlArr0(n);
        Arrays.sort(ar);

        double ans = ar[0];

        for (int i = 1; i < n; i++) ans = (ans + ar[i]) / 2;

        out.println(ans);
    }

    static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc() {
            return nn().charAt(0);
        }

        int ni() {
            return Integer.parseInt(nn());
        }

        long nl() {
            return Long.parseLong(nn());
        }

        double nd() {
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n) {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        int[] niArr1(int n) {
            int[] ar = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        long[] nlArr0(int n) {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nl();
            }
            return ar;
        }

        long[] nlArr1(int n) {
            long[] ar = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nl();
            }
            return ar;
        }
    }
}

Measured memory_bytes: 23252
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    a = list(in_na())

    t = 0
    for i in range(N):
        t = t | a[i]

    if t % 2 == 0:
        print('second')
    else:
        print('first')


if __name__ == '__main__':
    main()


Measured memory_bytes: 18544
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	public void run(){
		while(true){
			int d = sc.nextInt();
			int e = sc.nextInt();
			if(d == 0 && e == 0) break;
			calc(d, e);
		}
	}
	public void calc(int d, int e){
		double ans = Double.MAX_VALUE;
		for(int x = 0; x < d/2+1; x++){
			int y = d - x;
			double a = Math.abs(Math.sqrt(x*x + y*y) - e);
			if (a < ans) ans = a;
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 26416
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main(){
    string s;
    cin >> s;
    if(s=="SUN") cout << 7;
    if(s=="SAT") cout << 1;
    if(s=="FRI") cout << 2;
    if(s=="THU") cout << 3;
    if(s=="WED") cout << 4;
    if(s=="TUE") cout << 5;
    if(s=="MON") cout << 6;
    cout << endl;
    return 0;
}

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

int main() {
int R;
  cin >>R;
  if(R<1200){
    cout <<"ABC";
  }
  else if(R>=1200 && R<2800){
    cout <<"ARC";
  }
  else if(R>=2800){
    cout<<"AGC";
  }
    

}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int h, w;
    cin >> h >> w;
    int n = 10;
    VVI d(n, VI(n));
    REP(i,n) REP(j,n) cin >> d[i][j];

    REP(i,n) REP(j,n) REP(k,n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

    int ans = 0;
    REP(i,h) REP(j,w){
        int x;
        cin >> x;
        if (x >= 0) ans += d[x][1];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    
    int i,j=0;
    char a[11],b[11];
    
    scanf("%s",a);
    
    for(i=0;i<strlen(a);i++){
        if(a[i]-'0'==0){
            b[j]='0';
            j++;
        }
        else if(a[i]-'0'==1){
            b[j]='1';
            j++;
        }
        else j--;
        if(j<0){
            j=0;
        }
    }
    
    for(i=0;i<j;i++){
        printf("%c",b[i]);
    }
    printf("\n");
}

Measured memory_bytes: 128
/**
 *   @FileName	d.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 19:23:48
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

 
vector< ll > q;
vector< ll > a;
int x, y;
 
void dfs(int v, int c = -1, int p = -1) {
    if (q[v] != -1) {
        x = v;
        y = p;
        return;
    }
    q[v] = c + 1;
    dfs(a[v], c + 1, v);
}
 
int main() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    q.resize(n, -1);
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    dfs(0);
    if (q[x] >= k) {
        for (int i = 0; i < n; i++) {
            if (q[i] == k) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    else {
        k -= q[x];
        k %= q[y] - q[x] + 1;
        for (int i = 0; i < n; i++) {
            if (q[i] - q[x] == k) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 6340
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, x = ns()
    lim = 51
    total = [int(0) for _ in range(lim)]
    P_total = [int(0) for _ in range(lim)]

    total[0] = 1
    for i in range(1, lim):
        total[i] = total[i - 1] * 2 + 3

    P_total[0] = 1
    for i in range(1, lim):
        P_total[i] = P_total[i - 1] * 2 + 1

    ans = 0
    base = 1
    L = n
    flg = True
    while base != x and L != 0:
        if base + total[L] // 2 <= x and flg:
            base += total[L] // 2
            ans += P_total[L - 1] + 1
            flg = False
        else:
            flg = True
            base += 1
            L -= 1
            if L == 0:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63980
import java.util.Scanner;

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

		long c = n / (a + b);
		long m = n - c * (a + b);
		if(m < a) System.out.println(c * a + m);
		else if(m >= a) System.out.println(c * a + a);
		sc.close();
	}
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

int main()
{
  int n, m;
  while (n = in(), m = in()){
    vector<int> p;
    for (int i = 0; i < n; i++) p.push_back(in());
    p.push_back(0);
    n++;
    vector<int> pp;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        pp.push_back(p[i] + p[j]);
      }
    }
    int maxi = 0;
    sort(pp);
    for (int i = 0; i < pp.size(); i++){
      int v = pp[i] + upper_bound(pp.begin(), pp.end(), m - pp[i])[-1];
      if (v <= m) maxi = max(maxi, v);
    }
    printf("%d\n", maxi);
  }

  return 0;
}

Measured memory_bytes: 9168
#include<cstdio>

int main(){
	int n;
	int a = 100;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		if(a % 20){
			a = a * 1.05 + 1;
		}else{
			a *= 1.05;
		}
	}
	printf("%d000\n", a);
	return 0;
}

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

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

void no(){
	printf("NO\n");
	exit(0);
}

#define N 212345
char s[N], t[N];

int main(){
	int h, w, n, y, x; scanf("%d%d%d%d%d%s%s", &h, &w, &n, &y, &x, s, t);
	int p, q;
	p = y, q = x;
	REP(i, n){
		if(s[i]=='D') p++;
		if(p==h+1) no();
		if(t[i]=='U' && p>1) p--;
	}
	p = y, q = x;
	REP(i, n){
		if(s[i]=='U') p--;
		if(p==0) no();
		if(t[i]=='D' && p<h) p++;
	}
	p = y, q = x;
	REP(i, n){
		if(s[i]=='R') q++;
		if(q==w+1) no();
		if(t[i]=='L' && q>1) q--;
	}
	p = y, q = x;
	REP(i, n){
		if(s[i]=='L') q--;
		if(q==0) no();
		if(t[i]=='R' && q<w) q++;
	}
	printf("YES\n");
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
char s1[10],s2[10];
int main(void)
{
	scanf("%4s%s",s1,s2);
	printf("%s %s\n",s1,s2);
	return 0;
}


Measured memory_bytes: 128
fn read<T: std::str::FromStr>() -> T {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        s.trim().parse().ok().unwrap()
}

fn read_col<T: std::str::FromStr>(n: u32) -> Vec<T> {
        (0..n).map(|_| read()).collect()
}


fn main() {
    let n: i32 = read();
    let v: Vec<i32> = read_col(n as u32);

    let mut min = std::cmp::min(v[0], v[1]);
    let mut max = v[1] - v[0];
    let mut tmp: i32;

    for i in 2..n {
        tmp = v[i as usize] - min;
        max = std::cmp::max(tmp, max);
        min = std::cmp::min(v[i as usize], min);
    }

    println!("{}", max);
}



Measured memory_bytes: 5044
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())
cnt=0

while N>0:
	if N%3==0 or N%5==0:
		N=N-1
	else:
		cnt+=N
		N=N-1
		
print(cnt)

Measured memory_bytes: 9176
N = int(input())
x = [0]*N
aList = [int(x) for x in input().split()]

for i in range(N,0,-1):
    a = aList[i-1]
    b = 2
    c = 0
    while (i*b) - 1 < N:
        if x[(i*b)-1] == 1:
            c += 1
        b+=1
    x[i-1] = int(c%2==0 if a == 1 else c%2==1)

# output
print(sum(x))
for i,y in enumerate(x):
    if y == 1:
        print(i+1, end=' ')

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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    ll h[100005];
    bool ans = true;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int f = 0;
    for(int i = 0; i < n-1; i++){
        if(h[i] == h[i+1]){
            if(h[f] != h[i])f = i;
        }
        else{
            if(h[i]-1 == h[i+1]){
                for(int j = f; j <= i; j++)h[j]--;
            }
            else if(h[i] > h[i+1])h[i]--;
            f = i+1;
        }
    }
    for(int i = 0; i < n-1; i++){
        if(h[i] > h[i+1])ans = false;
    }

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

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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
ll dp[105][100005];
int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];
		ll dp[n];
		dp[0] = 0;dp[1] = abs(arr[1] - arr[0]);
		rep(i, 2, n){
			dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i]-arr[i-2]));
		}
		cout << dp[n-1] ;
	}
}

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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int result=1;
    for(int i=0;i<n-1;i++) if(s[i]!=s[i+1]) result++;
    cout <<result<<endl;

    
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections;

class Program{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(m => int.Parse(m)).ToArray();
        if(input[0]+input[1]==input[2]){
            Console.WriteLine("Yes");
        }else if(input[0]+input[2]==input[1]){
            Console.WriteLine("Yes");
        }else if(input[1]+input[2]==input[0]){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int N;
vi dat;


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}


void update(int i, int k){
    
    i += N-1;
    dat[i] = k;
    
    while (i > 0) {
        i = (i-1)/2;
        dat[i] = gcd(dat[2*i+1],dat[2*i+2]);
    }
    
}



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

    cin >> N;
    int n = N;
    N = 1;
    while (N < n) {
        N *= 2;
    }
    dat.resize(2*N-1,0);
    
    rep(i,n) {
        int a;
        cin >> a;
        update(i,a);
    }
    
    int ans = 0;
    rep(i,N){
        int a = dat[i+N-1];
        update(i,0);
        chmax(ans,dat[0]);
        update(i,a);
    }
    
    cout << ans << endl;
    

    return 0;
}


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

int main(){
    int N, len;
    int flag = 0; //1:false  0:true
    string str, last;
    vector<string> string_v;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> str;
        if(i == 0){
            last = str;
            string_v.push_back(str);
        }else{
            len = last.size();
            //しりとりの条件
            if(last[len-1] != str[0]){
                flag = 1;
            }
            //二回言ってないか
            for(int i = 0; i < string_v.size(); i++){
                if(str == string_v.at(i)) flag = 1;
            }
            last = str;
            string_v.push_back(str);
        }
    }
    if(flag == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, cnt=0, m=0;
    cin >> n;
    ll h, hh;
    cin >> hh;

    for (int i=1; i < n; i++) {
        cin >> h;
        if(h <= hh) cnt++;
        else {
            m = max(m, cnt);
            cnt = 0;
        }
        hh = h;
    }

    cout << max(m, cnt) << endl;

    return 0;
}

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

int main()
{
  int n, l;
  cin >> n >> l;
  string s[110];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  
  sort(s, s+n);
  string stot;
  for (int i = 0; i < n; i++) {
    stot += s[i];
  }
  cout << stot << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  if(a >= 13){
    ans = b;
  }else if(a >= 6 && a <= 12){
    ans = b / 2;
  }else{
    ans = 0;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    string c= to_string(a)+to_string(b);
    int d=stoi(c);
    bool abc=false;
    for(int i=1;i<1000;i++)
    {
        if(d==i*i)
            abc=true;
    }
    if(abc==false)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int p = scanner.nextInt();
		int[] d = new int[m];
		for (int i = 0; i < m; i++) {
			int a = scanner.nextInt();
			d[i] = (a + n - p) % n;
		}
		Arrays.sort(d);
		int ans = Math.min(d[m - 1], n - d[0]);
		for (int i = 0; i < m; i++) {
			if (i != 0)
				ans = Math.min(ans, 2 * (n - d[i]) + d[i - 1]);
			if (i != m - 1)
				ans = Math.min(ans, 2 * d[i] + n - d[i + 1]);
		}
		System.out.println(ans * 100);

	}
}

Measured memory_bytes: 34268
import bisect
N,M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

y = []
for _ in range(M):
    B, C = map(int, input().split())
    y.append([C,B])

y.sort(reverse=True)


ans = 0
py = 0
flg = False
for x in X:
    if flg:
        ans += x
        continue
    
    if x>=y[py][0]:
        ans += x
        flg = True
        continue
    else:
        ans += y[py][0]
        y[py][1] = y[py][1]-1
        if y[py][1] == 0:
            py += 1
            if py == M:
                flg = True

print(ans)                
        
    
    
    


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

ll N, A[100005];
map<ll, ll> A1, A2;

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

	cin >> N;
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
		if (i % 2 == 0) A1[A[i]]++;
		else A2[A[i]]++;
	}

	ll ans1 = 0, ans1x = 0, ans2 = 0, ans2x = 0;
	for (auto x : A1) {
		if (x.second > ans1) {
			ans1 = x.second;
			ans1x = x.first;
		}
	}
	for (auto x : A2) {
		if (x.second > ans2 && x.first != ans1x) {
			ans2 = x.second;
			ans2x = x.first;
		}
	}

	ll ans = N-ans1-ans2;
	
	ans1 = 0, ans1x = 0, ans2 = 0, ans2x = 0;
	for (auto x : A2) {
		if (x.second > ans1) {
			ans1 = x.second;
			ans1x = x.first;
		}
	}
	for (auto x : A1) {
		if (x.second > ans2 && x.first != ans1x) {
			ans2 = x.second;
			ans2x = x.first;
		}
	}	

	ans = min(ans, N-ans1-ans2);

	cout << ans << "\n";

}

Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#define ll long long
#define mp make_pair
using namespace std;
const int mxn=3e5+5;
int n;
ll k;
int a[mxn];
const ll md=1e9+7;
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;++i)scanf("%d",a+i);
	ll ans=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<i;++j)if(a[i]>a[j]){
			ans+=k*(k-1)/2;
			ans%=md;
		}
		for(int j=i+1;j<=n;++j)if(a[i]>a[j]){
			ans+=k*(k+1)/2;
			ans%=md;
		}
	}
	printf("%lld\n",ans);
}

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


int main(){
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5])cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#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 (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;
map<int, vector<int>> g;
map<int, int> color;
int red = 0;
int blue = 0;

void dfs(int cur, int par, int col)
{
    color[cur] = col;
    if (col == 0)
        red++;
    else
        blue++;
    for (auto x : g[cur])
    {
        if (x != par)
        {
            dfs(x, cur, (col + 1) % 2);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 0, 0);
    deque<int> q[3];
    rep(i, 1, n + 1) q[i % 3].push_back(i);
    map<int, int> ans;
    //0:red 1:blue
    if (red <= n / 3)
    {
        rep(i, 1, n + 1)
        {
            if (color[i] == 0)
            {
                ans[i] = q[0].front();
                q[0].pop_front();
            }
            else
            {
                for (int j = 2; j >= 0; j--)
                {
                    if (!q[j].empty())
                    {
                        ans[i] = q[j].front();
                        q[j].pop_front();
                        break;
                    }
                }
            }
        }
    }
    else if (blue <= n / 3)
    {
        rep(i, 1, n + 1)
        {
            if (color[i] == 1)
            {
                ans[i] = q[0].front();
                q[0].pop_front();
            }
            else
            {
                for (int j = 2; j >= 0; j--)
                {
                    if (!q[j].empty())
                    {
                        ans[i] = q[j].front();
                        q[j].pop_front();
                        break;
                    }
                }
            }
        }
    }
    else
    {
        rep(i, 1, n + 1)
        {
            if (color[i] == 0)
            {
                if (!q[1].empty())
                {
                    ans[i] = q[1].front();
                    q[1].pop_front();
                }
                else
                {
                    ans[i] = q[0].front();
                    q[0].pop_front();
                }
            }
            else
            {
                if (!q[2].empty())
                {
                    ans[i] = q[2].front();
                    q[2].pop_front();
                }
                else
                {
                    ans[i] = q[0].front();
                    q[0].pop_front();
                }
            }
        }
    }
    rep(i, 1, n + 1)
    {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 46592
#include <stdio.h>

int main( void )
{
	int number, max_num, min_num, tmp;
	int Num_Cou;
	long sum;

	scanf( "%d", &number );

	sum = 0;
	max_num = 0;
	min_num = 0;

	for( Num_Cou = 0; Num_Cou < number; Num_Cou++ )
	{
		scanf( "%d", &tmp );
		
		if( Num_Cou == 0 )
		{
			max_num = tmp;
			min_num = tmp;
		}
		else
		{
			if( tmp >= max_num )
			{
				max_num = tmp;
			}
			else
			if( tmp <= min_num )
			{
				min_num = tmp;
			}
		}
		
		sum = sum + tmp;
	}

	printf( "%d %d %ld\n", min_num, max_num, sum );

return 0;
}

Measured memory_bytes: 600
// AOJ 2444: Substring
// 2017.10.10 bal4u@uu

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

#define HASHSIZ 600011LL
unsigned long long hash[HASHSIZ+3], *hashend = hash + HASHSIZ;

#define M	1000000007
#define MAX 300000
char s[MAX+5];
unsigned long long hv[MAX+3], bv[MAX+3];

int insert(unsigned long long n)
{
	unsigned long long *p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 0;
		if (++p == hashend) p = hash;
	}
	*p = n;
	return 1;
}

int main()
{
	int n, m, i, l, r, ans;
	char buf[100], *bp;

	fgets(buf, 50, stdin); bp = buf;
	n = atoi(bp); while (*bp >= '0') bp++;
	m = atoi(bp);
	fgets(s, n+2, stdin);
	bv[0] = 1; for (i = 1; i <= n; i++) bv[i] = bv[i-1]*M;
	ans = 0, l = 0, r = 1, hv[0] = 0, hv[1] = s[0];
	while (m-- > 0) {
		fgets(buf, 50, stdin);
		if (*buf == 'R') {
			if (*(buf+1) == '+') {
				if (hv[++r] == 0) hv[r] = hv[r-1]*M + s[r-1];
			} else r--;
		} else {
			if (*(buf+1) == '+') l++; else l--;
		}
		if (insert(hv[r] - hv[l] * bv[r-l])) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11332
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int gcd(int a,int b){
	if(b>a)	swap(a,b);
	while(a%b!=0){
		int tmp=a%b;
		a=b;	b=tmp;
	}
	return b;
}
int main(){
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		int g=gcd(a,b);
		cout<<g<<" "<<a/g*b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
from collections import deque

def main():
    S = deque(input())
    
    Q = int(input())
    count = 1

    for i in range(Q):
        n = input()
        if n == "1":
            #qi[i][0] = 1
            count += 1
        else:
            q= list(n.split())
            if (count % 2 == 1 and q[1] == "1") or(count % 2 == 0 and q[1] == "2"):
                S.appendleft(q[2])
            else:
                S.append(q[2]) 

    if count % 2 == 0:
        S.reverse()
    print(''.join(S))

if __name__ == "__main__":
    main()

Measured memory_bytes: 74328
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const ll N=1e5+5;
const double eps=1e-6;
const int mod=1e9+7;
int main()
{
    char a,b,c,d;
    while(~scanf("%c%c%c%c",&a,&b,&c,&d))
    {
        getchar();
        if(a==b&&b==c||b==c&&c==d)
            puts("Yes");
        else puts("No");
    }
    return 0;
}



Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
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; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll dx[] = { 1, 0 , -1,  0 }, dy[] = { 0, 1, 0, -1 };
ll cb(ll a, ll b);

int main() {
	ll n, k;
	cin >> n >> k;
	
	ll cnt1, cnt2 = 0, ans = 0;

	cnt1 = n / k;

	ans += cnt1;
	if (cnt1 > 1) ans += cb(cnt1, 2) * 6;
	if (cnt1 > 2) ans += cb(cnt1, 3) * 6;

	if (k % 2 == 0) {
		cnt2 = n / (k / 2) - cnt1;
		ans += cnt2;
		if (cnt2 > 1) ans += cb(cnt2, 2) * 6;
		if (cnt2 > 2) ans += cb(cnt2, 3) * 6;
	}
	cout << ans;

	return 0;
}

ll cb(ll a, ll b) {
	ll ans = 1;
	rep(i, b) ans *= (a - i);
	rep(i, b) ans /= (b - i);

	return ans;
}


ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#define N 55
using namespace std;
typedef long long ll;

struct st{ll ct, co, tm;};
ll n, m, s, c[N], d[N], v[N][5005], ans[N];
vector<st> gr[N];
priority_queue<st> pq;

bool operator < (st p, st q) {return p.tm > q.tm;}

int main() {
	ll i, t1, t2, t3, t4;
	cin >> n >> m >> s;
	while(m--) {
		cin >> t1 >> t2 >> t3 >> t4;
		gr[t1].push_back({t2, t3, t4});
		gr[t2].push_back({t1, t3, t4});
	}
	for(i=1; i<=n; i++) cin >> c[i] >> d[i];
	pq.push({1, min(s, 5000LL), 0});
	while(pq.size()) {
		st t = pq.top(); pq.pop();
		if(v[t.ct][t.co]) continue;
		v[t.ct][t.co] = t.tm;
		if(!ans[t.ct]) ans[t.ct] = t.tm;
		for(auto x:gr[t.ct]) {
			if(t.co>=x.co && !v[x.ct][t.co-x.co]) {
				pq.push({x.ct, t.co-x.co, t.tm+x.tm});
			}
		}
		if(t.co+c[t.ct] <= 5000) pq.push({t.ct, t.co+c[t.ct], t.tm+d[t.ct]});
	}
	for(i=2; i<=n; i++) cout << ans[i] << endl;
 	return 0;
}

Measured memory_bytes: 17208
#include <cstdio>
#include <algorithm>
#define HEIGHT 10

using namespace std;

int a[HEIGHT];

void solve(){
	bool f=true;
	int right,left;
	right = left = 0;
	for(int i=0;i<HEIGHT;i++){
		if(right<a[i] && left<a[i]){
			if(right<left){
				left = a[i];
			} else {
				right = a[i];
			}
		} else if(right<a[i]){
			right = a[i];
		} else if(left<a[i]){
			left = a[i];
		} else {
			f = false;
			i = HEIGHT;
		}
	}
	if(f){
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}
			
int main(){
	
	int lp;
	scanf("%d",&lp);
	
	for(int i=0;i<lp;i++){
		for(int j=0;j<HEIGHT;j++){
			scanf(" %d",&a[j]);
		}
		solve();	
	}
	return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len = s.size();
    int cnt=0,a[len+1]={0};
    for(int i=1; i<len; i++)
    {
        if(s[i]==s[i-1]){
            //a[cnt]++;
            cnt++;
            if(s[i]=='0')s[i]='1';
            else if(s[i]=='1')s[i]='0';
        }
        //else cnt++;
    }
    //cnt++;
    //cout<<s<<endl;
    //int ans = *max_element(a,a+cnt);
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 896