akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    long long n,a,b;
    scanf("%lld",&n);
    scanf("%lld",&a);
    scanf("%lld",&b);
    if(((n == 1)&&(a != b)) || b < a){
        printf("0\n");
    }else{
        printf("%lld\n",(n-2)*(b-a)+1);
    }
    return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string s; int dp[2009][2009];
int main() {
	while (cin >> s) {
		int n = s.size();
		for (int i = 0; i < n; i++) dp[i][i + 1] = 1;
		for (int i = 2; i <= n; i++) {
			for (int l = 0; l <= n - i; l++) {
				int r = l + i;
				dp[l][r] = max(dp[l + 1][r], dp[l][r - 1]);
				if (s[l] == s[r - 1]) dp[l][r] = max(dp[l][r], dp[l + 1][r - 1] + 2);
			}
		}
		string ret;
		int pl = 0, pr = n;
		while (pr - pl >= 2) {
			if (s[pl] == s[pr - 1] && dp[pl][pr] == dp[pl + 1][pr - 1] + 2) ret += s[pl], pl++, pr--;
			else if (dp[pl][pr] == dp[pl + 1][pr]) pl++;
			else pr--;
		}
		string ps = ret;
		if (pr - pl == 1) ps += s[pl];
		reverse(ret.begin(), ret.end());
		ps += ret;
		cout << ps << endl;
	}
	return 0;
}

Measured memory_bytes: 16756
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 100005
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	optimizar_io
	int n; cin >> n;
	lli b, c; 
	vector<lli> v(n);
	vector<int> bucket(MAX);
	fore(i, 0, n) {
		cin >> v[i];
		bucket[v[i]]++;
	}
	lli sumTotal = 0;
	fore(i, 0, bucket.size()) sumTotal += (bucket[i] * i);
	
	int q; cin >> q;
	fore(i, 0, q) {
		cin >> b >> c;
		sumTotal -= (b * bucket[b]);
		sumTotal -= (c * bucket[c]);
		bucket[c] += bucket[b];
		bucket[b] = 0;
		sumTotal += (bucket[c] * c);
		cout << sumTotal << endl;
	}
}

Measured memory_bytes: 4436
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <utility>
#include <set>
#include <map>
using namespace std;

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

const int maxn = 3e2+1;
int n, m;
vector<ii> g[maxn];

int d[maxn][maxn][maxn];
const int mod = 1e9+7;

int dp(int r, int g, int b)
{
  int &ret = d[r][g][b];
  if (ret == -1)
    {
      ret = 0;
      int x = max(r, max(g, b));
      if (x == n)
	{
	  ret = 1;
	  //      printf("d[%d][%d][%d] = %d\n", r, g, b, ret);
	  return ret = 1;
	}
      x += 1;
      ret = (ret + dp(x, g, b))%mod;
      ret = (ret + dp(r, x, b))%mod;
      ret = (ret + dp(r, g, x))%mod;
    }
  //      printf("d[%d][%d][%d] = %d\n", r, g, b, ret);

  return ret;
}


int main()
{
  memset(d, -1, sizeof(d));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i)
    {
      for (int j = 0; j <= n; ++j)
	{
	  d[i][i][j] = d[i][j][i] = d[j][i][i] = 0;
	}
    }
  for (int i = 0; i < m; ++i)
    {
      int l, r, x;
      scanf("%d %d %d", &l, &r, &x);
      for (int i = 0; i < r; ++i)
	for (int j = 0; j < r; ++j)
	  {
	    int cnt = 1+(i>=l)+(j>=l);
	    if (cnt != x)
	      d[i][j][r] = d[r][i][j] = d[i][r][j] = 0;
	  }
    }
  printf("%d\n", dp(0, 0, 0));
}


