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

int main()
{
    string S;
    long long K;
    cin >> S;
    cin >> K;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] == '1') {
            if(K == i + 1) {
                cout << "1" << endl;
                return 0;
            }
        } else {
            cout << S[i] << endl;
            return 0;
        }
    }
    return 0;
}


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


int main(){
    map<string, int> m;
    string s;

    while (cin >> s){
	transform(s.begin(), s.end(), s.begin(), ::tolower);
	map<string, int>::iterator i = m.find(s);
	if (i == m.end()) m.insert(pair<string, int>(s, 1));
	else (*i).second++;
    }
    pair<string, int> freq("", 0);
    string len = "";
    for (map<string, int>::iterator i = m.begin(); i != m.end(); i++){
	if ((*i).first.size() > len.size()) len = (*i).first;
	if ((*i).second > freq.second){
	    freq.first = (*i).first;
	    freq.second = (*i).second;
	}
    }

    cout << freq.first << " " << len << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,x,y,dist[2005]={};
	cin>>n>>x>>y;
	for(int i=1;i<n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			dist[min((j-i),abs(x-i)+1+abs(y-j))]++;
		}
	}
	for(int i=1;i<n;i++)
	{
		cout<<dist[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import itertools

def get_index(l,x):
    return [i for i, _x in enumerate(l) if _x == x]

N,A,B,C=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(N):
    data.append(int(input()))
target=[A,B,C]

ans=float("inf")
for j in (list(itertools.product(["none","A","B","C"],repeat=N))):
    if set(j) >= {"A","B","C"}:
        score=(j.count("A")-1)*10 + (j.count("B")-1)*10 + (j.count("C")-1)*10
        score_a=sum([data[k] for k in (get_index(j,"A"))])
        score_b=sum([data[l] for l in (get_index(j,"B"))])
        score_c=sum([data[m] for m in (get_index(j,"C"))])
        score=abs(A-score_a)+abs(B-score_b)+abs(C-score_c)+score
        if score < ans:
            ans=score
print(ans)   

Measured memory_bytes: 10996
class Tree():
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append(e[1] - indexed)
            self.tree[e[1] - indexed].append(e[0] - indexed)

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.order = []
        self.order.append(root)
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj]

import sys
input = sys.stdin.readline

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]

C = list(map(int, input().split()))
C.sort(reverse=True)

res = [None for _ in range(N)]
t = Tree(N, E)
t.setroot(0)

for i in range(N):
    res[t.order[i]] = C[i]

