akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S[3];
    REP(i, 3) {
        cin >> S[i];
    }
    int x = 0;
    while (1) {
        if (S[x].empty()) {
            cout << char(x + 'A') << endl;
            return 0;
        }
        char c = S[x][0];
        S[x] = S[x].substr(1);
        x = c - 'a';
    }
    return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i);
h = gets.chomp.split(" ").map(&:to_i);

total = n
result = Array.new(n, true)

m.times do
  a, b = gets.chomp.split(" ").map(&:to_i);
  a-=1
  b-=1

  if h[a] == h[b]
    result[a] = false
    result[b] = false
  elsif h[a] < h[b]
    result[a] = false
  elsif h[a] > h[b]
    result[b] = false
  end
end

puts result.count(true)

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

int main()
{
    long n,i,j,k;
    cin>>n>>k;
    long A[n+1];
    A[0]=0;
    for(i=1;i<=n;i++)
        cin>>A[i];

    long long dp[n+1];
    for(i=0;i<=n;i++)
        dp[i]=1e18;
    dp[0]=0;
    dp[1]=0;
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=i+k && j<=n;j++)
            dp[j]=min(dp[j],dp[i]+abs(A[j]-A[i]));
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(register int i=(a),i##_st=(b);i>=i##_st;--i)
#define rpg(i,x) for(register int i=fir[x];i;i=e[i].nxt)
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define bin(i) (1<<i)
#define cls(x,y) memset(x,y,sizeof x)
typedef pair<int,int> pa;
typedef long long LL;
const int INF = 0x7fffffff;
const int oo = 0x3f3f3f3f;
/*const int _L = 1e6+5;
char ibuf[_L],*ih=ibuf+_L;
inline char gc(){return (ih==ibuf+_L?fread(ibuf,1,_L,stdin),ih=ibuf:0),*ih++;}
#define  getchar() gc() //*/
template <typename T>
inline void rd(T &x) {
    x = 0; int f = 1; char CH = getchar();
    while(!isdigit(CH)) {if(CH=='-')f=0;CH=getchar();}
    while(isdigit(CH)) {x=((x+(x<<2))<<1)+(CH-48);CH=getchar();}
    x=(f==1)?x:-x;  return;
}
const int MXN = 3e5 + 5;
int n,a[MXN],ans=INT_MAX,b[MXN];
char str[MXN];
int main()
{
#ifdef iloi
	   freopen("test.in","r",stdin);
#endif
	cin>>n; cin>>str+1;
	rep(i,1,n) if(str[i]=='W') a[i]=a[i-1]+1; else a[i]=a[i-1];
	per(i,n,1) if(str[i]=='E') b[i]=b[i+1]+1; else b[i]=b[i+1];
	rep(i,1,n) ans=min(ans,a[i-1]+b[i+1]);
	cout<<ans;
#ifdef iloi
	debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}


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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

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

    while (true) {
        int n, m, p, a, b;
        cin >> n >> m >> p >> a >> b;
        if (n == 0 and m == 0 and p == 0 and a == 0 and b == 0) { break; }
        a--;
        b--;
        vector<int> T(n);

        FOR(i, 0, n) {
            cin >> T[i];
        }

        VVI graph(m, VI(m, -1));
        FOR(i, 0, p) {
            int x, y, z;
            cin >> x >> y >> z;
            x--; y--;
            graph[x][y] = z;
            graph[y][x] = z;
        }

        vector<vector<double>> dp(m + 1, vector<double>(1 << n, INT_MAX));
        dp[a][0] = 0;

        bool change = true;
        while (change) {
            change = false;
            FOR(i, 0, m) {
                FOR(j, 0, m) {

                    double dist = graph[i][j];
                    if (dist == -1) {
                        continue;
                    }

                    FOR(k, 0, 1 << n) {
                        if (dp[j][k] == INT_MAX) { continue; }

                        FOR(t, 0, n) {
                            if ((k & (1 << t)) != 0) { continue; }
                            double cost = dist / T[t];

                            double now_cost = dp[i][k | (1 << t)];
                            double new_cost = dp[j][k] + cost;
                            if (new_cost < now_cost) {
                                change = true;
                                dp[i][k | (1 << t)] = new_cost;
                            }
                        }
                    }
                }
            }
        }

        double ans = INT_MAX;
        FOR(k, 0, 1 << n) {
            ans = min(ans, dp[b][k]);
        }
        if (ans == INT_MAX) {
            print("Impossible");
        } else {
            print(ans);
        }
    }
    return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <utility>
#include <set>
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(1)
#define lli long long int

using namespace std;

int main() {
  
  int n;
  string p1, p2;
  
  cin >> n;
  int score1 = 0;
  int score2 = 0;
  
  rep (i, n) {
    cin >> p1 >> p2;
    if (p1 == p2) {
      score1 += 1;
      score2 += 1;
    }
    else if (p1 > p2) {
      score1 += 3;
    }
    else {
      score2 += 3;
    }
  }
  cout << score1 << " " << score2 << endl;
  
  return 0;
}


Measured memory_bytes: 3136
import io,sys
sys.setrecursionlimit(10**6)

def main():
    import bisect
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    A.sort()

    ans = 0
    a_max = A[-1]
    note = [True]*(a_max+1)
    for j in range(n):
        a = A[j]
        if note[a]:
            if j != n-1 and A[j]==A[j+1]:
                ans-=1
            ans+=1
            # for i in range(a,a_max+1):
            #     if i%a==0:
            #         note[i] = False
            temp = a 
            while temp <= a_max:
                note[temp]=False
                temp+=a

        
    
    print(ans)
main()

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

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


        String s=scan.next();

        if(s.length()%2!=0){
            s=s.substring(0,s.length()-1);

        }else{
            s=s.substring(0,s.length()-2);
        }
        boolean jdg=false;
        int n=s.length();
        while(!jdg){
            n=s.length();
            for(int i=0;i<n/2;i++){
                if(s.charAt(i)!=s.charAt(i+n/2)){
                    s=s.substring(0,n-2);
                    break;
                }
                if(i==n/2-1){
                    jdg=true;
                }
            }

        }
        System.out.println(s.length());

}
}

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