Measured memory_bytes: 106880
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int a = 0;
	int t = 1;
	vector<int>x;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0' + t)a++;
		else {
			x.push_back(a);
			a = 1;
			t = 1 - t;
		}
	}
	if (a)x.push_back(a);
	if (x.size() % 2 == 0)x.push_back(0);
	int c = 0, d = 0;
	int ans = 0, tmp = 0;
	for (int i = 0; i < x.size(); i+=2) {
		int f = i;
		int g = min(2*k+1 + i, (int)x.size());
		while (c < f) {
			tmp -= x[c];
			c++;
		}
		while (d < g) {
			tmp += x[d];
			d++;
		}
		ans = max(ans, tmp);
	}
	
	cout << ans << endl;

	return 0;


}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
int n, rt = 1, mod;
num f[nsz + 5], dp[nsz + 5];
vector<int> g[nsz + 5];
vector<num> pre[nsz + 5], suf[nsz + 5];

num inline modulo(num a) {
    return (a % mod + mod) % mod;
}

void dfs1(int u = rt, int p = 0) {
    f[u] = 1;
    loop (i, g[u].size()) {
        int v = g[u][i];
        if (v == p)  continue;
        dfs1(v, u);
        f[u] *= f[v] + 1;
        f[u] %= mod;
    }
}

void dfs2(int u = rt, int p = 0) {
    int m = (int) g[u].size();
    num f_u = f[u];
    vector<num> &pre = ::pre[u], &suf = ::suf[u];
    pre.resize(m), suf.resize(m);
    loop (i, m) {
        int v = g[u][i];
        pre[i] = (i - 1 >= 0 ? pre[i - 1] : 1) * (f[g[u][i]] + 1) % mod;
    }
    for (int i = m - 1; i >= 0; --i) {
        suf[i] = (i + 1 < m ? suf[i + 1] : 1) * (f[g[u][i]] + 1) % mod;
    }
    dp[u] = modulo(dp[p] - f[p] + f[u]);
    loop (i, m) {
        int v = g[u][i];
        if (v != p) {
            f[u] = (i - 1 >= 0 ? pre[i - 1] : 1) % mod * (i + 1 < m ? suf[i + 1] : 1) % mod;
            dfs2(v, u);
        }
    }
    f[u] = f_u;
}

int main() {
    scanf("%d%d", &n, &mod);
    cont (i, n - 1) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs1();
    dfs2();
    cont (u, n) {
        printf("%lld\n", dp[u]);
    }
}

Measured memory_bytes: 25856
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# include <deque>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int main() {
	ll n=0, k=0, mini = 999999999;
	ll grid[3][3];
	bool flag = false;
	string str;
	cin >> str;
	rep(i, str.size()) {
		if (str[i] == '0')n++;
		else { k++; }
	}
	cout << min(n, k)*2;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        string s = Console.ReadLine().Replace(" ", "");
        string ans = "NO";
        int num = int.Parse(s);
        if (num % 4 == 0) ans = "YES";
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int i,j,n;
string str;

int main(){
  long long ans = 100;
  cin >> str;
  for(int i = 0;i < 26;i++){
    char c = 'a'+i;
    int maxi = 0,count = 0;
    for(int j = 0;j < str.length();j++){
      if(str[j] == c){
        if(count > maxi) maxi = count;
        count = 0;
      }
      else{
        count++;
      }
    }
    if(count > maxi) maxi = count;
    if(maxi < ans) ans = maxi;
  }
  cout << ans << endl;
}


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

using namespace std;

struct Dise
{
  int top;
  int bottom;
  int north;
  int east;
  int south;
  int west;
  void toNorth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = s, bottom = n, north = t, south = b;
  }
  void toEast()
  {
    int t = top, b = bottom, e = east, w = west;
    top = w, bottom = e, east = t, west = b;
  }
  void toSouth()
  {
    int t = top, b = bottom, n = north, s = south;
    top = n, bottom = s, north = b, south = t;
  }
  void toWest()
  {
    int t = top, b = bottom, e = east, w = west;
    top = e, bottom = w, west = t, east = b;
  }
  void spin()
  {
    int n = north, e = east, s = south, w = west;
    north = w, east = n, south = e, west = s;
  }
  void toTop(int a)
  {
    if (a == north)
      toSouth();
    else if (a == east)
      toWest();
    else if (a == south)
      toNorth();
    else if (a == west)
      toEast();
    else if (a == bottom)
    {
      toNorth();
      toNorth();
    }
  }
} d;