print(sum(C) - max(C))
print(*res)

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int n=B-A;
    int m=C-A;
    if(n>0){
        if(0<m&&m<n){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
    else{
        if(n<m&&m<0){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (pp(ll) p1, pp(ll) p2){
        return p1.ff >= p2.ff;
    }
};
map<pair<ll,pp(ll)>,ll> dp;
ll n;
ll rec(ll i, ll money, ll arr[], ll stocksleft){
    if(i == n){
        return money;
    }
    if(dp.count({i,{money,stocksleft}}) != 0) return dp[{i,{money,stocksleft}}];

    ll ans = 0;
    for(ll j = 0;j<=stocksleft;j++){
        ans = max(ans, rec(i+1,money+arr[i]*j,arr, stocksleft-j));
    }
    ll maxbuy = (money/arr[i]);
    for(ll j = 1;j<=maxbuy;j++){
        ans = max(ans, rec(i+1,money-j*arr[i],arr, stocksleft+j));
    }
    return dp[{i,{money,stocksleft}}] = ans;
}

int main(){
    FIO;
    cin >> n;
    ll arr[n]; forn(i,0,n) cin >> arr[i];
    //memset(dp,-1,sizeof(dp));
    ll currp = 1000;
    //ll ans = rec(0,1000,arr,0);
    ll ans = 1000;
    ll minc = INT_MAX;
    ll amount = 1000;
    ll stocks = 0;
    set<ll> s;
    ll i = 0;
    while(i < n){
        ll j = i+1;
        while(j < n && arr[j] >= arr[j-1]){
            j++;
        }
        j--;
        ll stocks = (amount/arr[i]);
        amount = (amount - stocks*arr[i]);
        amount += (stocks*arr[j]);
        i = j+1;
        //dbg2(i,amount);
        //dbg(stocks);
    }
    cout << amount << endl;
    return 0;
}


Measured memory_bytes: 3652
import           Data.Function (on)

main :: IO ()
main = print . solve . map fromChar =<< getLine

data Tile =
  Black | White
  deriving (Eq)

fromChar :: Char -> Tile
fromChar '0' = Black
fromChar '1' = White
fromChar _   = undefined

solve :: [Tile] -> Int
-- solve tiles = min (length $ filter not $ zipWith (==) goal1 tiles) (length $ filter not $ zipWith (==) goal2 tiles)
solve tiles = (min `on` (\goal -> length $ filter not $ zipWith (==) goal tiles)) goal1 goal2

goal1, goal2 :: [Tile]
goal1 = cycle [Black, White]
goal2 = cycle [White, Black]


Measured memory_bytes: 7164
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include <algorithm>
using namespace std;
 
int main(){
  long long A,B,K;
  cin >> A >> B >> K;
  if(K <= A){
    cout << A-K << " " << B;
    return 0;
  }
  if(A < K && K <= A+B){
    cout << 0 << " " << A+B-K;
    return 0;
  }
  else{
    cout << 0 << " " << 0;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC112
{
    class Program
    {
        static void Main(string[] args)
        {
            int n=int.Parse(Console.ReadLine());
            if (n==1)
            {
                Console.WriteLine("Hello World");
            }
            else { int a= int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                Console.WriteLine(a+b);
                
            }
            
        }
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back
#define fst first
#define snd second

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void solve() {

}

int main() {
  ll A, B, V , W, T;
  cin >> A >> V >> B >> W >> T;
  ll dir = 1;
  if( A == B ) {
    puts("YES");
  } else {
    if( A > B ) dir = -1;
    ll sA = A, eA = A + V * dir * T;
    ll sB = B, eB = B + W * dir * T;
    if( sA > eA ) swap(sA,eA);
    //cout << sA << " - " << eA << endl;
    //cout << sB << " - " << eB << endl;

    if(  ( sA <= eB && eB <= eA) )
      { puts("YES"); }
    else puts("NO");
  }
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const int N = 2e5+5;
 
struct edge{
	int x,y,d;
}a[N];
int n,h,w,c[N],sz[N],fa[N];
LL ans;

int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}

int main(){
	scanf("%d%d%d",&n,&h,&w);
	rep(i,1,n)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].d),a[i].y+=h;
	sort(a+1,a+n+1,[](edge x,edge y){return x.d>y.d;});
	
	rep(i,1,h+w)fa[i]=i,c[i]=0,sz[i]=1;
	rep(i,1,n){
		int x = find(a[i].x), y = find(a[i].y);
		if(x!=y){
			fa[x] = y, c[y] += c[x], sz[y] += sz[x];
		}
		if(c[y]<sz[y]) c[y]++, ans+=1ll*a[i].d;
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4480
import collections
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
S = [input() for i in range(N)]
# print(S)
S_new = []
for s in S:
    S_new.append(''.join(sorted(s)))
# print(S_new)
c = collections.Counter(S_new)
# print(c)
cnt = 0
for num in c.values():
    if num > 1:
        if num == 2:
            cnt += 1
        else:
            cnt += comb(num, 2)# a = comb(n, r)
print(cnt)

Measured memory_bytes: 27164
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n,k,q;
	cin>>n>>k>>q;
	
	vi a(n,0);
	REP(i,q){
		int aa;
		cin>>aa;
		a[aa-1]++;
	}
	
	REP(i,n){
		int sco=k-(q-a[i]);
		cout<<((sco>0)?"Yes":"No")<<endl;
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n;
map<char, int> mp[50];

signed main() {
  cin >> n;
  rep(i, 0, n) {
    string s;
    cin >> s;
    rep(j, 0, s.length()) {
      mp[i][s[j]]++;
    }
  }
  rep(i, 0, 26) {
    int mn = 1145141919;
    rep(j, 0, n) {
      mn = min(mn, mp[j][(char)('a' + i)]);
    }
    rep(j, 0, mn) {
      cout << (char)('a' + i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	x := scanString()
	ans := len(x)
	cnt := 0
	for _, r := range x {
		if r == 'S' {
			cnt++
		} else if r == 'T' && cnt > 0 {
			cnt--
			ans -= 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1152
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
int main() {
	cin >> n;
	string t;
	cin >> s >> t;
	if (s == t) {
		cout << n << endl;
		return 0;
	}
	ll cnt = 0;
	ll p = -1;
	rep(i, n) {
		ll tmp = cnt;
		rep(j, n - i) {
			if (s[i + j] != t[j]) {
				++cnt;
				break;
			}
		}
		if (tmp == cnt)break;
	}
	cout << n+cnt << endl;
}


Measured memory_bytes: 256
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))

x0, x1 = 0, 10**9
while x0 + 1  < x1:
  x = (x0+x1)//2
  suma=0
  for i in a:
    if i%x==0:
      suma+=(i//x)-1
    else:
      suma += (i//x)
    
  if suma > k:
    x0 = x
  else:
    x1 = x
print(x1)


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

int main(void){
    int N;
    cin>>N;
    vector <int> a(N,0);
    vector <int> b(N,0);

    for(int i=0;i<N;i++){
        cin>>a[i];
        b[i]=i+1;
    }

    int count=0;
    for(int j=0;j<N;j++){
        if(a[j]!=b[j]){
            count++;
        }
        
    }

    if(count==0){
        cout<<"YES"<<endl;
    } else if(count==2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, k;
    cin >> n >> k;
    
    string s;
    cin >> s;
    v_int done(n);
    vector<pii> a;

    irep(i,n)  {
        if(done[i]) { continue; }
        int sum = 1;
        int j = i;
        while(i+1 < n && s[i] == s[i+1]) {
            sum++; i++;
        }
        for(int k = j; k <= i; k++) {
            done[k] = 1;
        }
        a.push_back(pii(sum,s[i]-'0'));
    }
    
    int r = 0;
    int ki = 0;
    int sum = 0;
    int ans = -1;
    n = a.size();
    irep(l, n) {
        while(r < n && ki < k) {
            sum += a[r].fi;
            if(!a[r].se) { ki++; }
            r++;
        }
        if(r<n && a[r].se) { 
            chmax(ans,sum+a[r].fi);
        } else {
            chmax(ans,sum);
        }
        if(l == r) {
            r++;
        } else {
            if(!a[l].se) {
                ki--;
            }
            sum-=a[l].fi;
        }
    }
    cout << ans << endl;
    return 0;
}
/*atcoder*/


Measured memory_bytes: 4868
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int x1,y1,x2,y2;
  scanf("%d",&x1);
  scanf("%d",&y1);
  scanf("%d",&x2);
  scanf("%d",&y2);
  int tx = x2-x1;
  int ty = y2-y1;
  int ttx = tx;
  int tty = ty;
  tx = -tty;
  ty = ttx;
  int x3 = x2+tx;
  int y3 = y2+ty;
  ttx = tx;
  tty = ty;
  tx = -tty;
  ty = ttx;
  int x4 = x3+tx;
  int y4 = y3+ty;
  printf("%d %d %d %d\n",x3,y3,x4,y4);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
const ll z=0;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> s(M),c(M),map(N+1,0);
  for(int i=0;i<M;i++){
    cin >> s[i] >> c[i];
  }
  int ans=0;
  for(int i=0;i<M-1;i++){
    for(int j=i+1;j<M;j++){
      if(s[i]==s[j]&&c[i]!=c[j]){
        ans=-1;
      }
    }
  }
  for(int i=0;i<M;i++){
    if(s[i]==1&&c[i]==0&&N!=1){
      ans=-1;
    }
  }
  if(ans==-1)
    cout << ans << endl;
  else{
    for(int i=0;i<M;i++){
      map[s[i]]=c[i];
    }
    for(int i=N;i>=1;i--){
      if(map[1]==0&&N!=1){
        map[1]=1;
      }
      ans +=map[i]*pow(10,N-i);
    }
    cout << ans << endl;
  }
}

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

int main(){
    int n,m;
    cin>>n>>m;
    
    vector<int> s(m);
    vector<int> c(m);
    
    rep(i,m) cin>>s[i]>>c[i];
    
    vector<int> ans(n,0);
    
    if(n>1 && m==0){
        cout<<pow(10,n-1)<<endl;
        return 0;
    }
    
    rep(i,m){
        if(n!=1 && s[i]==1 && c[i]==0){
            cout<<-1<<endl;
            return 0;
        }
    }
    
    rep(i,m-1){
        for(int j=i+1;j<m;j++)
            if(s[i]==s[j]){
                if(c[i]!=c[j]){
                    cout<<-1<<endl;
                    return 0;
                }
            }
    }
    
    rep(i,m){
        if(s[i]!=1) ans[0]=1;
    }
    
    rep(i,m) ans[s[i]-1]=c[i];
    rep(i,n) cout<<ans[i];
    
    return 0;    
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

const int N=100 + 6;
int a[N];
int day[N];

int main(){
	IOS;
	int n,d,x;
	while(cin>>n>>d>>x){
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<n;i++){
			int days;
			if(d%a[i]==0){
				days=d/a[i];
				day[i]=days;
			}
			else{
				days=d/a[i]+1;
				day[i]=days;
			}
		}
		int sum=0;
		for(int i=0;i<n;i++){
			sum = sum + day[i];
		}
		cout<<sum+x<<endl;
	}
	return 0;
}

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


int main(){
	int n;
	cin>>n;
	vector<double> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	vector<vector<double> > dp(n+1,vector<double>(n+1,0));
	dp[0][0]=1.0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j==0){
				dp[i][j]=dp[i-1][j]*(1-v[i-1]);
			}
			else{
				dp[i][j]=dp[i-1][j-1]*v[i-1] + dp[i-1][j]*(1-v[i-1]);
			}
		}
	}
	double ans=0.0;
	for(int i=0;i<=n;i++){
		int t=n-i;
		if(i>t){
			ans+=dp[n][i];
		}
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

void printv(vector<int> v) {
  for (int i : v)
    cout << i << " ";
  cout << endl;
}

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> v(n+1);
  vector<int> w(n+1);
  rep(i, n) { cin >> v[i+1] >> w[i+1]; }
  vector<vector<int>> V(n+1, vector<int>(W+1, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= W; j++) {
      if (j - w[i] >= 0) {
        V[i][j] = max(V[i - 1][j - w[i]] + v[i], V[i - 1][j]);
      } else
        V[i][j] = V[i - 1][j];
    }
  }
  cout << V[n][W] << endl;
}



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

ll gcd(ll x,ll y){
    if(!x)return y;
    else return gcd(y%x,x);
}
int main(){
    ll a,b;cin>>a>>b;
    ll g=gcd(a,b);
    ll ans=1;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            ans++;
            while(g%i==0)g/=i;
        }
    }
    if(g>1)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
min = A[0]
max = 0
diff = 0
for i in range(N):
  if(A[i] <= min):
    min = A[i]
    diff = max - min
  if(A[i] >= max):
    max = A[i]
    diff = max - min
print(diff)
  


Measured memory_bytes: 3060
#include<stdio.h>

void swap(int xy[1000][2],int n){
	int i,save;
	for (i = 0; i < n; i++){
		if (xy[i][0]>xy[i][1]){
			save = xy[i][0];
			xy[i][0] = xy[i][1];
			xy[i][1] = save;
		}
	}
}

int main(void){
	int i;
	int xy[3000][2];

	for (i = 0; i < 3000; i++){
		scanf("%d %d", &xy[i][0], &xy[i][1]);
		if ((xy[i][0] == 0) && (xy[i][1] == 0))
			break;
	}
	int n = i;
	swap(xy,n);

	for (i = 0; i < n;i++)
	printf("%d %d\n",xy[i][0],xy[i][1]);

	return 0;
}


Measured memory_bytes: 1932
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),m=in();
    vec a(n);
    rep(i,n){
        a[i]=in();
    }
    sort(All(a));
    vector<pii> p(m);
    rep(i,m){
        int b=in(),c=in();
        p[i]=mp(c,b);
    }
    sort(All(p),greater<pii>());
    vec b(n);
    int id=0;
    int k=0;
    while(k<n&id<m){
        int x=p[id].first,y=p[id].second;
        rep(i,y){
            if(k+i<n)b[k+i]=x;
            else break;
        }
        id++;
        k+=y;
    }
    ll sum=0;
    rep(i,n){
        sum+=max(a[i],b[i]);
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> h >> w;
	vector<string> str(h);
	rep(i, h) {
		cin >> str[i];
	}
	rep(i, h) {
		cout << str[i] << endl;
		cout << str[i] << endl;
	}
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s, t;
  cin >> s >> t;
  long ans = t.size();
  for (int i = 0; i <= s.size() - t.size(); i++) {
    long count = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i + j) != t.at(j)) {
        count++;
      }
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int[] input = new int[2];
        for (int a = 0; a < 2; a++)
        {
            input[a] = int.Parse(Console.ReadLine());
        }
        //int input =int.Parse(input[0]+""+input[3+1]+""+input[3*2+2]);
        Console.WriteLine(input[0]%500<=input[1]?"Yes":"No");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

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

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

if (a > b) swap(a, b);
if (b > c) swap(b, c);
if (a > b) swap(a, b);
cout << a << " " << b << " " << c << endl;
return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1000000007; 
long long dp[100100];
bool hantei[100100];
int main() {
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    long long a;
    cin>>a;
    hantei[a]=1;
  }
  dp[0]=1;
  dp[1]=1;
  for(int i=2;i<=n;i++){
    if(hantei[i-2]==0)dp[i]+=dp[i-2];
    if(hantei[i-1]==0)dp[i]+=dp[i-1]; 
    dp[i]%=MOD;
  }
  cout<<dp[n]%MOD<<endl;
  return 0;
}


Measured memory_bytes: 1152
[k,n]= list(map(int,input().split(" ")))
a = list(map(int,input().split(" ")))
max = 0
for i in range(n-1):
    if a[i+1]-a[i]>max:
        max = a[i+1]-a[i]
if a[0]+k-a[n-1]>max:
    max =a[0]+k-a[n-1]
    
print(k-max)

Measured memory_bytes: 26436
a, b, c = map(int, input().split())
L = [0] * b
for i in range(1, b):
    s = (a * i) % b
    if L[s] == 1:
        print('NO')
        break
    elif s == c:
        print('YES')
        break
    else:
        L[s] = 1
else:
    print('NO')


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d;
    while(scanf("%d%d%d%d",&a,&b,&c,&d)==4)
    {
        if(b<=c||d<=a)
        {
            printf("0\n");
            continue;
        }
        int aa=max(a,c);
        int bb=min(b,d);
        printf("%d\n",bb-aa);
    }
}


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

int main() {
  char s;
cin >>s;
if (s == 'a' || s =='i'||  s == 'u'|| s == 'e'|| s =='o'){
cout << "vowel" <<endl;
}
else 
cout << "consonant" << endl;
}


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

int main()
{


    int a,b;
    cin >> a >> b;
    if(a == 1 && b == 1) cout << "Draw";
    else if(a == b) cout << "Draw";
    else if(a == 1) cout << "Alice";
    else if(b == 1) cout << "Bob";
    else if(a > b) cout << "Alice";
    else cout << "Bob";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt(), B=sc.nextInt();
		if(A==1){
	        A=14;
	    }
	    if(B==1){
	        B=14;
	    }
	    
	    if(A>B){
	        System.out.println("Alice");
	    }
	    
	    else if(B>A){
	    	System.out.println("Bob");
	    }
	    
	    else{
	    	System.out.println("Draw");
	    }

	}

}

Measured memory_bytes: 21972
# 入力
D, G = map(int, input().split())
ps = [0] * D
cs = [0] * D

for i in range(D):
    ps[i], cs[i] = map(int, input().split())

# 再帰的に問題数を求める
def dfs(n, d, g):
    """
    d以下の問題でg点以上取るために必要な最小の問題数を返す

    Parameters
    ----------
    n : int
        dより大きいレベルを解いた数
    d : int
        レベル
    g : int
        点数
    m : int
        dレベルを解く場合の問題数
    p : int
        p問解いた場合に得られる点数

    Returns
    -------
    g点取るための問題数
    """
    # d < 1でgに満たない場合
    if d < 1:
        return float('inf')

    # 解くべき問題数(piまたはg点取るのに必要な最小の問題数)
    m = min(-(-g // (100 * d)), ps[d-1])

    # m問解いた時に得られる点数
    p = 100 * m * d + cs[d-1] if m == ps[d-1] else 100 * m * d

    
    if p >= g:  # g点以上取れる
        return min(n+m, dfs(n, d-1, g))
    else:       #g点に満たない
        return min(dfs(n + m, d - 1, g - p), dfs(n, d -1, g))

print(dfs(0, D, G))


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

string shuffle(string str, int h ){
  string head = str.substr(0, h);
  string tail = str.substr(h, str.size()-h);
  return tail + head;
}

int main(){
  string cards;
  int m, h;

  while(1){
    cin >> cards;
    if ( cards ==  "-") break;

  cin >> m;
  for ( int i = 0; i < m; i++ ){
   cin >> h;
   cards = shuffle(cards, h);
}
cout << cards << endl;;
}

return 0;
}


Measured memory_bytes: 3160
#include <cstdio>
#include <cstdlib>
using namespace std;
#define ll long long
ll n,d;
ll cnt;
int main()
{
	scanf("%lld%lld",&n,&d);
	d=2*d+1;
	if(n%d!=0)
		cnt++;
	cnt+=n/d;
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int i, j, H, W;
	scanf("%d %d", &H, &W);
	while((H!=0)||(W!=0)){
		for(i=0; i<H ;i++){
			for(j=0; j<W; j++){
				if((i+j)%2 == 0)
					printf("#");
				else
					printf(".");
				if(j==(W-1))
					printf("\n");				
			}
		}
		printf("\n");
		scanf("%d %d", &H, &W);
	}
	return 0;
}

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

int main(){
  int k;
  string  s,ans;
  cin >> k >> s;
  
  if(s.size()>k){
    ans=s.substr(0,k)+"...";
  }
  else ans=s;
  
  cout << ans << endl;
  
  return 0; 
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {

	A := oneInt()

	var takos []int
	for index := 0; index < A; index++ {
		takos = append(takos, oneInt())
	}

	var ans int
	for i := 0; i < len(takos)-1; i++ {
		for j := i + 1; j < len(takos); j++ {
			ans += takos[i] * takos[j]
		}
	}
	fmt.Print(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 640
use proconio::input;
use proconio::marker::*;
use std::cmp::*;

fn main() {
    input! {
        n: usize,
        a: [usize;n]
    }

    let mut count = 0;
    for i in a{
        if i == (count + 1){
            count += 1;
        }
    }

    let res = {
        if count == 0{
            -1
        }else{
            (n - count) as i32
        }
    };
    
    print!("{}",res);
}


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

using namespace std;

void solve() {
    string N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < (int)N.size(); i++)
    {
        ans = (ans + (N[i] - '0'))%9;
    }
    if (ans == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

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

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N;
  cin>>N;
  vector<ll> v(N);
  cinv(v,0,N);
  sort(v.begin(),v.end());
  ll res=0;
  FOR(i,1,N){
    if(v[i]>v[i-1]) res++;
  }
  cout<<res+1<<endl;
}


Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var str = Console.ReadLine();
        if (str[0] == 'A')
        {
            var ccount = 0;
            for (int i = 0; i < str.Length - 3; i++)
            {
                if (str[i + 2] == 'C')
                    ccount++;
            }
            if (ccount == 1)
            {
                str = str.Replace("A", "").Replace("C", "");
                if (str.ToLower() == str)
                {
                    Console.WriteLine("AC");
                    return;

                }
            }
        }
        Console.WriteLine("WA");
        Console.ReadLine();
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

    public static int Max(params int[] values)
    {
        var maxes = -1;
        for (int i = 0; i < values.Length; i++)
        {
            maxes = Math.Max(values[i], maxes);
        }
        return maxes;
    }

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }
    // public static int[]

    #endregion
}



Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int a[2*100001],val[2*100001];
bool visited[2*100001];

int main(){

    int n; long long int k;

    cin >> n >> k;

    for(int i=1;i<=n;i++)cin>>a[i];

    int next=1;
    while(k>0){
        if(visited[next]==true){
            int sub_next=a[next],sum=1;
            while(sub_next!=next){
                sum++;
                sub_next=a[sub_next];
            }
            k = k % sum;
            for(int i=0;i<k;i++){
                next=a[next];
            }
            cout << next << endl;;
            return 0;
        }
        visited[next] = true;
        next=a[next];
        k--;
    }

    cout << next << endl;

    return 0;
}

Measured memory_bytes: 4612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll n;cin >> n;
    ll s;cin >> s;
    ll arr[n];
    for(ll i=0;i<n;i++) cin >> arr[i];
    ll dp[n+1][s+1];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<=s;j++)
        {
            dp[i+1][j] += 2*dp[i][j];
            dp[i+1][j]%=mod1;
            if(j+arr[i]<=s) {dp[i+1][j+arr[i]]+=dp[i][j];dp[i+1][j+arr[i]]%=mod1;} 
        }
    }
    cout << dp[n][s] << endl;
    
}
    

Measured memory_bytes: 73952
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn];
int a[maxn];

int main(void)
{
    int N;
    scanf("%d %s", &N, s + 1);
    for(int p = 0; p <= 1; p++)
    for(int q = 0; q <= 1; q++)
    {
        a[1] = p, a[2] = q;
        for(int i = 3; i <= N; i++) a[i] = a[i-2] ^ a[i-1] ^ (s[i-1] == 'x');
        if(a[1] != a[N-1] ^ a[N] ^ (s[N] == 'x')) continue;
        if(a[2] != a[N] ^ a[1] ^ (s[1] == 'x')) continue;
        for(int i = 1; i <= N; i++) putchar(a[i] ? 'W' : 'S');
        puts(""); return 0;
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <limits>

void doit(int N) {
    if (N < 3) {
        return;
    }
    int min = std::numeric_limits<int>::max();
    int max = std::numeric_limits<int>::min();
    int total = 0;
    int num = 0;
    
    for (int i = 0; i < N; i++) {
        int v;
        std::cin >> v;
        if (v < min) {
            min = v;
        }
        if (v > max) {
            max = v;
        }
        total += v;
        num++;
    }
    total -= (min + max);
    num -= 2;
    std::cout << (int)(((double)total) / num) << std::endl;
}

int main()
{
    int N;
    while(std::cin >> N) {
        doit(N);
    }
}

Measured memory_bytes: 3016
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N;
	cin >> N;
	vll H(N);
	for(int i=0; i<N; i++){
		cin >> H[i];
	}

	int ans=0;
	int tmp=0;
	for(int i=N-1; i>0; i--){
		if(H[i-1]>=H[i]){
			tmp++;
		}else{
			tmp=0;
		}
		if(ans<tmp){
			ans=tmp;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(void)
{
    int N,T,A,X;
    scanf("%d%d%d", &N, &T, &A);
    int res = 0;
    int cc = 1<<30;
    for(int i=1; i<=N; i++){
        scanf("%d", &X);
        int d = (T*1000-X*6)-A*1000;
        if(d<0) d=-d;
        if(cc>d) cc = d, res =i;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int s[7];
void solve(int n,int m)
{
	if(n==s[5]&&m==s[4]||n==s[3]&&m==s[5]||n==s[2]&&m==s[3]||n==s[4]&&m==s[2])
		cout<<s[1]<<endl;
	if(n==s[3]&&m==s[2]||n==s[5]&&m==s[3]||n==s[4]&&m==s[5]||n==s[2]&&m==s[4])
		cout<<s[6]<<endl;
	if(n==s[1]&&m==s[4]||n==s[3]&&m==s[1]||n==s[6]&&m==s[3]||n==s[4]&&m==s[6])
		cout<<s[2]<<endl;
	if(n==s[4]&&m==s[1]||n==s[1]&&m==s[3]||n==s[3]&&m==s[6]||n==s[6]&&m==s[4])
		cout<<s[5]<<endl;
	if(n==s[1]&&m==s[2]||n==s[5]&&m==s[1]||n==s[6]&&m==s[5]||n==s[2]&&m==s[6])
		cout<<s[3]<<endl;
	if(n==s[2]&&m==s[1]||n==s[1]&&m==s[5]||n==s[5]&&m==s[6]||n==s[6]&&m==s[2])
		cout<<s[4]<<endl;


}
int main()
{
	int n,m,q;
for(int i=1;i<=6;i++)
		cin>>s[i];
cin>>q;
for(int i=0;i<q;i++)
	{	cin>>n>>m;
		solve(n,m);

}
return 0;

	

}

Measured memory_bytes: 3092
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };


int main()
{
	int h;
	while (cin >> h&&h)
	{
		vi a[11];
		FOR(i, h)
		{
			FOR(j, 5)
			{
				inin(x); a[i].push_back(x);
			}
		}
		bool ok = true;
		int ans = 0;
		while (ok)
		{
			ok = false;
			FOR(i, h)
			{
				for (int j = 5; j >= 3;j--)
				{
					for (int k = 0; k <= 5 - j; k++)
					{
						bool okk = true;
						for (int l = k; l < k + j; l++)
						{
							if (a[i][k] == 0)okk = false;
							if (a[i][l] != a[i][k])okk = false;
						}
						if (okk)
						{
							ok = true;
							for (int l = k; l < k + j; l++)
							{
								ans += a[i][l];
								a[i][l] = 0;
							}
						}
					}
				}
			}
			for (int c = 0; c < h;c++) for (int i = 0; i < h - 1; i++)
			{
				for (int j = 0; j < 5; j++)
				{
					if (a[i+1][j] == 0)
					{
						swap(a[i][j], a[i + 1][j]);
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int n,k,i,j,v[101],d[100010];

int main()
{
    cin>>n>>k;
    for(i=1; i<=n; i++)cin>>v[i];

    d[0]=0; /// pierde daca sunt 0 pietre, pentru ca nu poate sa faca nicio mutare
    for(i=1;i<=k;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i-v[j]>=0)
            {
                if(d[i-v[j]]==0) /// inseamna ca am gasit un punct in care a pierdut anterior, deci acum va castiga
                                 /// asta inseamnca ca din punctul (i-v[j]) daca mergem inca o data in spate, toate mutarile sunt castigatoare
                                 /// adica jucatorul 1 poate ajunge optim in oricare din variantele castigatoare de acum doua dati, olbigand astfel jucatorul 2 sa "castige" la pasul anterior indiferent de mutare
                {
                    d[i]=1;
                }
            }
        }
    }

    if(d[k]==1)cout<<"First";
    else cout<<"Second";

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];
    cin >> m;
    vector<string> t(m);
    REP(i, m) cin >> t[i];
    int ans = 0;
    REP(i, n){
        int cnt = 0;
        REP(j, n) if(s[i] == s[j]) ++cnt;
        REP(j, m) if(s[i] == t[j]) --cnt;
        ans = max(ans, cnt);
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    vector<int> p(4);
    vector<int> t(4);
    for(int i = 0;i < 4;++i) {
        cin>>p[i];
    }
    for(int i = 0;i < 4;++i) {
        cin>>t[i];
    }
    int ans=1000000;
    for(int i = 0;i <= n;++i) {
        for(int j = 0;j <= n;++j) {
            for(int k = 0;k <= n;++k) {
                for(int h = 0;h <= n;++h) {
                    if(i*t[0]+j*t[1]+k*t[2]+h*t[3]>=n){
                        ans=min(ans,i*p[0]+j*p[1]+k*p[2]+h*p[3]);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second

P s[100005];

int main(void){
	int n,m,ans=0,now=0;cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>s[i].S>>s[i].F;
		
	}
	sort(s,s+m);
	for(int i=0;i<m;i++){
		if(s[i].S>=now){
			now=s[i].F;
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1024