akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
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 int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int N;
vector<int> h;
vector<ll> dp;


int main()
{
    cin >> N;
    h.resize(N);
    for(int i = 0; i < N; i++) cin >> h[i];
    dp.resize(N);
    for(int i = 0; i < N; i++)
    {
        dp[i] = INF;
        // cout << dp[i] << endl;
    }
    dp[0] = 0;
    for(int i = 1; i < N; i++)
    {
        chmin(dp[i],dp[i - 1] + abs(h[i - 1] - h[i]));
        if(i > 1)
        {
            chmin(dp[i],dp[i - 2] + abs(h[i - 2] - h[i]));
        }
    }
    cout << dp[N -1] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a, b, c, k, maxi;
    cin >> a >> b >> c >> k;
    maxi = max(a, max(b, c));
    cout << a + b + c + maxi * (pow(2, k) - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int H,A,i,n;
    scanf("%d",&H);
     scanf("%d",&A);
     n=A;

     for(i=0;i<1000000;i++){
         if(A>=H){
             printf("%d",i+1); break;
         }
        A=A+n;
     }

     return 0;

}


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

int main(){
  int A,B,sum=1;
  int i=0;
  
  cin >> A >> B ;
  
  if(B == 1){
    cout << i;
    return 0;
  }
  
  while(1){
    sum += A-1 ;
    i++ ;
    if(sum >= B) break;
  }
  
  cout << i ;
  return 0;
}

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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //?§???????????????¢??????????????????
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int l, a, sum_angle = 90;
    double x, y;

    x = y = 0.0;

    while (scanf("%d,%d", &l, &a), l || a){
        x += l * cos(PI(sum_angle));
        y += l * sin(PI(sum_angle));

        sum_angle = (sum_angle - a) % 360;
    }

    CL((int)x);
    CL((int)y);

    return (0);
}

Measured memory_bytes: 3456
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static int N, M, Q;
	static List<Integer> A = new ArrayList<Integer>();
	static int[] a, b, c, d;
	static int ans = 0;

	static void dfs(List<Integer> A){
		if(A.size() == N){
			int tmp = 0;
			for(int i = 0; i < Q; i++){
				if(A.get(b[i]) - A.get(a[i]) == c[i]){
					tmp += d[i];
				}
			}
			ans = Math.max(ans, tmp);
			return;
		}
		int x = A.get(A.size()-1);
		for(int i = x; i <= M; i++){
			A.add(i);
			dfs(A);
			A.remove(A.size()-1);
		}
	}

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

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        Q = sc.nextInt();
        a = new int[Q];
        b = new int[Q];
        c = new int[Q];
        d = new int[Q];
        for(int i = 0; i < Q; i++){
        	a[i] = sc.nextInt()-1;
        	b[i] = sc.nextInt()-1;
        	c[i] = sc.nextInt();
        	d[i] = sc.nextInt();
        }
        sc.close();
        A.add(1);
        dfs(A);
        System.out.println(ans);
    }
}

Measured memory_bytes: 38960
program ABC_079_B_LucasNumber
   implicit none
   integer N, i
   integer(8) L(0: 86)
   read(*, *) N
   L(0) = 2
   L(1) = 1
   do i = 2, N
       L(i) = L(i-1) + L(i-2)
   end do
   write(*, *) L(N)
end program ABC_079_B_LucasNumber

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MAX 10e17

struct edge{ll to; ll cost;};
vector<vector<edge> > G;
vector<ll> used;

void bfs(ll k){
    queue<edge> q;
    q.push({k, 0});
    while(!q.empty()){
        edge e = q.front();
        ll now = e.to, prec = e.cost;
        q.pop();
        for(int i = 0; i < G[now].size(); i++){
            ll next = G[now][i].to;
            ll c = prec + G[now][i].cost;
            if(used[next] != MAX){continue;}
            used[next] = c;
            q.push({next, c});
        }
    }
}