int main()
{
  cin >> d.top >> d.south >> d.east >> d.west >> d.north >> d.bottom;
  int q, a, b;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> a >> b;
    d.toTop(a);
    while (b != d.south)
      d.spin();
    cout << d.east << endl;
  }
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		
		String ABCD = scan.next();
		
		/*StringBuilder sb = new StringBuilder();//+ -　連結
		sb.append(ABCD);*/
		
		int []keisancount = new int[1];//式一つのみの結果を出力するため
		keisancount[0] =0;
		
		
		tashihiki(ABCD,"+",ABCD.length(),keisancount);//今回は文字列は４
		tashihiki(ABCD,"-",ABCD.length(),keisancount);
		
		
		
		
		
	}
	
	public static int keisan (String shiki){
		int goukei = 0;
		goukei += Integer.valueOf(shiki.substring(0, 1));//最初の数字は入れておく
	
		
		for(int i = 0;i<shiki.length()-1;i++){
			if(shiki.substring(i, i+1).equals("+")){
				goukei += Integer.valueOf(shiki.substring(i+1, i+2));
				
			}else if(shiki.substring(i, i+1).equals("-")){
				goukei -= Integer.valueOf(shiki.substring(i+1, i+2));
			}
		}
		
		
		
		return goukei;
		
		
	}
	
	
	

	
	
	
	
	
	public static void tashihiki(String S,String tashihiki,int mojiretu,int[] keisancount){
		if(mojiretu ==2){
			if(tashihiki.equals("+")){
				String kekka = S.substring(0, mojiretu-1)+"+"+S.substring(mojiretu-1, S.length());
				
				//System.out.println(kekka);
				if(keisan(kekka)==7&&keisancount[0]==0){
					System.out.println(kekka+"=7");
					keisancount[0]=1;
				}
				
				
			}else if(tashihiki.equals("-")){
				String kekka2 = S.substring(0, mojiretu-1)+"-"+S.substring(mojiretu-1, S.length());
				
				//System.out.println(kekka2);
				if(keisan(kekka2)==7&&keisancount[0]==0){
					System.out.println(kekka2+"=7");
					keisancount[0]=1;
				}
				
			
				
			}
			
		}else{
			if(tashihiki.equals("+")){
				String S1 = S.substring(0, mojiretu-1)+"+"+S.substring(mojiretu-1, S.length());
				tashihiki(S1,"+",mojiretu-1,keisancount);
				tashihiki(S1,"-",mojiretu-1,keisancount);
			}else if(tashihiki.equals("-")){
				String S2 = S.substring(0, mojiretu-1)+"-"+S.substring(mojiretu-1, S.length());
				tashihiki(S2,"+",mojiretu-1,keisancount);
				tashihiki(S2,"-",mojiretu-1,keisancount);	
			}
			
			
		}
		
		
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}

typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int H, W;
//maps[y][x];
int state[55][55];
int maps[55][55][55][55];

struct Data{
	P t, k;
	int cost;
	Data(P _t, P _k, int c){
		t = _t;
		k = _k;
		cost = c;
	}Data(){}
};

int bfs(Data d){
	queue<Data> que;
	que.push(d);
	int ans = -1;
	while(que.size()){
		Data d = que.front(); que.pop();
		P taka = d.t;
		P kazu = d.k;
		int cost = d.cost;
		if(cost >= 100)break;

		if(maps[taka.first][taka.second][kazu.first][kazu.second] <= cost)continue;
		maps[taka.first][taka.second][kazu.first][kazu.second] = cost;

		if(taka.first == kazu.first && taka.second == kazu.second){
			ans = cost;
			break;
		}
		for(int i = 0; i < 4; i++){
			int ntx, nty, nkx, nky;
			ntx = taka.first + dx[i];
			nty = taka.second + dy[i];
			nkx = kazu.first - dx[i];
			nky = kazu.second - dy[i];
			if(ntx <= -1 || nty <= -1){
				ntx = taka.first;
				nty = taka.second;
			}
			if(nkx <= -1 || nky <= -1){
				nkx = kazu.first;
				nky = kazu.second;
			}
			if(state[nky][nkx] != 0){
				nkx = kazu.first;
				nky = kazu.second;
			}
			if(state[nty][ntx] != 0){
				ntx = taka.first;
				nty = taka.second;
			}
			///cout << ntx << "," << nty << " " << nkx << "," << nky << endl;
			que.push(Data(P(ntx, nty), P(nkx, nky), cost+1));
		}
	}
	return ans;
}