int main() {
  int N,i;
  cin >> N;
  vector<int> h(N);
  vector<int> d(N,-1);
  
  for(auto& x:h)
    cin >> x;
  
  d[0] = 0;
  d[1] = abs(h[1] - h[0]);
  for (i=2;i<N;i++)
    d[i] = min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));
  cout << d[N-1] << endl;
}

Measured memory_bytes: 3992
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9 + 7;

alias Edge = Tuple!(int, "to", int, "cost", int, "rev");

void main() {
    int n, m;
    scan(n, m);

    auto adj = new Edge[][](n, 0);

    foreach (i ; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        adj[u] ~= Edge(v, c, adj[v].length.to!int);
        adj[v] ~= Edge(u, 0, adj[u].length.to!int - 1);
    }

    int ans = FordFulkerson(n, m, adj, 0, n - 1);

    writeln(ans);
}

int FordFulkerson(int n, int m, Edge[][] adj, int s, int t) {
    bool[] visited = new bool[](n);

    int dfs (int u, int f) {
        if (u == t) {
            return f;
        }

        visited[u] = 1;

        foreach (ref e ; adj[u]) {
            if (e.cost > 0 && !visited[e.to]) {
                int d = dfs(e.to, min(f, e.cost));

                if (d > 0) {
                    e.cost -= d;
                    adj[e.to][e.rev].cost += d;
                    return d;
                }
            }
        }

        return 0;
    }

    int F;

    while (true) {
        visited[] = 0;

        int f = dfs(s, inf);

        if (f == 0) break;

        F += f;
    }

    return F;
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 2512
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

int main() {
    int n;
    while (cin >> n, n != 0) {
        vector< pair<int, int> > island(n);
        for (int i = 0; i < n; i++) {
            cin >> island[i].second >> island[i].first;
        }
        sort(island.begin(), island.end());
        
        int w = 0;
        string ans = "Yes";
        for (int i = 0; i < island.size(); i++) {
            w += island[i].second;
            if (w > island[i].first) {
                ans = "No";
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>


using namespace std;


void insertion_sort(unsigned int S[], int n)
{
    for (int i = 1; i < n; i++) {
        int j;
        unsigned int v;
        j = i - 1;
        v = S[i];
        while (j >= 0 && S[j] > v) {
            S[j + 1] = S[j];
            j--;
        }
        S[j + 1] = v;
    }
}


bool binary_search(unsigned int S[], int n, unsigned int t)
{
    int l, r, m;
    l = 0;
    r = n;
    while (r - l > 0) {
        m = (l + r) / 2;
        if (S[m] == t)
            break;
        if (S[m] < t)
            l = m + 1;
        else
            r = m;
    }

    return S[m] == t;
}


int main(void)
{
    unsigned int S[100000];
    unsigned int t;

    int n, q;

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> S[i];

    insertion_sort(S, n);

    int cnt = 0;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (binary_search(S, n, t))
            cnt++;
    }

    cout << cnt << endl;
}



Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
int vis[10];
int main(){
    int n,k,x;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>x;
        vis[x]=1;
    }
    for(int i=n;;i++){
        int j=i;
        int ok=1;
        while(j){
            if(vis[j%10]){
                ok=0;
                break;
            }
            j/=10;
        }
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string T[4] = {"dream",  "dreamer" ,"erase", "eraser"};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string K;
    for(int i = (int)S.length() - 1; i >= 0; i--) {
        K = S[i] + K;
        for(int j = 0; j < 4; j++) {
            if (K == T[j]) K = "";
        }
    }
    if (K.length() == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 592
#include <stdio.h>

int judge(int a , int b, int c ) {
	if ( a == b )
		return 1;
	else if ( a * a + b * b == c * c ) 
		return 2;
	else
		return 0;
}

int main (void) {
	int a , b , c , tsum = 0 , hsum = 0;
	
	while ( scanf("%d,%d,%d",&a,&b,&c) != EOF ) {
		tsum += judge(a,b,c) == 2;
		hsum += judge(a,b,c) == 1;
	}
	printf("%d\n%d\n",tsum,hsum);
	return 0;
}

Measured memory_bytes: 0
n, m = STDIN.gets.split(' ').map(&:to_i)

mat = []
n.times do |i|
  mat << STDIN.gets.split(' ').map(&:to_i)
end

vec = []
m.times do |j|
  vec << STDIN.gets.to_i
end

n.times do |i|
  sum = 0
  m.times do |j|
    sum += mat[i][j] * vec[j]
  end
  puts sum
end

Measured memory_bytes: 8892
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
queue<long long> q;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long k;
	cin>>k;
	for(long long i=1;i<=9;i++)
		q.push(i);
	k-=1;
	while(k--)
	{
		long long x=q.front();
		q.pop();
		if(x%10!=0)
			q.push(10*x+x%10-1);
		q.push(10*x+x%10);
		if(x%10!=9)
			q.push(10*x+x%10+1);
	}
	cout<<q.front()<<endl;
	return 0;
}




Measured memory_bytes: 1792
import java.util.Scanner;

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

        int digit = 1;
        int num = N;
        while((num /= K) != 0) digit++;

        System.out.println(digit);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <numeric>
#include <functional>

using namespace std;

int square(int x) {
	return x * x;
}

struct Circle {
	int x, y, r, c;
	
	Circle() {};
	Circle(int x, int y, int r, int c) :x(x), y(y), r(r), c(c) {};
};

bool ok(Circle& a, Circle& b) {
	return square(a.x - b.x) + square(a.y - b.y) < square(a.r + b.r);
}

int dp[1 << 24], intersect[30];

int main() {
	int n;
	while (cin >> n, n) {
		fill(dp, dp + (1 << 24), -1);
		fill(intersect, intersect + 30, 0);
		vector<Circle> cs(n);
		for (int i = 0; i < n; ++i) cin >> cs[i].x >> cs[i].y >> cs[i].r >> cs[i].c;
		for (int i = 0; i < n; ++i)
			for (int j = i + 1; j < n; ++j)
				if (ok(cs[i], cs[j])) intersect[j] |= (1 << i);
		dp[0] = 0;
		for (int i = 0; i < (1 << n); ++i) {
			if (dp[i] == -1) continue;
			for (int j = 0; j < n; ++j) {
				if ((i & (1 << j)) || (i & intersect[j]) != intersect[j]) continue;
				for (int k = j + 1; k < n; ++k) {
					if ((i & (1 << k)) || (i & intersect[k]) != intersect[k]) continue;
					if (cs[j].c != cs[k].c) continue;
					int to = i | (1 << j) | (1 << k);
					dp[to] = max(dp[to], dp[i] + 2);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < (1 << 24); ++i) ans = max(ans, dp[i]);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 68616
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

char S[10*10*10*10*10];

int main()
{
  int cnt;
  int N;
  int i;
  int result = 0;
  char prev = 0;

  cnt = scanf("%d", &N);
  cnt = scanf("%c", &S[i]);
  
  for (i=0; i<N; i++) {
    cnt = scanf("%c", &S[i]);
//    printf ("prev=%c S[%d]=%c\n", prev, i, S[i]);
    if (prev == 0) {
      prev = S[i];
      result++;
      continue;
    } else {
      if (prev == S[i]) continue;
      prev = S[i];
      result++;
    }
  }

  printf("%d", result);

  return 0;
}



Measured memory_bytes: 256
n,m=[int(i) for i in input().split()]

h=[int(i) for i in input().split()]


tenbodai=[]

class Tenbo:
    def __init__(self,name,hight):
        self.name=name
        self.tonari=[]
        self.hight=hight
for i in range(n):
    tenbo=Tenbo(i,h[i])
    tenbodai.append(tenbo)

for i in range(m):
    a,b=[int(i) for i in input().split()]
    a=a-1
    b=b-1
    tenbodai[a].tonari.append(tenbodai[b].hight)
    tenbodai[b].tonari.append(tenbodai[a].hight)

def good(tenbo):
    if tenbo.tonari==[]:
        return True
    tenbo.tonari.sort()
    if tenbo.hight>tenbo.tonari[-1]:
        return True
    return False
        
ans=0        
for tenbo in tenbodai:
    if good(tenbo):
        ans+=1
print(ans)        

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}


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


int main() {
    int N, K, result;
    cin>>N>>K;
    result=1;
    for (int i=1; i<=N; i++){
        if (2*result<result+K){
            result=2*result;
        }
        else {
            result+=K;
        }
    }
    cout<<result<<endl;

    
}


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


int main()
{
    string inp;
    cin >> inp;
    int res = 0;
    for(int i=0; i<inp.size(); i++)
    {
        if(inp[i]=='+')
            res++;
        else
            res--;
    }
    cout << res << endl;
    return 0;
}








Measured memory_bytes: 256
#MLE注意！

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = input().rstrip()
    res = s.count('R') * s.count('G') * s.count('B')

    cnt = 0
    for j in range(1, n-1):
        for k in range(1, j+1):
            if j+k >= n:
                continue
            if s[j-k] != s[j] and s[j+k] != s[j] and s[j-k] != s[j+k]:
                cnt += 1

    print(res - cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68472
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n);
  double m = 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    m *= a[i];
  }
  double s = 0;
  for (int i = 0; i < n; ++i) {
    s += m / a[i];
  }
  double ans = m / s;
  cout << ans << endl;
  return 0;
}


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

string ban;

int main()
{
    while (cin >> ban)
    {
        if (ban[0]!='s' && ban[0]==ban[1] && ban[1]==ban[2])
        {
            cout << ban[0] << endl;
            continue;
        }
        if (ban[3]!='s' && ban[3]==ban[4] && ban[4]==ban[5])
        {
            cout << ban[3] << endl;
            continue;
        }
        if (ban[6]!='s' && ban[6]==ban[7] && ban[7]==ban[8])
        {
            cout << ban[6] << endl;
            continue;
        }
        if (ban[0]!='s' && ban[0]==ban[3] && ban[3]==ban[6])
        {
            cout << ban[0] << endl;
            continue;
        }
        if (ban[1]!='s' && ban[1]==ban[4] && ban[4]==ban[7])
        {
            cout << ban[1] << endl;
            continue;
        }
        if (ban[2]!='s' && ban[2]==ban[5] && ban[5]==ban[8])
        {
            cout << ban[2] << endl;
            continue;
        }
        if (ban[0]!='s' && ban[0]==ban[4] && ban[4]==ban[8])
        {
            cout << ban[0] << endl;
            continue;
        }
        if (ban[2]!='s' && ban[2]==ban[4] && ban[4]==ban[6])
        {
            cout << ban[2] << endl;
            continue;
        }
        cout << 'd' << endl;
    }

    return 0;
}

Measured memory_bytes: 1180
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr << #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }
#define p   998244353

void solve()
{ 
int n,a,b;
cin>>n>>a>>b;
int ans=0;
ans+=(n/(a+b))*a;
ans+=min(a,n%(a+b));
cout<<ans;










   
 }

  

signed main()
{fast
  int t;
  //cin>>t;
  t=1;
  while(t--)
    {solve();}
  
}












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

int main()
{
    string w;
    cin >> w;
    map<char, int> m;
    for (int i = 0; i < w.size(); i++)
        m[w[i]]++;
    bool beautiful = true;
    for (auto item : m)
    {
        if (item.second % 2 == 1)
        {
            beautiful = false;
            break;
        }
    }
    if (beautiful)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
deck, h = ([], [])
while True:
    temp = []
    deck.append(list(input().strip()))
    if deck[-1][0] == '-':
        del deck[-1]
        break
    m = int(input())
    for i in range(m):
        temp.append(int(input()))
    else:
        h.append(temp)

for j in range(len(deck)):
    for k in h[j]:
        for l in deck[j][:k]:
            deck[j].append(l)
        del deck[j][:k]

    [print(v, end='') for v in deck[j]]
    print()

Measured memory_bytes: 7684
N = int(input())
L=[[0 for i in range(10)] for j in range(10)]
for i in range(1,N+1):
    a=i%10
    if i<10:
        b=i
    c=i
    while c>=10:
        b=c//10
        c=b
    L[b][a]+=1
num=0
for i in range(10):
    for u in range(10):
        if L[i][u]!=0:
            num+=L[i][u]*L[u][i]
print(num)

Measured memory_bytes: 9128
N = int(input())
A = [int(input()) for i in range(N)]
max_a = max(A)
max_count = A.count(max_a)
if max_count == 1:
    ind = A.index(max_a)
    max_b = max(A[:ind]+A[ind+1:])

for i in range(N):
    if max_count > 1:
        print(max_a)
    else:
        if A[i] == max_a:
            print(max_b)
        else:
            print(max_a)


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

int main(){
  int N; cin >>N;
  int max_i=0, max1=0, max2=0;
  for(int i=0;i<N;i++){
    int a; cin >>a;
    if(a>=max1) {
      max2 = max1;
      max1 = a;
      max_i = i;
    }
    if(max1>a && a>max2){
      max2 = a;
    }
  }

  for(int i=0; i<N; i++){
    if(i==max_i) cout << max2 << endl;
    else cout << max1 << endl;
  }

  return 0;
}


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

vector<vector<int>> edges;
vector<int> d;
vector<int> indegree;
vector<bool> visited;

void dfs(int n){
	visited[n]=true;
	for(auto e:edges[n]){
		if(!visited[e]){
			d[e]=max(d[e],1+d[n]);
			indegree[e]--;
		}
		if(indegree[e]==0){
			dfs(e);
		}
	}
}

int main(){
	int n,m;cin>>n>>m;
	edges.assign(n+1,vector<int>());
	d.assign(n+1,0);
	indegree.assign(n+1,0);
	visited.assign(n+1,false);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		edges[u].push_back(v);
		++indegree[v];
	}
	for(int i=1;i<=n;i++){
		if(indegree[i]==0 && !visited[i]){
			dfs(i);
		}
	}
	int mm=0;
	for(int i=1;i<=n;i++)
		mm=max(mm,d[i]);

	cout<<mm<<endl;
		
}

Measured memory_bytes: 14288
c = []
x,y = [0],[]

3.times do |i|
  c << gets.chomp.split.map(&:to_i)
end

3.times do |i|
  y[i] = c[0][i] - x[0]
end 

3.times do |i|
  x[i] = c[i][0] - y[0]
end 

3.times do |i|
  3.times do |j|
    if x[i] + y[j] != c[i][j]
      puts "No"
      exit
    end
  end
end

puts "Yes"

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


int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int count = 0;
    for (int i = 0; i < m; i++) {
        int num;
        cin >> num;
        if (num < x) count++;
    }
    cout << (count < m - count ? count : m - count) << endl;
    return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

using graph = VVI;
int c[10005];
int d[10005];

void dfs(const graph &g, int u, int &idx) {
	d[u] = c[idx--];
	for (auto v : g[u]) {
		if (d[v] == -1)dfs(g, v, idx);
	}
}

int main() {
	int n;
	scanf("%d", &n);
	graph g(n);
	REP(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--, b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	REP(i, n)scanf("%d", &c[i]);
	sort(c, c + n);
	int ret = 0;
	REP(i, n - 1)ret += c[i];
	printf("%d\n", ret);
	int idx = n-1;
	memset(d, -1, sizeof(d));
	dfs(g, 0, idx);
	REP(i, n)printf("%d\n", d[i]);
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int f[9];
    fill(f, f + 9, 0);
    imfor(i, n) {
        int a;
        cin >> a;
        if (a < 3200) {
            f[a / 400]++;
        }
        else {
            f[8]++;
        }
    }
    int ans = 0;
    imfor(i, 8) {
        if (f[i] > 0) {
            ans++;
        }
    }
    cout << max(ans, 1) << " " << ans + f[8] << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def check(H, W, s, x, y):
    res = False
    if x - 1 >= 0 and s[y][x-1] == '#':
        res = True
    if x + 1 < W and s[y][x+1] == '#':
        res = True
    if y - 1 >= 0 and s[y-1][x] == '#':
        res = True
    if y + 1 < H and s[y+1][x] == '#':
        res = True

    return res


H,W = map(int, input().split())
s = []
for h in range(H):
    s.append(list(input()))

for y in range(H):
    for x in range(W):
        if s[y][x] == "#" and not check(H, W, s, x, y):
            print("No")
            exit()

print("Yes")

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

int f(string s, char c){
	int ret = 0;
	while(count(s.begin(), s.end(), c) != s.size()) {
		string ns;
		for(int i = 0; i < s.size() - 1; i++) {
			if(s[i] != c && s[i + 1] == c) ns += s[i + 1];
			else ns += s[i];
		}
		s = ns;
		ret++;
	}
	return ret;
}

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

	string s;
	cin >> s;
	set<char> set;
	for(auto c : s) {
		set.insert(c);
	}

	int ans = 1e9;
	for(auto c : set) {
		int x = f(s, c);
		//cerr << "c : " << c << ", x : " << x << endl;
		ans = min(ans, x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int H=0;
	int W=0;

	do{
		scanf("%d %d",&H,&W);
		if(H*W==0)break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				printf("#");
			}
			puts("");
		}
		puts("");
	}while(H*W!=0);

	return 0;
}



Measured memory_bytes: 2044
class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1

N,M,K = map(int, input().split())

friends = []
for _ in range(M):
    a,b = map(int, input().split())
    friends.append((a-1,b-1))

blocks = []
for _ in range(K):
    c,d = map(int, input().split())
    blocks.append((c-1,d-1))

uf = UnionFind(N)

for a,b in friends:
    if not uf.is_same(a,b):
        uf.unite(a,b)

ans = [0] * N

for i in range(N):
    _ = uf.root(i)

# i番目のUnionの人数
members = [0] * N
for i in range(N):
    members[uf.root(i)] += 1

for i in range(N):
    # iの人が所属するUnionの人数（i本人を除く）
    ans[i] = members[uf.root(i)] - 1

# 友達関係にある人は同じUnionかつ、友達候補になりえないから除く
for a,b in friends:
    ans[a] -= 1
    ans[b] -= 1

# ブロック関係にあるc,dが、もし同じUnionであれば友達候補になりえないので除く
for c,d in blocks:
    if uf.is_same(c,d):
        ans[c] -= 1
        ans[d] -= 1


print(*ans)


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

typedef long long ll;

int main()
{
    //freopen("in.txt","r",stdin);
    int n,m;
    cin >> n >> m;
    vector< pair< int,int > >   jobs(n);
    for(int i=0;i<n;i++){
        cin >> jobs[i].first >> jobs[i].second;
    }
    priority_queue< int > Q;
    sort(jobs.begin(),jobs.end());
    ll ans =0;
    for(int i=1,id=0;i<=m;i++){
        while(jobs[id].first == i && id < n){
            Q.push(jobs[id++].second);
            //cout << id << endl;
        }
        if(!Q.empty()){
            //cout << Q.top() << endl;
            ans += Q.top();
            Q.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1660
#include <stdio.h>
int main()
{
	int W, H, x, y, r, a, b, c, d;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	a=x-r;
	b=x+r;
	c=y-r;
	d=y+r;
	if(a>=0 && b<=W && c>=0 && d<=H){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String str;
    int num;
    boolean[] S = new boolean[13];
    boolean[] H = new boolean[13];
    boolean[] C = new boolean[13];
    boolean[] D = new boolean[13];

    for (int i = 0; i < 13; i++)
      S[i] = H[i] = C[i] = D[i] = false;

    for (int i = 0; i < n; i++) {
      str = sc.next();
      num = sc.nextInt();
      if (str.equals("S"))
        S[num - 1] = true;
      else if (str.equals("H"))
        H[num - 1] = true;
      else if (str.equals("C"))
        C[num - 1] = true;
      else if (str.equals("D"))
        D[num - 1] = true;
    }

    for (int i = 0; i < 13; i++)
      if (!S[i])
        System.out.println("S" + " " + (i + 1));
    for (int i = 0; i < 13; i++)
      if (!H[i])
        System.out.println("H" + " " + (i + 1));
    for (int i = 0; i < 13; i++)
      if (!C[i])
        System.out.println("C" + " " + (i + 1));
    for (int i = 0; i < 13; i++)
      if (!D[i])
        System.out.println("D" + " " + (i + 1));
  }
}

Measured memory_bytes: 26172
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a) <= d){
    cout<<"Yes"<<'\n';
  }
  else if(abs(c-b) <= d && abs(b-a) <= d){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}
int main(){
    int AC=0;
    int WA=0;
    int TLE=0;
    int RE=0;
    int N;cin>>N;
    rep(i,N){
        string s;
        cin>>s;
        if(s=="AC"){
            AC+=1;
        }
        else if(s=="WA"){
            WA+=1;
        }
        else if(s=="TLE"){
            TLE+=1;
        }
        else{
            RE+=1;
        }
    }
    cout<<"AC"<<" "<<"x"<<" "<<AC<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<WA<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<TLE<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<RE<<endl;
}

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

int main() {
   int n, x, a=0, l, count=0; cin >> n >> x;
   for (int i=0; i<n; i++) {
       cin >> l;
       a +=l;
       if (a > x) break;
       count++;
   }
   cout << count + 1 << endl;
}

 

Measured memory_bytes: 256
//abc093_c.cpp
//Sat Apr  7 20:40:28 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int x[3];
	cin >> x[0];
	cin >> x[1];
	cin >> x[2];

	sort(x,x+3);

	int ans = x[2]-x[1];
	x[1] = x[1] + ans;
	x[0] = x[0]+ans;

//	cout << x[0] << x[1] << x[2] << ans <<endl;

	while (1){
		if (x[0]==x[2]){
			break;
		}else if (x[0]==x[2]-1){
			break;
		}
		ans= ans+1;
		x[0] = x[0] + 2;
	}

//	cout << x[0] << x[1] << x[2] << ans <<endl;

	if (x[0] == x[2]-1){
		ans = ans+2;
	}
	
//	cout << x[0] << x[1] << x[2] << ans <<endl;

	cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[4], n;
int main() {
  int x;
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d",&x);
    num[x % 4] ++;
  }
  if (num[2] > 0) num[1] ++;
  if (num[1] + num[3] > num[0] + 1)
    puts("No");
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int A[] = new int[N];
		int maxA = 0;
		int maxAIndex = -1;
		int max = 0;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();

			if (maxA <= A[i]) {
				maxA = A[i];
				maxAIndex = i;
			}
		}

		for (int j = 0; j < N; j++) {

			max = 0;

			for (int i = 0; i < N; i++) {

				if (i == j) {
					continue;
				}

				if (!(j == maxAIndex)) {
					break;
				}

				if (max <= A[i]) {
					max = A[i];
				}
			}

			if (max == 0) {
				System.out.println(maxA);
			} else {
				System.out.println(max);
			}

		}
	}
}


Measured memory_bytes: 85348
n, k = map(int, input().split())
MOD = 10**9+7


def com(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
    Y = pow(Y, MOD-2, MOD)
    return X*Y % MOD


for i in range(1, k+1):
    ans = com(k-1, i-1)*com(n-k-(i-1)+i, i)
    print(ans % MOD)


Measured memory_bytes: 3316
import java.util.*;


	public class Main {
	public static void main( String[] args) {			
					
					Scanner in = new Scanner(System.in);
					String a = in.next();
					
					if(a.charAt(2)==a.charAt(3)&&a.charAt(4)==a.charAt(5)) {
						System.out.println("Yes");
					}
					else {
						System.out.println("No");
					}
					
			}}

Measured memory_bytes: 22868
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define mod 1000000007
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
bigint cnt[200001] ;
int main(){
    FAST_IO ;
    int N ; cin >> N ;
    bigint sum = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        bigint x ; cin >> x ;
        cnt[x]++ ;
        sum += x ;
    }
    int Q ; cin >> Q ;
    while( Q-- ){
        bigint B , C ; cin >> B >> C ;
        sum = sum - cnt[B] * B + cnt[B] * C ;
        cnt[C] += cnt[B] ; cnt[B] = 0 ;
        cout << sum << endl ;
    }
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
vector<int> num(1000);
void divisor(int n){
  for(int i=2; i<=n; i++){
    int cnt = 0;
    while(n%i==0){
      cnt++;
      n /= i;
    }
    num[i] += cnt;
  }
  return;
}
int main() {
  int n;
  cin >> n;
  for(int i=1; i<=n; i++){
    divisor(i);
  }
  //cout << num[5] << endl;
  ll ans = 1;
  rep(i,1000) {
    if(num[i]>0) {
      ans *= num[i]+1;
      ans %= 1000000007;
      //cout << ans << endl;
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, input, top[3];
  for (i = 0; i <= 2; i++)
    top[i] = 0;


  for (i = 10; i > 0; i--) {
    scanf("%d", &input);
    
    if (input > top[0]) {
      top[2] = top[1];
      top[1] = top[0];
      top[0] = input;
    } else if (input > top[1]) {
      top[2] = top[1];
      top[1] = input;
    } else if (input > top[2]) {
      top[2] = input;
    }
    
  }

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

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> v(n, vector<int>(3));
  rep(i, n) cin >> v[i][0] >> v[i][1] >> v[i][2];
  vector<vector<int>> dp(n, vector<int>(3));
  dp[0][0] = v[0][0];
  dp[0][1] = v[0][1];
  dp[0][2] = v[0][2];
for(int i = 1; i < n; ++i) {
  rep(j, 3) {
    rep(k, 3) {
      if(j == k) continue;
      dp[i][j] = max(dp[i][j], dp[i - 1][k] + v[i][j]);
    }
  }
}
int ans = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
cout << ans << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>
int n, g[5];
char c;

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf(" %c", &c);
        if(c == 'P')
            g[0] += 1;
        else if(c == 'W')
            g[1] += 1;
        else if(c == 'G')
            g[2] += 1;
        else
            g[3] +=1;
    }
    int cont = 0;
    for(int i=0; i<4; i++){
        if(g[i] > 0)
            cont +=1;
    }


    if(cont == 3)
        printf("Three\n");
    else
        printf("Four\n");
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <memory>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

int H, W;
int A, B;

const int64_t MOD = 1000000007;

int64_t add(int64_t a, int64_t b) {
  return (a + b) % MOD;
}

int64_t mul(int64_t a, int64_t b) {
  return (a * b) % MOD;
}

int64_t pow(int64_t a, int64_t b) {

  if (b == 1)
    return a;

  int64_t square = mul(a, a);
  int64_t half = b / 2;
  int64_t ret = pow(square, half);

  if (b % 2 == 0) {
    return ret;
  }
  else {
    return mul(a, ret);
  }
}

int64_t division(int64_t a, int64_t b) {

  int64_t revB = pow(b, MOD-2);
  return mul(a, revB);

}

int64_t comb(int64_t n, int64_t k) {

  if (n/2 < k)
    return comb(n, n-k);

  int64_t num=1, div=1;

  for (int i=n; n-k<i; --i)
    num = mul(num, i);

  for (int i=1; i<=k; ++i)
    div = mul(div, i);

  return division(num, div);
}

int main() {

  cin >> H >> W >> A >> B;

  int64_t ret = 0;

  /*
  for (int64_t i=A; i<H; ++i) {
    int64_t a = comb(B-1 + H-i-1, B-1);
    int64_t b = comb(W-B-1+i, W-B-1);
    ret = add(ret, mul(a, b));
  }
  */


  int64_t a = comb(B-1 + H-(A-1)-1, B-1);
  int64_t b = comb(W-B-1+(A-1), (A-1));

  for (int i=A; i<H; ++i) {
    //a = division(mul(a, H-i), B-1 + H-i-1 + 1);
    a = division(mul(a, H-i), B+H-i-1);
    //b = division(mul(b, W-B-1+i), i);
    b = division(mul(b, W-B+i-1), i);
    ret = add(ret, mul(a, b));
  }

  cout << ret << endl;

  return 0;
}
//(n-k)* nCk = n * (n-1)Ck;


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

int main(){
    string s;
    cin >> s;
    map<char, int> m;
    for(auto e: s) m[e]++;
    if(m.size() == 2 && m.begin()->second == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define LB lower_bound
#define UP upper_bound
#define INF 999999999999
const double PI = acos(-1.0);
int n;
ll x,y;
ll X[200000];
ll Y[200000];
ll ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    ans = -8e18;
    rep1(i,0,n){
        cin >> x >> y;
        X[i] = x+y;
        Y[i] = y-x;
    }

    sort(X,X+n);
    sort(Y,Y+n);
    ans = max(abs(X[0]-X[n-1]),abs(Y[0]-Y[n-1]));
    cout << ans;
    return 0;
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    string S;cin>>S;int K;cin>>K;
    char c=S[K-1];
    for(int i=0;i<N;i++){
        if(S[i]==c)continue;
        else S[i]='*';
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256