int main(){
    int n; cin >> n;
    used = vector<ll>(n, MAX);
    G = vector<vector<edge> >(n);
    for(int i = 0; i < n-1; i++){
        ll a, b, c; cin >> a >> b >> c;
        edge e1 = {b-1, c}, e2 = {a-1, c};
        G[a-1].push_back(e1);
        G[b-1].push_back(e2);
    }
    ll q, k; cin >> q >> k;
    bfs(k-1);
    for(int i = 0; i < q; i++){
        ll x, y; cin >> x >> y;
        cout << used[x-1] + used[y-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 10736
N = int(input())
S = input()
S = list(S)

tmp = [0 for _ in range(N+1)]

#if S[0] == '.':
   # tmp[0] = 1

for i in range(N):
    if S[i] == '.':
        tmp[i+1] = tmp[i] + 1
    else:
        tmp[i+1] = tmp[i]
  
res1 = 10 ** 9
for i in range(N):
    res1 = min((i+1) - tmp[i+1] + tmp[N] - tmp[i+1], res1)
        
b = 0
w = 0
for i in range(N):
    if S[i] == '#':
        b += 1
    else:
        w += 1

res3 = N - max(b, w)

print(min(res1, res3))

Measured memory_bytes: 12740
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

int N, K;
int a[2000000];

int main(int argc, char** argv) {
    cin >> N >> K;
    for (int i=1;i<=N;i++) cin >> a[i];

    int a_min = 1e9;
    for (int i=1;i<=N;i++) if (a[i] <= a_min) a_min = a[i];

    int ans = 0;
    int last_pos = -1;
    int i = 1;
    while (i <= N) {
        // cout << "p" << i << endl;
        if (a[i] != a_min && last_pos < 0) last_pos = i;
        if (a[i] != a_min && i == N) {
            int n;
            last_pos -= 1;
            if ((i - last_pos) % (K - 1) == 0)
                n = (i - last_pos) / (K - 1);
            else
                n = (i - last_pos) / (K - 1) + 1;
            ans += n;
            break;
        } else if ((a[i] == a_min) && 0 < last_pos) {
            // replace
            int n;
            if ((i - last_pos) % (K - 1) == 0)
                n = (i - last_pos) / (K - 1);
            else
                n = (i - last_pos) / (K - 1) + 1;
            ans += n;
            i = last_pos + (K - 1) * n + 1;
            last_pos = -1;
        } else {
            i++;
        }
    }
    if (a[i] <= a_min) a_min = a[i];


    cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            if (N == 1 && M == 1)
            {
                WriteLine(1);
                return;
            }
            if (N == 1 || M == 1)
            {
                WriteLine(Max(N, M) - Min(N, M) - 1);
                return;
            }
            WriteLine((N - 2) * (M - 2));
            

            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
H, W, A, B = map(int,input().split())
mod = 10**9+7
C = [1,1]
inv = [0,1]
Cinv = [1,1]
for i in range(2,H+W+1):
    C.append((C[-1]*i)%mod)
    inv.append((-inv[mod%i]*(mod//i)%mod))
    Cinv.append(Cinv[-1]*inv[-1]%mod)
ans = 0
for i in range(H-A):
    a = (C[i+B-1]*C[H-1-i+W-B-1])%mod
    a = (a*Cinv[B-1])%mod
    a = (a*Cinv[i])%mod
    a = (a*Cinv[W-B-1])%mod
    a = (a*Cinv[H-i-1])%mod
    ans += a
    ans %= mod
print(ans)


Measured memory_bytes: 32800
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t H, W, K;
constexpr uint64_t MOD = 1000000007;
bool used[100][8];
uint64_t dp[100][8];
uint64_t func(int32_t h, int32_t pos)
{
	if (h >= H) {
		return pos==K?1:0;
	}

	auto& memo = dp[h][pos];
	if (used[h][pos]) {
		return memo;
	}
	used[h][pos] = true;
	memo = 0;
	for (uint32_t MASK = 0; MASK < (1<<(W-1)); ++MASK)
	{
		if ((MASK & (MASK << 1))!=0) {
			continue;
		}

		std::bitset<9> mask(MASK);
		if (mask[pos]) {
			memo += func(h + 1, pos + 1);
		}
		else if ((pos > 0 && mask[pos - 1])) {
			memo += func(h + 1, pos - 1);
		}
		else {
			memo += func(h + 1, pos);
		}
		if (memo >= MOD) { memo -= MOD; }
	}
	return memo;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> H >> W >> K; --K;
	if (W == 1) {
		out << 1 << endl;
		return 0;
	}
	out << func(0, 0) << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
while 1:
    li=input().split()
    a=int(li[0])
    op=li[1]
    b=int(li[2])
    if op=='?':
        break
    elif op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='*':
        print(a*b)
    elif op=='/':
        print(int(a/b))



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N;
  scanf("%ld",&N);
  vector<vector<pii>> A(N);
  vi Dist(N);
  rep(i,0,N-1){
    int X,Y,C; scanf("%ld%ld%ld",&X,&Y,&C);
    A[X-1].push_back(make_pair(Y-1,C));
    A[Y-1].push_back(make_pair(X-1,C));
  }
  int QQ; scanf("%ld",&QQ);
  int K; scanf("%ld",&K);
  queue<int> Q;
  Q.push(K-1);
  vector<bool> F(N,1);
  F[K-1]=0;
  while(Q.size()>0){
    int Z=Q.front();
    Q.pop();
    rep(i,0,A[Z].size()){
      if(F[A[Z][i].first]){
        Q.push(A[Z][i].first);
        F[A[Z][i].first]=0;
        Dist[A[Z][i].first]=Dist[Z]+A[Z][i].second;
      }
    }
  }
  rep(i,0,QQ){
    int X,Y; scanf("%ld%ld",&X,&Y);
    int ans=Dist[X-1]+Dist[Y-1];
    printf("%ld\n",ans);
  }
  }






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

using namespace std;

string a;
int main() {
    cin >> a;
    for (int i = 0; i < a.size(); i++) {
        if (a[i] == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int X,N; cin >> X >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    int ans=INF;
    int a;
    rep(i,102) {
        bool can=true;
        rep(j,N) {
            if(i==A[j]) can=false;
        }
        if(!can) continue;
        if(chmin(ans,abs(X-i))) {
            a=i;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3632
n = int(input())
d = list(map(lambda x: int(x), input().split()))
d.sort()

res = 0

for i in range(n-2):
    k = i + 2
    for j in range(i+1, n-1):
        while k < n and d[i] + d[j] > d[k]:
            k += 1
        if k > j:
            res += k - j - 1

print(res)

Measured memory_bytes: 3188
#pragma warning(disable:4996)
#include <stdio.h>
#include <algorithm>
using namespace std;
int root[200200];
bool team[200200];
int n, m;
int find(int a)
{
	if (root[a] < 0) return a;
	else return root[a] = find(root[a]);
}
void merge(int a, int b)
{
	a = find(a);
	b = find(b);
	if (a == b) return;
	root[a] += root[b];
	root[b] = a;
	return;
}
int main()
{
	scanf("%d %d", &n, &m);
	fill(root, root + n + 1, -1);
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		merge(a, b);
	}
	int max=0;
	for (int i = 1; i <= n; i++)
	{
		max = max > -root[i] ? max : -root[i];
	}
	printf("%d", max);
}

Measured memory_bytes: 3996
#include <iostream>
using namespace std;
 
inline int f(const int &x, const int &y, const int &z) {
	return (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z);
}

int main() {
	int N; cin >> N; 
	int A[N + 1]; for (int i = 0; i <= N ; i++) A[i] = 0;
	for (int i = 1; i < 101; i++) {
		for (int j = 1; j < 100; j++) {
			for (int k = 1 ; k < 100 ; k++) {
				if (f(i,j,k) <= N) A[f(i,j,k)]++;
			}
		}
	}
	for (int i = 1 ;i <= N ; i++) cout << A[i] << '\n';
	return 0;
}

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


int main(){
    while(1){
    
    int H,W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i == 0 || i == H-1 || j == 0 || j == W-1) cout<<"#";
            else cout<<".";
        }
    cout<<endl;
}
        cout<<endl;
    }
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int D, N;
	cin >> D >> N;
	if (D == 0){
		if (N == 100)cout << 101 << endl;
		else cout << N << endl;
	}
	else if (D == 1){
		if (N == 100)cout << 10100 << endl;
		else cout << 100 * N << endl;
	}
	else if (D == 2){
		if (N == 100)cout << 1010000 << endl;
		else cout << 10000 * N << endl;
	}
}

Measured memory_bytes: 256
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int x,y,win[300][300] = {0};
int main() {
	int ans = 0;
	cin>>x>>y;
	if(x<=3)ans+=(4-x)*100000;
	if(y<=3)ans+=(4-y)*100000;
	if(x == y && x == 1)ans+=400000;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;
    int max = 0, min = 0;
    if (a > b){
        max = a;
        min = b;
    }
    else{
        max = b;
        min = a;
    }
    if (max < c) max = c;
    if (min > c) min = c;
    std::cout << min << " " << max << std::endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
#define PI 3.14159265359
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<pair<double,double>> XY;
    for(int i=0;i<N;i++){
        double x,y;
        cin >> x >> y;
        XY.push_back(make_pair(x,y));
    }
    vector<int> I(N,0);
    for(int i=1;i<N;i++) I[i] += I[i-1]+1;
    vector<double> avgl;
    int cnt = 0;
    do{
        double sum=0;
        cnt++;
        for(int i=0;i<N-1;i++){
            double x1,y1,x2,y2;
            x1 = XY[I[i]].first  ; y1 = XY[I[i]].second;
            x2 = XY[I[i+1]].first; y2 = XY[I[i+1]].second;
            sum += sqrt(pow((x1-x2),2)+pow((y1-y2),2));
        }
        avgl.push_back(sum);
    }while(next_permutation(I.begin(),I.end())); 
//    for(double x : avgl) cout << x << ' ';
    double ret = 0;
    for(double x : avgl) ret += x;
//    cout << cnt << endl;
    printf("%.10f\n",ret/cnt);
}


Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    int radius = Integer.parseInt(reader.readLine());
    out.println(2 * 3.14159 * radius );
    out.flush();
  }
}


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

bool palindrome(int i,int j,string S)
{
    int c=j-i+1;
    for(int k=0;k<c; i++,j--,k++)
    {
        if(S[i]==S[j])
            continue;
        else
            return 0;
    }
    return 1;
}

main()
{
    string S;
    cin>>S;
    int N=S.length();
    if(N)
    if(palindrome(0,N-1,S)&&palindrome(0,((N-1)/2)-1,S)&&palindrome(((N+3)/2)-1,N-1,S))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, nodes):
        self._parents = {k: k for k in nodes}
        self._ranks = {k: 0 for k in nodes}
        self._sizes = {k: 1 for k in nodes}

    def union(self, x, y):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :return:
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            # rank が小さい方が下
            if self._ranks[x] > self._ranks[y]:
                self._parents[y] = x
                self._sizes[x] += self._sizes[y]
            else:
                self._parents[x] = y
                self._sizes[y] += self._sizes[x]
                if self._ranks[x] == self._ranks[y]:
                    self._ranks[y] += 1

    def find(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.find(x)]


n, m = map(int, input().split())

bridges = []
for _ in range(m):
    bridges.append(list(map(int, input().split())))


def c2(n):
    # n から2個選ぶ組み合わせ nC2
    return int(n * (n - 1) / 2)


bridges.reverse()
uf = UnionFind(nodes=[i + 1 for i in range(n)])
# 便利さ; つながってる島の組み合わせの数
useful = 0
useful_history = []

for bridge in bridges:
    useful_history.append(useful)

    if uf.find(bridge[0]) != uf.find(bridge[1]):
        # 新しくつながったので便利さを更新
        size0 = uf.size(bridge[0])
        size1 = uf.size(bridge[1])
        useful += c2(size0 + size1) - c2(size0) - c2(size1)
        uf.union(bridge[0], bridge[1])

for u in reversed(useful_history):
    print(useful - u)


Measured memory_bytes: 55956
#include<stdio.h>
int M[12][12];
int main() {
	int n, m, i, j; scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)for (j = 1; j <= m; j++) {
		char x; scanf(" %c", &x);
		M[i][j] = x == '#';
	}
	for (i = 1; i <= n; i++)for (j = 1; j <= m; j++)if (M[i][j] && M[i + 1][j] && M[i][j + 1]) { printf("Impossible"); return 0; }
	for (i = 1; i <= n; i++)for (j = 1; j <= m; j++)if (M[i][j] && M[i - 1][j] && M[i][j - 1]) { printf("Impossible"); return 0; }
	printf("Possible");
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int64_t Y;
  cin >> Y;
  int a=10000;
  int b=5000;
  int c=1000;
  int ansa,ansb,ansc;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      int k=N-i-j;
      if(a*i+b*j+c*k==Y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 10000000
using namespace std;
typedef pair<int,int> P;

struct data{
	int f,t,l;
	data(){}
	data(int ff,int tt,int ll){
		f=ff;
		t=tt;
		l=ll;
	}
};

struct data2{
	int t;
	int c;
	data2(){}
	data2(int tt,int cc){
		t=tt;
		c=cc;
	}
	bool operator<(const data2 &d)const{
		return c>d.c;
	}
};

int n,m;
vector<data> G;
vector<data2> fixG[500001];
vector<int> line[100001];
vector<int> toid[100001];
P iddata[500001];
int dist[500001];


int dijk(){
	priority_queue<data2> que;
	que.push(data2(0,0));
	dist[0]=0;
	while(que.size()){
		data2 q=que.top();
		que.pop();
		if(dist[q.t]<q.c)continue;
		if(iddata[q.t].first==n-1 && iddata[q.t].second==-1)return q.c;
		for(int i=0;i<fixG[q.t].size();i++){
			data2 d2=fixG[q.t][i];
			if(dist[d2.t]>q.c+d2.c){
				dist[d2.t]=q.c+d2.c;
				que.push(data2(d2.t,q.c+d2.c));
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int f,t,c;
		scanf("%d %d %d",&f,&t,&c);
		f--;
		t--;
		c--;
		G.push_back(data(f,t,c));
		line[f].push_back(c);
		line[t].push_back(c);
	}
	for(int i=0;i<n;i++){
		line[i].push_back(-1);
	}
	int all=0;
	for(int i=0;i<n;i++){
		sort(line[i].begin(),line[i].end());
		line[i].erase(unique(line[i].begin(),line[i].end()),line[i].end());
		for(int j=0;j<line[i].size();j++){
			iddata[all].first=i;
			iddata[all].second=line[i][j];
			toid[i].push_back(all);
			if(j>0){
				fixG[all].push_back(data2(toid[i][0],0));
				fixG[toid[i][0]].push_back(data2(all,1));
			}
			all++;
		}
	}
	for(int i=0;i<m;i++){
		data d=G[i];
		int fid=lower_bound(line[d.f].begin(),line[d.f].end(),d.l)-line[d.f].begin();
		int tid=lower_bound(line[d.t].begin(),line[d.t].end(),d.l)-line[d.t].begin();
		fixG[toid[d.f][fid]].push_back(data2(toid[d.t][tid],0));
		fixG[toid[d.t][tid]].push_back(data2(toid[d.f][fid],0));
	}
	for(int i=0;i<all;i++){
		dist[i]=INF;
	}
	printf("%d\n",dijk());
	return 0;
}

Measured memory_bytes: 54064
import sys
input = sys.stdin.readline

n = int(input())
X = [list(input().split()) for _ in range(n)]


xx = [0]*n
for i in range(n):
    X[i][1] = int(X[i][1])
    xx[i] = int(X[i][1])


L = sorted(X, key=lambda x:(x[0], -x[1]))

for i in range(n):
    print(xx.index(L[i][1]) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll k; cin >> k;
    
    queue<ll> q;
    rep(i, 1, 9){q.push(i);}
    
    while(--k){
        ll a = q.front(); q.pop();
        ll b = a%10;

        if(b-1 >= 0){q.push(a*10+b-1);}
        q.push(a*10+b);
        if(b+1 <= 9){q.push(a*10+b+1);}
    }
    print(q.front())
    return 0;
}

Measured memory_bytes: 1792
using System;
class Program
{
    static void Main()
    {
        
        int alpha = int.Parse(Console.ReadLine());
        int gamma = alpha - 1;
        string[] beta = Console.ReadLine().Split(' ');
        for (;gamma>0;gamma= gamma-1)
        {
            Console.Write(beta[gamma]+" ");
        }
        Console.Write(beta[0]);
        Console.WriteLine();

    }
}



Measured memory_bytes: 15948
#include<bits/stdc++.h>
using namespace std;
const long long inf = 1e15;

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

    long long x, y, ans;
    ans = inf;

    for(long long x=1; x<=sqrt(N); ++x){
        if(N % x == 0){
            y = N / x;
            ans = min(ans, x + y - 2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b; cin>>a>>b;
  int ans=a;
  if(b<a)
  ans--;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N;
    cin >> N;
    N %= 10;
    if (N == 3) {
        cout << "bon" << endl;
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;

vector<ll> nums(1000000, -1);

ll ryuka(ll n)
{
  if(n == 0) return nums[0];
  else if(n == 1) return nums[1];
  else if(nums[n] != -1) return nums[n];
  else return nums[n] = ryuka(n-1) + ryuka(n-2);

}

int main()
{
  ll n;
  cin >> n;
  nums[0] = 2;
  nums[1] = 1;
  cout << ryuka(n) << endl;

}

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

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

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

    int flag = true;
    int count = 0;
    while (flag) {
        flag = 0;
        for (int i = 0; i < n - 1; i++) {
            if (v[i] > v[i+1]) {
                swap(v[i], v[i+1]);
                flag = true;
                count++;
            }
        }
    }

    for (int j = 0; j < n; j++) {
        if (j) cout << " ";
        cout << v[j];
    }
    cout << "\n";

    cout << count << "\n";
    return 0;
}


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

using namespace std;

int main(){
  int l, r, d;
  cin >> l >> r >> d;
  int p = r - l + 1;
  int count = 0;
  for ( int i = 0; i < p; i++){
    if ( (l + i) % d == 0){
      count++;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 3628
//programking2_b.cpp
//Sun Dec  8 11:18:32 2019

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

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

	ll node[n];
	ll d[n];
	fill(node,node+n,0);
	ll maxnode = 0;
	for (int i=0;i<n;i++){
		cin >> d[i];
		node[d[i]]++;
		maxnode = max(maxnode,d[i]);
	}

	if (node[0]!=1 || d[0]!=0){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	for (int i=1;i<=maxnode;i++){
		ll temp = node[i];
		while (temp){
			ans = ans * node[i-1] % 998244353;
			temp--;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int X;
  cin >> X;

  int ans = 0;
  for (int i = 0; ; i++) {
    ans += i;
    if (X <= ans) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;


bool solve(int n, int A[], vector<char> ops, int target) {
    int i = 0;
    int value = A[0];
    while (i < n - 1) {
        if (ops[i] == '+') {
            value += A[i+1];
        } else {
            value -= A[i+1];
        }
        i++;
    }
    if (value == target) {
        for (int i = 0; i < n; i++) {
            cout << A[i];
            if (i < n - 1) cout << ops[i];
        }
        cout << "=" << target << endl;
        return true;
    }
    return false;
}


void dfs(vector<vector<char>> &opsList, vector<char> &ops1, int targetLength) {
    if (ops1.size() == targetLength) {
        opsList.push_back(ops1);
    } else {
        vector<char> ops2 = ops1;
        ops1.push_back('+');
        ops2.push_back('-');
        dfs(opsList, ops1, targetLength);
        dfs(opsList, ops2, targetLength);
    }
}


int main() {
    int M = 4;
    int target = 7;

    // inputs
    string S;
    cin >> S;

    int N = S.size();
    if (N != M) {
        cout << "fuck off!" << endl;
        return 0;
    }

    int A[N];
    for (int i = 0; i < N; i++) {
        A[i] = S[i] - '0';
    }

    vector<vector<char>> opsList;
    vector<char> ops;
    dfs(opsList, ops, N - 1);

    for (auto ops: opsList) {
        if (solve(N, A, ops, target)) return 0;
    }

    cout << "Impossible!" << endl;
    return 0;
}

// :!g++ -std=c++11 % && ./a.out



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll H;
        cin >> H;

        ll ans = 0;
        ll es = 1;

        while (H > 0) {
                ans += es;
                es *= 2;
                H /= 2;
        }

        cout << ans << endl;
}


Measured memory_bytes: 3596
use std::io::{self, Read};

pub struct Scanner<R>
where
    R: Read,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: Read,
{
    pub fn new(reader: R) -> Self {
        Scanner { reader: reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n: i32 = sc.next();
    let mut count: i32 = 0;

    for i in 1..n + 1 {
        if i.to_string().len() % 2 != 0 {
            count += 1;
        }
    }
    println!("{}", count);
}


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

int main() {
  int n, k;
  cin >> n;
  cin >> k;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (ans < k) {
      ans *= 2;
    }
    else {
      ans += k;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	#S = int(input())
	S = list(input())
	#W, H, x, y = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	S = S[:-1]

	for i,val in enumerate(S):
		if i == 0:
			continue
		if val == S[i-1]:
			print("Bad")
			sys.exit()
		

	print("Good")

if __name__ == "__main__":
	main()

Measured memory_bytes: 5104
#include <iostream>
using namespace std;
 
int main() {
    int m, f, r, sum;
    char grade;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)break;
        sum = m + f;
        if (m == -1 || f == -1 || sum < 30)grade = 'F';
        else if (sum >= 80)grade = 'A';
        else if (sum >= 65)grade = 'B';
        else if (sum >= 50 || r >= 50)grade = 'C';
        else grade = 'D';
        cout << grade << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
n,m = map(int, input().split())
a = set([int(input()) for i in range(m)])
memo = [0]*(n+1)

memo[0] = 1
if 1 in a:
    memo[1] = 0
else:
    memo[1] = 1
for i in range(2,n+1):
    if i in a:
        continue
    memo[i] = (memo[i-1] + memo[i-2])%1000000007

print(memo[n])

Measured memory_bytes: 13192
#include <iostream>
using namespace std;
const int MAXN = 30000;
int main()
{
    int a[MAXN];
    int n,m;
    cin >> n >> m;
    for(int i = 0;i < n;i ++)
        {
            cin >> a[i];
        }
    for(int i = 0;i < n-1;i++)
        {
             
            for(int j= n -2; j >= i;j--)
                {
                    if(a[j]<a[j+1])
                        {
                            int t =a[j+1];
                            a[j+1]=a[j];
                            a[j]=t;
                        }
                }
        }
    long long sum = 0;
    for(int i = 0;i < m;i++)
        {
        	sum = sum +a[i];
		}
	cout << sum<< endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

answer = 0
flg = 0
while 1:
	for i in range(len(A)):
		if A[i] % 2 == 0:
			A[i] = A[i]//2
		else:
			flg = 1
			break
	if flg == 1:
		break
	else:
		answer+=1
print(answer)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
     
    using namespace std;
     
    int a, b, c, d, e, f, new_a, new_b;
    int ans_w = 10, ans_s = -1;
    double chk;
     
     
    int main() {
        cin >> a >> b >> c >> d >> e >> f;
        new_a = a * 100;
        new_b = b * 100;
     
        chk = (double)(e * 100) / (100 + e);
     
        for (int i = 0; i <= f; i += new_a) {
            for (int j = 0; j <= f; j += new_b) {
                for (int k = 0; k <= f; k += c) {
                    for (int l = 0; l <= f; l += d) {
                        if (i + j + k + l == 0) continue;
                        if (i + j + k + l > f) break;
                        if ((double)(k + l) * 100 / (i + j + k + l) > chk) break;
                        if ((double)(k + l) * 100 / (i + j + k + l) > (double)(ans_s * 100) / (ans_w + ans_s)) {
                            ans_w = i + j;
                            ans_s = k + l;
                        }
                    }
                }
            }
        }
        cout << ans_w + ans_s << " " << ans_s << endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int n;
ll a[100010];

int main(){
  cin >> n;
  for(int i = 0; i < n; i++)  cin >> a[i];

  ll count[2];  count[0] = count[1] = 0;
  for(int ii = -1; ii < 2; ii+=2){
    int index = (ii == -1) ? 0 : 1;
    ll sum = 0;
  for(int i = 0; i < n; i++){
    if((i % 2 == 1 && (sum + a[i])*ii >= 0) || (i % 2 == 0 && (sum + a[i])*ii <= 0)){
      if(i%2 == 1){
        count[index] += (sum+a[i])*ii+1;
        sum = -ii;
      }
      else{
        count[index] += 1-(sum+a[i])*ii;
        sum = ii;
      }
      //cout << a[i] << " " << sum << endl;
    }
    else{
      sum += a[i];
    }
  }
}

  cout << min(count[0], count[1]) << endl;

  return 0;
}


Measured memory_bytes: 1024
from collections import Counter
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
c = Counter(A)
c.update({i: 0 for i in range(1, N + 1) if i not in c.keys()})

for k, v in sorted(c.items()):
  if v > Q - K:
    print('Yes')
  else:
    print('No')

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

int main()
{
    int A, B;
    int add, sub, mul;
    cin >> A >> B;
    add = A + B;
    sub = A - B;
    mul = A * B;
    if(add >= sub && add >= mul) {
        cout << add << endl;
    } else if(sub >= add && sub >= mul) {
        cout << sub << endl;
    } else if(mul >= add && mul >= sub) {
        cout << mul << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input().split('T')
    x, y = map(int, input().split())

    X = []
    Y = []
    flag = 0
    for s in S:
        if flag == 0:
            X.append(len(s))
        else:
            Y.append(len(s))
        flag ^= 1

    A = set()
    A.add(X[0])
    for i in X[1:]:
        tmp = set()
        for a in A:
            tmp.add(a + i)
            tmp.add(a - i)
        A = tmp

    B = set()
    B.add(0)
    for j in Y:
        tmp = set()
        for b in B:
            tmp.add(b + j)
            tmp.add(b - j)
        B = tmp

    if x in A and y in B:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 78856
input()
s = input()
m = 0

for i in range(1,len(s)):
    f = s[:i]
    g = s[i:]
    
    x = set(f)
    count = 0
    
    for j in x:
        if j in g:
            count = count+1
    m = max(count,m)

print(m)

Measured memory_bytes: 8772
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
const int MaxN = 1e3;

int a[MaxN + 5];

int main()
{
	int n,d,x,ans;
	while(~scanf("%d %d %d",&n,&d,&x))
	{
		ans = x+n;
		for(int i = 1;i <= n;i++)
		{
			scanf("%d",&a[i]);
			ans += (d-1)/a[i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    int n=s.size();
    vector<vector<bool>>cx(2*n+2,vector<bool>(n+1,false));
    vector<vector<bool>>cy(2*n+2,vector<bool>(n+1,false));
    cx[n][0]=true;
    cy[n][0]=true;
    int x,y;cin >>x>>y;
    x+=n;y+=n;
    vector<int>sx;
    vector<int>sy;
    int now=0;
    int t=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='F')now++;
        else {
            if(t==0){
                sx.push_back(now);
                t=1;
            }
            else {
                sy.push_back(now);
                t=0;
            }
            now=0;
        }
    }
    if(now!=0) {
        if (t == 0)sx.push_back(now);
        else sy.push_back(now);
    }
    for (int i = 0; i < sx.size(); ++i) {
        for (int j = 0; j <=2*n; ++j) {
            if(cx[j][i]) {
                if (i == 0) {
                    if (j + sx[i] <= 2*n) {
                        cx[j + sx[i]][i+1] =true;
                    }
                } else {
                    if (j + sx[i] <= 2*n) {
                        cx[j + sx[i]][i+1]=true;
                    }
                    if (j - sx[i] >= 0) {
                        cx[j - sx[i]][i+1]=true;
                    }
                }
            }
        }
    }
    for (int i = 0; i < sy.size(); ++i) {
        for (int j = 0; j <=2*n; ++j) {
            if (cy[j][i]) {
                if (j + sy[i] <= 2 * n) {
                    cy[j + sy[i]][i+1] =true;
                }
                if (j - sy[i] >= 0) {
                    cy[j - sy[i]][i+1] =true;
                }
            }
        }
    }
//    for (int i = 0; i < 4 * n; ++i) {
//        if (cx[i])cout << i << " ";
//    }
//    cout <<endl;
//    for (int i = 0; i < 4 * n; ++i) {
//        if(cy[i])cout <<i<<" ";
//    }
//    cout <<endl;
//    cout <<cx[x]<<" "<<cy[y]<<endl;
//    for (int i = 0; i < 2 * n; ++i) {
//        if(cx[i][sx.size()])cout <<i<<" ";
//    }
//    cout <<endl;
    if(cx[x][sx.size()]&&cy[y][sy.size()])puts("Yes");
    else puts("No");
    return 0;
}

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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}


int main()
{
    int N,a[3010]={},ans=0;
    cin>>N;

    for(int i=0;i<N;i++){
        cin>>a[i];
        ans+=a[i]-1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> vec(N);

    vector<int> odd(1000000);
    vector<int> even(1000000);

    for(int i=0;i<N;i++){
        cin>>vec[i];

        if(i%2==0){
            even[vec[i]]+=1;
        }else{
            odd[vec[i]]+=1;
        }
    }

    auto even_max=max_element(even.begin(),even.end());
    auto odd_max=max_element(odd.begin(),odd.end());

    int even_tmp=0,odd_tmp=0;

    even_tmp=*even_max;
    odd_tmp=*odd_max;

    int it_e_max=0,it_o_max=0;

    for(int i=1;i<1000000;++i){
        if(even[it_e_max]<even[i]){
            it_e_max=i;
        }
        if(odd[it_o_max]<odd[i]){
            it_o_max=i;
        }
    }


    if(it_e_max==it_o_max){
        if(even_tmp>odd_tmp){
            cout<<N-even_tmp;
        }else if(even_tmp<odd_tmp){
            cout<<N-odd_tmp;

        }else{
            N-=even_tmp;
            even.erase(even_max);
            odd.erase(odd_max);
            auto even_max=max_element(even.begin(),even.end());
            auto odd_max=max_element(odd.begin(),odd.end());

            int even_tmp=0,odd_tmp=0;

            even_tmp=*even_max;
            odd_tmp=*odd_max;

            if(even_tmp>odd_tmp){
                cout<<N-even_tmp;
            }else{
                cout<<N-odd_tmp;
            }
        }
    }else{
        cout<<N-odd_tmp-even_tmp;
    }

    cout<<endl;

}

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

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3628
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
-- end of templete



main = replicateM 5 getInt >>= \[a,b,c,d,p] -> print $ min (a*p) (b + d * max 0 (p-c))


Measured memory_bytes: 3620
def p_a():
    A, B = map(int, input().split())
    print(A * B if A < 10 and B < 10 else -1)


def p_b():
    N = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if N == i * j:
                print("Yes")
                exit()
    print("No")


import math


def p_c():
    N = int(input())
    m = int(math.sqrt(N))

    for i in reversed(range(1, m + 1)):
        if N % i == 0:
            print(i + N // i - 2)
            break


def p_d():
    a, b, x = map(int, input().split())
    if 2 * x / a ** 2 >= b:
        h = b - x / a ** 2
        w = a / 2
        ans = math.degrees(math.atan(h / w))
    else:
        h = b
        w = 2 * x / (a * b)
        ans = math.degrees(math.atan(h / w))
    print(ans)


def p_e():
    pass


def p_f():
    pass


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 38384