int main(void){
	
	while(cin >> W >> H, W|H){
		int x, y;
		fill_n(*state, 55*55, -1);
		fill_n(***maps, 55*55*55*55, INF);
		cin >> x >> y;
		x--;y--;
		P taka = P(x,y);
		cin >> x >> y;
		x--;y--;
		P kazu = P(x,y);
		rep(i, H)rep(j, W){
			cin >> state[i][j];
		}
		int ans = bfs(Data(taka, kazu, 0));
		if(ans < 0 || ans >= 100){
			cout << "NA" << endl;
			continue;
		}
		cout << ans << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 38156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, int, int, int, int, int, int, int>T;
#define PI 3.14159265358979
const int MAX = 510000;
const int MOD = 1000000007;
const int INF=100000000;


int main(){
  int K,S;
  cin>>K>>S;
  ll ans=0ll;
  rep(i,K+1){
  	rep(j,K+1){
      int z=S-i-j;
      if(0<=z&&z<=K){ans++;}
    }
  }
  cout<<ans;
}








Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    int a;
    for (int i = 0;i < N;i++) cin >> a;
    int ans = (N - K) / (K - 1) + 1;
    if ((N - K) % (K - 1) != 0) ans++;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
class SegmentTree(object):
    def __init__(self,A,dot,e):
        n=2**((len(A)-1).bit_length())
        self.__n=n
        self.__dot=dot
        self.__e=e
        self.__node=[e]*(2*n-1)
        for i in range(len(A)):
            self.__node[n+i-1]=A[i]
        for i in range(n-2,-1,-1):
            self.__node[i]=dot(self.__node[2*i+1],self.__node[2*i+2])

    def update(self,i,c):
        i+=self.__n-1
        node=self.__node
        node[i]=c
        while(i!=0):
            i=(i-1)//2
            node[i]=self.__dot(node[2*i+1],node[2*i+2])

    def __get_range(self,l,r):
        if l>=r: return [],[]
        Left,Right=[],[]
        n=self.__n
        l+=n-1; r+=n-2
        while(l<r):
            if l%2==0:
                Left.append(l)
            if r%2==1:
                Right.append(r)
                r-=1
            l=l//2; r=(r-1)//2
        if l==r:
            if l%2==0: Left.append(l)
            else: Right.append(l)
        return Left,Right

    def sum(self,l,r):
        Left,Right=self.__get_range(l,r)
        res=self.__e
        for i in Left+Right[::-1]:
            res=self.__dot(res,self.__node[i])
        return res

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,q=map(int,input().split())
    A=[(1<<31)-1]*n
    tree=SegmentTree(A,min,INF)
    for _ in range(q):
        c,x,y=map(int,input().split())
        if c==0: tree.update(x,y)
        else: print(tree.sum(x,y+1))
resolve()


Measured memory_bytes: 10344
#include<stdio.h>
int main()
{
    int n,i,j,p,s,sum1=0,sum2=0,sum,t;
    int a[100];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }

    for(j= 0; j < n; j++)
        for(p= j + 1; p< n; p++)
            if(a[j]<a[p])
            {
                t = a[j];
                a[j]=a[p];
                a[p]= t;
            }

    for(s=0; s<n; s++)
    {
        if(s%2==0)
            sum1+=a[s];
        else if(s%2==1)
            sum2+=a[s];
    }
    sum=sum1-sum2;
    printf("%d",sum);

}


Measured memory_bytes: 128
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: u32 = sc.read();
    let b: u32 = sc.read();
    let c: u32 = sc.read();
    let d: u32 = sc.read();
    let e: u32 = sc.read();
    let f: u32 = sc.read();
    let mut a_conc = 0.0;
    let mut a_ws: u32 = 0;
    let mut a_sugar: u32 = 0;
    for i in 0..f {
        for j in 0..f {
            let water = 100*a*i+100*b*j;
            if water > f {
                break;
            }
            for ii in 0..f {
                for jj in 0..f {
                    let sugar = c*ii+d*jj;
                    if water + sugar <= f && sugar <= water/100*e {
                        let conc = 100.0 * sugar as f32 / (water as f32 + sugar as f32);
                        if conc >= a_conc {
                            a_conc = conc;
                            a_ws = water+sugar;
                            a_sugar = sugar;
                        }
                    }
                }
            }
        }
    }
    println!("{} {}", a_ws, a_sugar);
}

// Thanks, kenkoooo(https://kenkoooo.hatenablog.com/entry/2019/05/07/101033)
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=300005,INF=1<<30;
int prime[MAX];//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++){
        if(i%7==1||i%7==6) is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(300000);
    while(1){
        int N;cin>>N;
        if(N==1) break;
        vector<int> ans;
        
        for(int i=1;i<=N;i++){
            if(is_prime[i]&&N%i==0) ans.push_back(i);
        }
        
        cout<<N<<":";
        
        for(int p:ans) cout<<" "<<p;
        cout<<endl;
    }
}



Measured memory_bytes: 3540
#include<stdio.h>

int main(void){
	
	int x,y,temp;
	int num[10];
	
	for(x=0;x<10;x++){
		scanf("%d",&num[x]);
		for(y=x;0<y;y--){
			if(num[y]>num[y-1]){
				temp=num[y-1];
				num[y-1]=num[y];
				num[y]=temp;
			}
			else break;
		}
	}
	
	printf("%d\n%d\n%d\n",num[0],num[1],num[2]);
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#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--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll p[60], s[60], N, X;

ll bu(ll N,ll X) {
	if (N == 0 and X == 1)return 1;
	if (X <= 1)return 0;
	if (X == s[N]) return p[N];
	ll ans = 0;
	X--;
	ans += bu(N - 1, min(s[N - 1], X));
	X -= s[N - 1];
	if (X > 0) {
		X--;
		ans++;
		ans += bu(N - 1, min(s[N - 1], X));
	}
	return ans;
}
int main() {
	p[0] = 1;
	s[0] = 1;
	cin >> N >> X;
	REP(i, N)p[i + 1] = p[i] * 2 + 1;
	REP(i, N)s[i + 1] = s[i] * 2 + 3;
	cout << bu(N, X) << endl;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    long long ans = 0;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    for (int i = 0; i < n; i++) {
        long long l = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        l--;
        if (l >= 0) {
            long long r = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
            if (r != c.size()) {
                ans += (l + 1) * (n - r);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
x1, y1, x2, y2 = map(int, input().split())

x = x2 - x1
y = y2 - y1
dx = y
dy = x

x3 = x2-dx
y3 = y2+dy
x4 = x1-dx
y4 = y1+dy

print(x3, y3, x4, y4)


Measured memory_bytes: 9092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next() + "$";
            int pos = 0;
            long res = 0;
            while (s.charAt(pos) != '$') {
                int a = 0;
                while (s.charAt(pos) == '<') {
                    ++pos;
                    ++a;
                }
                int b = 0;
                while (s.charAt(pos) == '>') {
                    ++pos;
                    ++b;
                }
                int c = Math.min(a, b);
                int d = Math.max(a, b);
                res += c * (long) (c - 1) / 2;
                res += d * (long) (d + 1) / 2;
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 29580
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main()
{
	long M,N,ans;

	cin >> N >>M;
	ans=0;

	if(M>=2*N){
		ans=N+(M-2*N)/4;
	}else{
		ans=M/2;
	}

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


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    
    int n, k, q;
    cin >> n >> k >> q;

    map<int, int> m;
    rep(i, q) {
        int a;
        cin >> a;
        m[a - 1]++;
    }

    rep(i, n) {
        // cout << i << " " << m[i] << endl;
        if (m[i] + k > q) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
	int n, W; scanf("%d %d", &n, &W);
	vector<int> a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a.begin(), a.end());
	int sum = 0; for (int i = 0; i < n; i++) sum += a[i];
	vector<vector<mint>> dp(2, vector<mint>(W + 1));
	int cur = 0;
	int nxt = 1;
	dp[0][0] = 1;
	mint res = 0;
	for (int i = n - 1; i >= 0; i--) {
		fill(dp[nxt].begin(), dp[nxt].end(), 0);
		for (int j = 0; j <= W; j++) {
			dp[nxt][j] += dp[cur][j];
			if (j + a[i] <= W) dp[nxt][j + a[i]] += dp[cur][j];
		}
		sum -= a[i];
		int lf = W - sum - a[i];
		int rg = W - sum; if (i) rg -= a[i - 1];
		//cout << lf << " " << rg << endl;
		for (int j = max(lf + 1, 0); j <= min(rg, W); j++) res += dp[nxt][j];
		swap(cur, nxt);
	}
	cout << res.x << "\n";
    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;

    vector<vector<int>> v(n, vector<int>(n, 1<<30));
    for(int i = 0; i < n; i++)  v[i][i] = 0;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a][b] = 1;
    }

    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(v[i][k] == 1<<30 || v[k][j] == 1<<30)   continue;
                v[i][j] = min(v[i][j], v[i][k]+v[k][j]);
            }
        }
    }

    vector<int> ans[n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(v[i][j] != 1<<30 && v[j][i] != 1<<30)    ans[i].push_back(j);
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < ans[i].size(); j++){
            cout << ans[i][j]+1 << " \n"[j+1==ans[i].size()];
        }
    }
    
    return 0;
}


Measured memory_bytes: 3972
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i = 0; i < n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	
 
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
 
		if (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}



int main(){
	string s; cin >> s;
	int Q; cin >> Q;
	string forw = "", bac = "";
	bool flg = 0;

	for (int i = 0; i < Q; i++){
		int num; cin >> num;
		if (num == 1){
			flg = !flg;
		} else {
			int f; char c; cin >> f >> c;
			if (flg && f == 1){
				bac += c;
			} else if (flg && f == 2){
				forw += c;
			} else if (!flg && f == 1){
				forw += c;
			} else if (!flg && f == 2){
				bac += c;
			}
		}
	}

	reverse(forw.begin(), forw.end());
	string res = forw + s + bac;
	if (flg == 0){
		cout << res << endl;
	} else {
		reverse(res.begin(), res.end());
		cout << res << endl;
	}
}




Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

class Dice {
    array<int, 6> dice;

    void _roll(int a, int b, int c, int d)
    {
        int tmp = dice[a];
        dice[a] = dice[b];
        dice[b] = dice[c];
        dice[c] = dice[d];
        dice[d] = tmp;
    }

public:
    Dice(int d1, int d2, int d3, int d4, int d5, int d6)
    {
        dice[0] = d1;
        dice[1] = d2;
        dice[2] = d3;
        dice[3] = d4;
        dice[4] = d5;
        dice[5] = d6;
    }

    int top()
    {
        return dice[0];
    }

    void roll(char dir)
    {
        switch (dir) {
        case 'S':
            _roll(0, 1, 5, 4);
            _roll(0, 1, 5, 4);
        case 'N':
            _roll(0, 1, 5, 4);
            break;
        case 'E':
            _roll(0, 2, 5, 3);
            _roll(0, 2, 5, 3);
        case 'W':
            _roll(0, 2, 5, 3);
            break;
        }
    }

    int right(int _top, int _front)
    {
        for (size_t i = 0; i < 6; i++) {
            for (size_t j = 0; j < 4; j++) {
                if (dice[0] == _top && dice[1] == _front)
                    goto out;

                _roll(1, 2, 4, 3);
            }

            if (i % 2) {
                _roll(0, 1, 5, 4);
            } else {
                _roll(0, 2, 5, 3);
            }
        }

    out:
        return dice[2];
    }
};

int main()
{
    array<int, 6> d;
    for (auto&& i : d) {
        cin >> i;
    }
    Dice dice(d[0], d[1], d[2], d[3], d[4], d[5]);

    // string str;
    // cin >> str;
    // for (auto&& c : str) {
    //     dice.roll(c);
    // }

    // cout << dice.top() << endl;

    int q;
    cin >> q;

    for (size_t i = 0; i < q; i++) {
        int top, front;
        cin >> top >> front;

        cout << dice.right(top, front) << endl;
    }
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = input[0];
            var K = input[1];

            var i = N % K;
            Console.WriteLine(Math.Min(i, K - i));
        }
    }
}


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

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = n - 1; i < (int)n; --i)
#define FOR(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define RFOR(i, l, r) for (int i = (int)(r); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vector<double> v(n);
    REP(i, n) cin >> v[i];

    sort(all(v));

    double ans = v[0];
    FOR(i, 1, n) {
        ans = (ans + v[i]) / 2.0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000

const int maxn = 1e5 + 10;
int a,s[10005];

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

	int h, w, n; 
	cin >> h>>w;
	cin>>n;
	
	vi v;
	rep(i, n)
	{
		cin >> a;
		rep(j, a) v.pb(i + 1);
	}

	int field[105][105];

	rep(i, h*w)
	{
		if ((i / h) % 2 == 0) // 木数列
		{
			field[i % h][(i / h)] = v[i];
		}
		else 
		{
			field[h-1-(i % h)][(i / h)] = v[i];
		}
	}

	rep(i, h)
	{
		rep(j, w)cout << field[i][j] << " ";
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 512
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int a[n];
  queue<int> b;
  bool flag = false;
  int len = n;
  int cnt = 0;
  rep(i,n) cin >> a[i];
  while(!flag){
    flag = true;
    rep(i,len){
      if(a[i] <= i+1){
        b.push(a[i]);
        // printf("%d\n", a[i]);
      }
      else{
        flag = false;
        cnt++;
      }
    }
    len -= cnt;
    cnt = 0;
    rep(i,len){
      a[i] = b.front(); b.pop();
    }
    // printf("\n");
  }

  cnt = 1;
  rep(i,len){
    if(a[i] == cnt) cnt++;
  }
  if(cnt == 1) printf("-1\n");
  else printf("%d\n", n-cnt+1);

  return 0;
}


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

int main() {
    ll n,l=1e6,c=0,i; cin>>n; ll a[n];
    for(i=0;i<n;i++) 
    {
        cin>>a[i];
        l=min(l,a[i]);
        if (l==a[i]) {c++;}
    }
    cout<<c;
	return 0;
}

Measured memory_bytes: 5124
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    reachable_from_1 = set()
    reachable_to_N = []
    ships = []
    for _ in range(M):
        a, b = LI()
        ships.append((a, b))
        if b == N:
            reachable_to_N.append(a)
        if a == 1:
            reachable_from_1.add(b)
    ans = False
    for n in reachable_to_N:
        if n in reachable_from_1:
            ans = True
    if ans:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()



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

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

    if (s == "Sunny")
        puts("Cloudy");
    else if (s == "Cloudy")
        puts("Rainy");
    else
        puts("Sunny");
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		List<Food> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			list.add(new Food(sc.nextLong(), sc.nextLong()));
		}
		Collections.sort(list);
		long score1 = 0, score2 = 0;
		for(int i = 0; i < n; i++) {
			Food food = list.get(i);
			if (i % 2 == 0)  score1 += food.p1;
			else score2 += food.p2;
		}
		out.println(score1 - score2);
		
		out.close();
	}
	static class Food implements Comparable<Food> {
		Long p1;
		long p2;
		Long sum;
		Food(long p1, long p2){
			this.p1 = p1;
			this.p2 = p2;
			this.sum = p1 + p2;
		}
		
		public int compareTo(Food o) {
			return -this.sum.compareTo(o.sum);
		}
		
	}


static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




Measured memory_bytes: 36036
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	if (S.size() == 2)cout << S << endl;
	else {
		reverse(S.begin(), S.end());
		cout << S << endl;
	}
}

Measured memory_bytes: 3560
#include <algorithm>
#include <bits/stdc++.h>
#include <deque>

using ll = long long;
using namespace std;

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

    deque<char> q;

    for (char c : s) q.push_back(c);
    bool flip = false; //dequeueで前からか後ろからどっちに入れる間か判定するためのFlag
    
    int Q;
    cin >> Q;

    for(int i = 0; i < Q; i++){
        int ty;
        cin >> ty;
        if(ty == 1){
            flip = !flip;
        }else {
            int f;
            char c;
            cin >> f >> c;
            if(flip){//フリップされているときは逆順のとき正順になりまたその逆にもなる
                f = 3-f;
            }
            if(f == 1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }

        }
    }

    if(flip) reverse(q.begin(),q.end());
    string ans;
    for(char c : q) ans+=c;

   cout << ans << endl; 


    return 0;
}



Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_geneous = 0; ngtkana_is_geneous < n; ngtkana_is_geneous++)
#define rep(i, begin, end) for(int i = begin; i < end; i++)

#define LOCAL
using std::to_string;
auto to_string(std::string s) -> std::string {
  return '"' + s + '"';
}
auto to_string(char c) -> std::string {
  return "'" + std::string{c} + "'";
}
auto to_string(const char* s) -> std::string {
  return to_string((std::string) s);
}
auto to_string(bool b) -> std::string {
  return (b ? "true" : "false");
}
template <typename T, typename U>
auto to_string(std::pair<T, U> p) -> std::string {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <size_t N>
auto to_string(std::bitset<N> bs) -> std::string {
  std::string res{};
  for (size_t i = 0; i < N; i++)
    res.insert(res.begin(), bs.test(i) ? '1' : '0');
  return res;
}
template <typename T>
auto to_string(T v) -> std::string {
  bool flg = false;
  std::string res = "{";
  for (auto const&x : v) {
    if (flg) res += ", ";
    else flg = true;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  std::cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template <typename T>
auto make_vector(size_t sz, T t) {
  return std::vector<T>(sz, t);
}
template <size_t N, typename T, typename U, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz, U u) {
  return make_vector(sz, T(u));
}
template <size_t N, typename T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz) {
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args, std::enable_if_t<
  N != 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t a, Args... args) {
  return make_vector(a, make_higher_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s, t; std::cin >> s >> t;
  int n = s.length();
  int sz = 26;
  auto ss = s + s;
  auto prv  = std::vector<int>(sz, -1);
  auto move = make_higher_vector<2, int>(n + n, sz, -1);
  for (int i = n + n - 1; i >= 0; i--)
  {
    auto crr = ss.at(i) - 'a';
    rep(j, 0, sz)
    {
      if (prv.at(j) == -1) continue;
      at(move, i, j) = prv.at(j) - i;
    }
    prv.at(crr) = i;
  }
  long long pos = -1;
  for (auto c : t)
  {
    int x = c - 'a';
    auto dif = move.at((pos + n) % n).at(x);
    if (dif == -1)
    {
      std::cout << -1 << std::endl;
      return 0;
    }
    pos += dif;
  }
  std::cout << pos + 1 << std::endl;
  return 0;
}

Measured memory_bytes: 27216
#include<iostream>

int main() {
	using namespace std;
	int n, max, num,count = 1;
	cin >> n;
	cin >> max;
	for (int i = 1; i < n; i++) {
		cin >> num;
		if (num >= max) {
			max = num;
			count++;
		}

	}
	cout << count << endl;
}

Measured memory_bytes: 256