akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

typedef vector<int> vi;
typedef tuple<int, int, int> Node;
typedef pair<Node, int> pii;

struct Comp {
	bool operator() (pii a, pii b) {
		return a.second > b.second;
	}
};

int dx[2][9] = { {1, 1, 1, 1, 1, 2, 2, 2, 3}, {-1, -1, -1, -1, -1, -2, -2, -2, -3} };
int dy[2][9] = { {-2, -1, 0, 1, 2, -1, 0, 1, 0},{ -2, -1, 0, 1, 2, -1, 0, 1, 0 } };

int solve(int W, int H)
{
	vector< vector<char> > S(H, vector<char>(W));
	rep(y, 0, H) rep(x, 0, W) cin >> S[y][x];
	
	priority_queue<pii, vector<pii>, Comp> que;
	map<Node, int> dist;
	set<Node> done;

	rep(x, 0, W) rep(y, 0, H) if (S[y][x] == 'S')
	{
		S[y][x] = '0';
		rep(i, 0, 2) que.push(pii(Node(x, y, i), 0));
		rep(i, 0, 2) dist[Node(x, y, i)] = 0;
	}

	while (!que.empty())
	{
		Node n = que.top().first;
		int c = que.top().second;
		que.pop();

		if (done.find(n) != done.end()) continue;
		done.insert(n);

		int x = get<0>(n);
		int y = get<1>(n);
		int lr = get<2>(n);

		if (S[y][x] == 'T') return c;

		rep(i, 0, 9)
		{
			int xx = x + dx[lr][i];
			int yy = y + dy[lr][i];

			if (xx < 0 || W <= xx) continue;
			if (yy < 0 || H <= yy) continue;
			if (S[yy][xx] == 'X') continue;
			if (S[yy][xx] == 'S') continue;

			int next_c = c;
			if (S[yy][xx] != 'T') next_c += S[yy][xx] - '0';

			int next_lr = (lr + 1) % 2;
			Node next_n(xx, yy, next_lr);
			
			if (dist.find(next_n) == dist.end()) dist[next_n] = INF;
			if (next_c < dist[next_n])
			{
				dist[next_n] = next_c;
				que.push(pii(next_n, next_c));
			}
		}
	}

	return -1;
}

int main()
{
	while (1)
	{
		int W, H;
		cin >> W >> H;
		if (W == 0) return 0;

		cout << solve(W, H) << endl;
	}
}

Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int ans=0,now=1;
  rep(i,n){
    if(a[i]!=now){
      ans++;
    }else{
      now++;
    }
  }
  if(ans==n) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


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


vector<int> prime;
int ps[10000];


bool judge(int n){
	if (n == 2) return true;
	for (int i = 2; i*i <= n; i++)
		if (n % i == 0) return false;
	return true;
}


void pgen(){
	for (int i = 2; prime.size() != 10000; i++)
		if (judge(i)) prime.push_back(i);
}


void acc(){
	ps[0] = prime[0];
	for (int i = 1; i < 10000; i++)
		ps[i] = ps[i - 1] + prime[i];
}


int main(){
	int n;

	pgen();
	acc();

	while (cin >> n, n != 0) cout << ps[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 3152
N = int(input())

if(N<2):
  print(N)
elif(2<=N<4):
  print(2)
elif(4<=N<8):
  print(4)
elif(8<=N<16):
  print(8)
elif(16<=N<32):
  print(16)
elif(32<=N<64):
  print(32)
elif(64<=N):
  print(64)
  

Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                int[] costs = new int[N];
                int[] cache = new int[N];
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = scan.nextInt();
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-     2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
}

Measured memory_bytes: 57496
/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
long long mod = 1000000007LL;
long long base = 10000007;
long long large = 1000000000000000000LL;



int solve(string s){

	int n = (int)s.length();
	vector<int> pre(n,-1);
	int p = 0;
	for(int i=1;i<n;i++){
		pre[i] = p;
		if(s[i]=='0') p=i;
	}
	vector<int> dp(n,0);
	for(int i=1;i<n;i++){
		dp[i] = dp[i-1];
		if(s[i]=='1'){
			if(s[i-1]=='0'){
				int pos = pre[i-1];
				if(pos==-1) continue;
				for(int j=pos+1;j<i-1;j++){
					dp[i] = max(dp[i],dp[j-1]+i-j+1-2);
				}
			}else{
				int pos = pre[i];
				if(pos>1) dp[i] = max(dp[i],dp[pos-2]+i-pos);
			}
		}
	}
	return dp[n-1];
}
int main(){

	int n;

	string s;
	cin>>n>>s;
	vector<string> w;
	s = "0" + s;
	s = s + "00";
	string t = "0";
	for(int i=1;i<(int)s.length();i++){
		if(s[i-1]=='0'&&s[i]=='0'){
			w.push_back(t);
			t="";
		}
		t.push_back(s[i]);
	}


	int ans = 0;
	for(int i=0;i<(int)w.size();i++){
		//cout<<w[i]<<endl;
		ans+=solve(w[i]);
	}
	cout<<ans<<endl;


	return 0;
}


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

int main(){
    ll N, A, B;
    string S;
    cin >> N >> A >> B >> S;
    ll b = 0, pass = 0;
    rep(i, 0, N){
        if(S[i] == 'a' && pass < A + B){
            pass++;
            cout << "Yes" << endl;
        }else if(S[i] == 'b' && pass < A + B && b < B){
            pass++;
            b++;
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N, M;
    cin >> N;
    multiset<string> s, t;
    set<string> ls;
    REP(i, N){
        string st;
        cin >> st;
        s.insert(st);
        ls.insert(st);
    }
    cin >> M;
    REP(i, M){
        string st;
        cin >> st;
        t.insert(st);
        ls.insert(st);
    }
    int ans = 0;
    for(auto &x: ls){
        chmax(ans, (int)s.count(x)-(int)t.count(x));
    }
    cout << ans << "\n";
    return 0;
}

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

#define all(u) (u).begin(),(u).end()
#define PB push_back
#define REP(i,n) for(int i = 0;i < (n);i++)
	
using namespace std;

typedef vector<int> VI;

int stoi(string num)
{
	int ret;
	stringstream s;
	s << num;
	s >> ret;
	return ret;
}

string str;
int cur;

int rec()
{
	cur++;
	if(str[cur] != '[' && str[cur] != ']')
	{
		string t;
		while (str[cur] != '[' && str[cur] != ']')
		{
			t += str[cur];
			cur++;
		}
		cur++;
		//cout << t << endl;
		return  stoi(t) / 2 + 1;
	}
	VI vote;
	while(str[cur] != ']')
	{
		vote.PB(rec());
	}
	sort(all(vote));
	int ret = 0;
	REP(i,vote.size()/2+1)
	{
	//	cout << vote[i] << endl;
		ret += vote[i];
	}
	cur++;
	return ret;
	
}

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		cin >> str;
		cur = 0;
		cout << rec() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3140
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 305;
int n, m;
int a[maxn][maxn];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      a[i][j]--;
    }
  }
  return true;
}

int pos[maxn];
int cnt[maxn];
int del[maxn];

void getNxt(int id) {
  auto &i = pos[id];
  while (i < m && del[a[id][i]]) {
    i++;
  }
  if (i < m) {
    cnt[a[id][i]]++;
  }
}

void solve() {
  for (int i = 0; i < n; i++) {
    pos[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cnt[i] = 0;
    del[i] = false;
  }
  for (int i = 0; i < n; i++) {
    getNxt(i);
  }
  int res = inf;
  for (int it = 0; it < m; it++) {
    int todel = -1;
    for (int i = 0; i < m; i++) {
      if (del[i]) {
        continue;
      }
      if (todel == -1 || cnt[i] > cnt[todel]) {
        todel = i;
      }
    }
    res = min(res, cnt[todel]);
    del[todel] = true;
    for (int i = 0; i < n; i++) {
      if (a[i][pos[i]] == todel) {
        getNxt(i);
      }
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
n=int(input())
AB=[]
A=[]
B=[]
for _ in range(n):
    a,b = map(int,input().split())
    AB.append((a,b))
    A.append(a)
    B.append(b)
A.sort()
B.sort()
#AB = sorted(AB,key=lambda x: x[1])
med = n//2
if n%2 != 0:
    print(B[n//2]-A[n//2]+1)
else:
    p = (A[n//2] + A[n//2-1])
    q = (B[n//2] + B[n//2-1])
    print(q-p+1)

Measured memory_bytes: 118888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int R = scan.nextInt();
        int C = scan.nextInt();
        int K = scan.nextInt();
        long[][][] dp = new long[R+1][C+1][4];
        boolean[][] map = new boolean[R][C];
        int[][] cost = new int[R][C];
        for (int i = 0; i < K; i++) {
            int r = scan.nextInt()-1;
            int c = scan.nextInt()-1;
            int v = scan.nextInt();
            map[r][c] = true;
            cost[r][c] = v;
        }
        for (int i = 1; i <= R; i++) {
            for (int j = 1; j <= C; j++) {
                long max = Math.max(dp[i-1][j][0], Math.max(dp[i-1][j][1], Math.max(dp[i-1][j][2], dp[i-1][j][3])));
                dp[i][j][0] = Math.max(dp[i][j-1][0],max);
                dp[i][j][1] = dp[i][j-1][1];
                dp[i][j][2] = dp[i][j-1][2];
                dp[i][j][3] = dp[i][j-1][3];
                if(map[i-1][j-1]) {
                    dp[i][j][1] = Math.max(dp[i][j][1],Math.max(dp[i][j-1][0] + cost[i-1][j-1], max + cost[i-1][j-1]));
                    dp[i][j][2] = Math.max(dp[i][j][2],dp[i][j-1][1] + cost[i-1][j-1]);
                    dp[i][j][3] = Math.max(dp[i][j][3],dp[i][j-1][2] + cost[i-1][j-1]);
                }
            }
        }
        long ans = Math.max(dp[R][C][0], Math.max(dp[R][C][1], Math.max(dp[R][C][2], dp[R][C][3])));
        System.out.println(ans);
    }
}


Measured memory_bytes: 800464
import java.util.*;

public class Main {

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

        int first = Integer.MIN_VALUE;
        int second = Integer.MIN_VALUE;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            list.add(a);
            if (a > first) {
                second = first;
                first = a;
            } else if (a > second){
                second = a;
            }
        }

        for (int a : list) {
            if (a < first) {
                System.out.println(first);
            } else {
                System.out.println(second);
            }
        }
    }

}

Measured memory_bytes: 94816
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n), c(n);

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

    vector<ll> currentSol(3);
    vector<ll> lastSol(3);
    currentSol[0] = a[0];
    currentSol[1] = b[0];
    currentSol[2] = c[0];

    for (int i = 1; i < n; ++i)
    {
        swap(currentSol, lastSol);
        currentSol[0] = max(lastSol[1] + a[i], lastSol[2] + a[i]);
        currentSol[1] = max(lastSol[0] + b[i], lastSol[2] + b[i]);
        currentSol[2] = max(lastSol[0] + c[i], lastSol[1] + c[i]);
    }

    cout << max(max(currentSol[0], currentSol[1]), currentSol[2]);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
using ull = unsigned long long int;

ull f(ull b, ull n) {
	if (n < b) { return n; }
	else { return f(b, floor(n / b)) + (n % b); }
}

int main() {
	ull n, s;
	cin >> n >> s;

	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}
	if (n < s) {
		cout << -1 << endl;
		return 0;
	}

	for (ull b = 2; b * b <= n; ++b) {
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}

	ull res = 1;
	for (ull p = 1; p * p < n; ++p) {
		if ((n - s) % p != 0) { continue; }

		ull x = (n - s) / p + 1;
		if ((x * x <= n) || (x > n)) { continue; }

		if (f(x, n) == s) {
			if (res < 2) { res = x; }
			res = min(res, x);
		}
	}

	if (res < 2) { cout << -1 << endl; }
	else { cout << res << endl; }

	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

map<int64_t, int> prime_factor(int64_t n) {
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

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

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

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  map<ll, ll> mp;

  REP(i, n) {
    auto x = prime_factor(a[i]);

    for (auto y : x) {
      if (mp[y.first] < y.second) {
        mp[y.first] = y.second;
      }
    }
  }

  mint lcm = 1;
  for (auto x : mp) {
    lcm *= mod_pow(x.first, x.second, mod);
  }

  mint ans = 0;
  REP(i, n) { ans += lcm * modinv(a[i], mod); }

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

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    string s;
    vector<string> v;
    int k;
    cin >> s >> k;
    for(int i=0;i<s.length();i++){
        for(int j=1;j<=k;j++){
            v.push_back(s.substr(i, j));
        }
    }
    sort(v.begin(), v.end());
    string cur = v[0];
    int cnt=1;
    for(int i=0;i<v.size();i++){
        if(v[i]!= cur){
            cur = v[i];
            cnt++;
        }
        if(cnt==k){
            cout << v[i] << endl;
            break;
        }
    }
}

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

int main() {
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  
  	int a, b; cin>>a>>b;
  	for (int x = 1; x < 1e6; x++) {
    	if ( floor(x*.08) == a && floor(x*.1) == b) {
        	cout << x << endl;
          	return 0;
        }
    }
  	cout << -1 << endl;
  
	return 0;
}

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

int		main(void)
{
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
		cin >> a.at(i);
	if (a.at(0) != a.at(1))
		cout << (a.at(0) == a.at(2) ? a.at(1) : a.at(0)) << endl;
	else
		cout << a.at(2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N = 0;
	int H[100000];
	int h[100000];
	
	
	int total = 0;
	int max = 0;
	int i;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}

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

	}

	for (i = N - 2; i >= 0; i--) {
		if (h[i] == 1) {
			total += 1;
		}
		else {
			if (total > max) {
				max = total;
			}
			total = 0;
		}
		if (i == 0) {
			if (total > max) {
				max = total;
			}
		}
	}

	printf("%d\n", max);
	
	return 0;
	
}

Measured memory_bytes: 896
S = input()
longest_acgt = 0

def is_acgt(string):
    a_count = string.count("A")
    c_count = string.count("C")
    g_count = string.count("G")
    t_count = string.count("T")
    acgt_count = a_count + c_count + g_count + t_count
    string_count = len(string)
    if acgt_count == string_count:
        return True
    else:
        return False

for i in range(0, 11):
    # print(str(i) + "回目")

    
    for j in range(i + 1, 11):
        # print(str(i) + " " + str(j))
        # print(S[i:j])
        result = is_acgt(S[i:j])
        if result and len(S[i:j]) > longest_acgt:
            longest_acgt = len(S[i:j])
            pass
print(longest_acgt)



Measured memory_bytes: 3064
H, W = map(int,input().split())
A = [input() for i in range(H)]
row = [False]*H
col = [False]*W
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            row[i] = True
            col[j] = True
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(A[i][j], end = '')
        print()

Measured memory_bytes: 9028
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >>S;
    if(S=="Sunny"){
        cout<<"Cloudy";
    }
    if(S=="Cloudy"){
        cout<<"Rainy";
    }
    if(S=="Rainy"){
        cout<<"Sunny";
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t N;
  cin>>N;
 
  //vector<int64_t> A(N);
  for(int i=1; i<1000; i++){
    if((N*i)%360==0){cout<<i<<endl;
    break;}
  }
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
 // cout << N << endl;
}


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

int a[100005],n,k;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    std::sort(a+1,a+n+1);

    if(a[1]==a[n])puts(a[1]==n-1||(a[1]&&a[1]<=n/2)?"Yes":"No");
    else
    {
	for(k=1;a[k]==a[k+1];++k);
	if(a[k+1]!=a[n]||a[n]-a[k]>1)puts("No");
	else a[n]-=k,puts(a[n]>0&&a[n]<=(n-k)/2?"Yes":"No");
    }
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
using namespace std;
int n,a[N+5],s[N+5];
class FastIO
{
	private:
		#define FS 100000
		#define tc() (A==B&&(B=(A=FI)+fread(FI,1,FS,stdin),A==B)?EOF:*A++)
		#define tn (x<<3)+(x<<1)
		#define D isdigit(c=tc())
		char c,*A,*B,FI[FS];
	public:
		I FastIO() {A=B=FI;}
		Tp I void read(Ty& x) {x=0;W(!D);W(x=tn+(c&15),D);}
		Ts I void read(Ty& x,Ar&... y) {read(x),read(y...);}
}F;
int main()
{
	RI i,t=0;for(F.read(n),i=1;i<=n;++i) F.read(a[i]),t^=a[i];if(t) return puts("No"),0;
	for(sort(a+1,a+n+1),i=1;i<=n;++i) s[i]=a[i];t=unique(s+1,s+n+1)-s-1;
	return puts(t<=3&&(a[1]^a[n/3+1])==a[n]?"Yes":"No"),0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

//ここから

vector<bool> isprime;
vector<int> prime;

void Prime_Seq(int n){//nまでの素数列を形成
    isprime.resize(n+1,true);
    isprime[0]=false;
    isprime[1]=false;
    int p=0;
    for(int j=2;j<=n;j++){
        if(isprime[j]){
            prime.push_back(j);
            p++;
            for(int k=2;j*k<=n;k++){
                isprime[j*k]=false;
            }
        }
    }
}

//ここまで

int main()
{ 

    LL n;
    cin>>n;
    LL m=1;
    while(m*m<=n){m++;}
    m=m-1;
    Prime_Seq(m);
    LL ans=0;
    reverse(prime.begin(),prime.end());
    while(n!=1){
        if(!prime.empty()){
        LL p=prime.back();
        prime.pop_back();
        LL cnt=0;
        while(n%p==0){n=n/p;cnt++;}
        LL l=1;
        while(l*(l+1)/2<=cnt){l++;}
        ans=ans+l-1;
        }
        else{cout<<ans+1<<endl;return 0;}
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int cnt=1,h,hoge;
  cin>>h;
  hoge=h;
  rep(i,n-1){
    cin>>h;
    if(h>=hoge){
      hoge=h;
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int W, H, x, y;
    scanf("%d %d %d %d", &W, &H, &x, &y);

    long area = 0;
    for(int i = 0; i < H; i++){
        area += W;
    }
    
    double ans = area / 2.0;

    int judge;

    if((x == W/2.0) && (y == H/2.0)){
        judge = 1;
    }else{
        judge = 0;
    }

    printf("%lf %d", ans, judge);

    return 0;
}

Measured memory_bytes: 128
/*
*  Author: windystreet
*  Date  : 2019-04-13 20:02:03
*  Motto : Think twice, code once.
*/
#include<bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
    int a,b;
    while(cin>>a>>b){
    	if(a==b){
	    	printf("%d\n",a+b );
	    }else{
	    	a = max(a,b);
	    	printf("%d\n",a+a-1 );
	    }
    }
    
    
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("F:/in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Grand_Garden
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = 0;
            int n = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split().Select(int.Parse).ToList();
            input.Insert(0, 0);
            for (int i = 1; i < input.Count; i++)
            {
                int a = input[i] - input[i - 1];
                if (a > 0) { result += a; }
            }
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int main(void)
{
	char s[10];
	scanf("%s",s);
	
	if(s[0]=='S')
	printf("Cloudy");
	
	else if(s[0]=='C')
	printf("Rainy");
	
	else
	printf("Sunny");
	

	return 0;
}


Measured memory_bytes: 1692
#include <iostream>

int64_t gcd(int64_t a, int64_t b) {
    return b==0 ? a : gcd(b, a%b);
}

int main() {
    int64_t a,b;
    std::cin >> a >> b;
    std::cout << a*b/gcd(a,b) << std::endl;
}

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

void sort(int* num, int n);
void output(int* num, int n);

int cnt = 0;

int main(){
  int n;
  cin >> n;
  int* num;
  num = new int[n];
  for(int i = 0; i < n; i++) cin >> num[i];
  sort(num, n);
  output(num, n);
  delete[] num;
  return 0;
}

void sort(int* num, int n){
  for(int i = 0; i <= n - 1; i++){
    int minj = i;
    for(int j = i; j <= n - 1; j++){
      if(num[j] < num[minj]) minj = j;
    }
    if(i != minj) cnt++;
    int temp = num[i];
    num[i] = num[minj];
    num[minj] = temp;
  }
}

void output(int* num, int n){
  for(int i = 0; i < n; i++){
    if(i == n - 1) cout << num[i];
    else cout << num[i] << " ";
  }
  cout << endl;
  cout << cnt << endl;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
using namespace std;
int a[1010];
int main()
{
	int n,ans=0;cin>>n;
	for(int i=1;i<=n*2;i++) cin>>a[i];
	sort(a+1,a+n*2+1);
	for(int i=1;i<=2*n;i+=2) ans+=a[i];
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#! /usr/bin/env python3

import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys


def S():
    return sys.stdin.readline().rstrip()


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def LS():
    return list(sys.stdin.readline().rstrip().split())


def num2ary(n, num):
    ret = [0] * n
    x = 2 ** (n - 1)
    for i in range(n):
        if x <= num:
            num = num - x
            ret[i] = 1
        else:
            ret[i] = 0
        x = x / 2
    return ret


def main():
    n, m, x = LI()
    # print(n, m, x)
    c = []
    a = [[0] * m] * n
    # print(a)
    for i in range(n):
        z = LI()
        # print(z)
        c.append(z[0])
        # print(c)
        a[i] = z[1:]
        # print(a)
    cmin = 9999999999
    for i in range(2 ** n):
        csum = 0
        asum = [0] * m
        ary = num2ary(n, i)
        for j in range(n):
            if ary[j] == 1:
                csum = csum + c[j]
                for k in range(m):
                    asum[k] = asum[k] + a[j][k]
        # print("xxx", i, csum, asum)
        ok = 1
        for i in range(m):
            if asum[i] < x:
                ok = 0
                break
        if ok == 1 and csum < cmin:
            cmin = csum
            # print("yyy", i)
    if cmin >= 9999999999:
        print(-1)
    else:
        print(cmin)
    # N = I()
    # A = [LI() for _ in range(N)]


main()


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

typedef long long ll;
map<int,int> d1, d2;

bool prime(int n) {
    for (int d = 2; d*d <= n; d++) if (n%d == 0) return 0;
    return 1;
}

ll gcd(ll a, ll b) { return a ? gcd(b%a,a) : b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) if ((i+j)%2) {
            d1[i+j] = d2[i-j] = 0;
        }

    int need = d1.size() + d2.size();
    vector<int> primes;
    for (int p = 3; ; ++p) if (prime(p)) {
        primes.push_back(p);
        if (primes.size() == need) break;
    }

    for (auto &xy : d1) xy.second = primes.back(), primes.pop_back();
    for (auto &xy : d2) xy.second = primes.back(), primes.pop_back();

    static ll ans[505][505];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) if ((i+j)%2 == 1) {
            ans[i][j] = (ll) d1[i+j] * d2[i-j];
        }

    map<ll,int> cnt;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) if ((i+j)%2 == 0) {
            ll x = 1;
            if (i) x = lcm(x, ans[i-1][j]);
            if (j) x = lcm(x, ans[i][j-1]);
            if (i+1 < n) x = lcm(x, ans[i+1][j]);
            if (j+1 < n) x = lcm(x, ans[i][j+1]);
            ans[i][j] = x+1;
            while (cnt.count(ans[i][j])) ans[i][j] += x;
            ++cnt[ans[i][j]];
        }

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

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            assert(ans[i][j] <= ll(1e15));
            assert(++cnt[ans[i][j]] < 2);
            if ((i+j)%2 == 0)  {
                for (int di = -1; di <= 1; di++)
                    for (int dj = -1; dj <= 1; dj++) if (abs(di) + abs(dj) == 1) {
                        int ni = i + di, nj = j + dj;
                        if (ni >= 0 && ni < n && nj >= 0 && nj < n) {
                            assert(ans[i][j] % ans[ni][nj] == 1);
                        }
                    }
            }
        }

    return 0;
}


Measured memory_bytes: 12928
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <bitset>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define MP make_pair
#define PB push_back
const int N=10010;
const int INF=1<<30;
vector<pi> v[N];
int Prim(int n){
    int ans=0,dis[n];
    priority_queue<pi,vector<pi>,greater<pi> >pq;
    pi temp; 
    bitset<N>b;
    dis[0]=0;
    b.reset();
    b[0]=true;
    for(int i=1;i<n;i++)dis[i]=INF;
    for(int i=0;i<v[0].size();i++){
        dis[v[0][i].S]=v[0][i].F;
        pq.push(v[0][i]);
    }
    n--;
    while(n>0){
        temp=pq.top();
        pq.pop();
        if(b[temp.S])continue;
        b[temp.S]=true;
        ans+=dis[temp.S];
        for(int i=0;i<v[temp.S].size();i++)if(!b[v[temp.S][i].S]){
            if(dis[v[temp.S][i].S]>v[temp.S][i].F){
                dis[v[temp.S][i].S]=v[temp.S][i].F;
                pq.push(MP(dis[v[temp.S][i].S],v[temp.S][i].S));
            }
        }
        n--;
    }
    return ans;
}
int main(){
    int n,m,l,r,temp;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&l,&r,&temp);
        v[l].PB(MP(temp,r));
        v[r].PB(MP(temp,l));
    }
    printf("%d\n",Prim(n));
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  long long int A[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long int  a_1 = 0;
  long long int  a_2 = 0;
  sort(A,A+N);
  for(int i = N-1; i >= 1; i--) {
    if(A[i] == A[i-1]) {
      if(a_1 == 0) {
        a_1 = A[i];
        i -= 1;
      } else {
        a_2 = A[i];
        break;
      }
    }
  }
  cout << a_1 * a_2 << endl;




}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
	int n,l,r,ans=0;
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&l,&r);
		ans+=(r-l)+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
mod utils {
    use std::error::Error;
    use std::io::stdin;
    use std::str::FromStr;

    #[allow(dead_code)]
    pub fn read_line<T>() -> Result<Vec<T>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        let mut line = String::new();
        let _ = stdin().read_line(&mut line)?;
        let parsed_line = line.split_whitespace()
            .map(|x| x.parse::<T>())
            .collect::<Result<Vec<T>, T::Err>>()?;

        Ok(parsed_line)
    }

    #[allow(dead_code)]
    pub fn read_lines<T>(n: usize) -> Result<Vec<Vec<T>>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        (0..n).map(|_| read_line()).collect()
    }
}

fn solve() -> Result<(), Box<std::error::Error>> {
    let header = utils::read_line::<usize>()?;
    let n_nodes = header[0];
    let n_edges = header[1];
    let edges = utils::read_lines::<i32>(n_edges)?;
    let mut distances = vec![vec![None as Option<i32>; n_nodes]; n_nodes];

    for i in 0..n_nodes {
        distances[i][i] = Some(0);
    }

    // initial distance
    for edge in edges {
        distances[edge[0] as usize][edge[1] as usize] = Some(edge[2]);
    }

    // update distances
    for k in 0..n_nodes {
        for i in 0..n_nodes {
            for j in 0..n_nodes {
                let d_ikj = if let (Some(d_ik), Some(d_kj)) = (distances[i][k], distances[k][j]) {
                    Some(d_ik + d_kj)
                } else {
                    None
                };

                distances[i][j] = if let Some(d_ij) = distances[i][j] {
                    if let Some(d_ikj) = d_ikj {
                        Some(std::cmp::min(d_ij, d_ikj))
                    } else {
                        Some(d_ij)
                    }
                } else {
                    d_ikj
                };
            }
        }
    }

    let has_negative_cycle = distances
        .iter()
        .enumerate()
        .find(|&(i, row)| (*row)[i].unwrap_or(0) < 0)
        .is_some();

    if has_negative_cycle {
        println!("NEGATIVE CYCLE");
        return Ok(());
    }

    for row in distances {
        let row_string: String = row.iter()
            .map(|d_opt| match *d_opt {
                Some(d) => d.to_string(),
                None => "INF".to_string(),
            })
            .collect::<Vec<String>>()
            .join(" ");
        println!("{}", row_string);
    }
    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("{}", err),
        _ => (),
    };
}



Measured memory_bytes: 5052
def is_prime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False

    i = 3
    while i <= x ** (1/2):
        if x % i == 0:
            return False
        i += 1

    return True


N = int(input())
result = 0
for _ in range(N):
    x = int(input())
    if is_prime(x):
        # print('{} is prime'.format(x))
        result += 1

print(result)



Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  
  vector<int> p(n);
  rep(i, n) cin >> p.at(i);
  
  int ans = 0;
  rep1(i, n-2) {
    bool a = (p.at(i-1)<p.at(i) and p.at(i)<p.at(i+1));
    bool b = (p.at(i-1)>p.at(i) and p.at(i)>p.at(i+1));
    if(a or b)
      ans++;
  }
    
  cout << ans << "\n";

}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""
    ll mod=(int)1e9+7;
    int b[N];
ll stup(ll x,ll m)
{
    ll o=1;
    while(m)
    {
        if (m&1)
        {
            o*=x;
            o%=mod;
        }
        x*=x;
        x%=mod;
        m>>=1;
    }
    re o;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,i,a;
    cin>>n;
    map<int,int> m;
    fo(i,n)
    {
        cin>>a;
        b[i]=a;
        for(int j=2;j*j<=a;j++)
        {
            if (a%j==0)
            {
                int c=0;
                while(a%j==0)
                {
                    a/=j;
                    c++;
                }
                m[j]=max(m[j],c);
            }
        }
        if (a!=1)
        {
            m[a]=max(m[a],1);
        }
    }
    ll ans=1;
    for(auto j:m)
    {
        ans*=stup(j.fi,j.se);
        ans%=mod;
    }
    ll o=0;
    fo(i,n)
    {
        o+=ans*stup(b[i],mod-2)%mod;
        o%=mod;
    }
    cout<<o;
}


Measured memory_bytes: 768
import java.util.Scanner;

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

        int[][] rst = new int[50][3];

        for(int i=0; i<50; i++) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            rst[i][0] = m;
            rst[i][1] = f;
            rst[i][2] = r;
            if(m == -1 && f == -1 && r == -1) {
                break;
            }
        }

        for(int i=0; i<rst.length; i++) {
            if(rst[i][0] == -1 && rst[i][1] == -1 && rst[i][2] == -1) {
                break;
            } else if(rst[i][0] == -1 || rst[i][1] == -1) {
                System.out.println("F");
            } else if(rst[i][0] + rst[i][1] >= 30 && rst[i][0] + rst[i][1] < 50 && rst[i][2] >= 50) {
                System.out.println("C");
            } else if(rst[i][0] + rst[i][1] >= 80) {
                System.out.println("A");
            } else if(rst[i][0] + rst[i][1] >= 65 && rst[i][0] + rst[i][1] < 80 ) {
                System.out.println("B");
            } else if(rst[i][0] + rst[i][1] >= 50 && rst[i][0] + rst[i][1] < 65 ) {
                System.out.println("C");
            } else if(rst[i][0] + rst[i][1] >= 30 && rst[i][0] + rst[i][1] < 50 ) {
                System.out.println("D");
            } else {
                System.out.println("F");
            }
        }
    }
}



Measured memory_bytes: 26308
#include <stdio.h>

int main(void)
{
    int a, b, c, i;

    while (scanf("%d %d", &a, &b) != EOF) {
        c = a + b;
        for (i = 1; (c /= 10) != 0; ++i) {}
        printf("%d\n", i);
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstring>
using namespace std;
char s[100005];
int main()
{
	cin >> s;
	int sum = 0;
	int len = strlen(s);
	int p = len/2;
	for(int i = 0;i < len;i++)
	{
		if(s[i]=='p')
		sum++;
	}
	int ans = p - sum;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * ?????¬??????????????????
 *
 * @author B7078
 *
 */
class CookingCurry {
	int X = 0; // ??????????????????????????°
	double Y = 0.0; // ?????????????°´??????
	double c0; // ????????????????????¬????????????

	void calcXY(int r0, int w0, int C, int R) { // ??????????????????????????°??¨?°´??????????¨????
		c0 = r0 / w0;
		while (r0/w0 < C) { // ?????????????????????????????§??°?????????
			++X;
			r0 += R;
		}
		System.out.println(X);
		X = 0;
	}
}

public class Main {

	public static void main(String[] args) throws IOException {
		CookingCurry cc = new CookingCurry();
		int r0 = 0; // ?????¬?????????
		int w0 = 0; // ?°´
		int C = 0; // Best???????????????????????¬?????????
		int R = 0;// ?????????????????????[g]
		double Y = 0.0; // ??????????°´[L]
		String str;
		String recipe[] = new String[4]; // ??¬??????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// ???????????\???
		while (true) {
			str = br.readLine();
			recipe = str.split(" ", 0);

			r0 = Integer.parseInt(recipe[0]);
			w0 = Integer.parseInt(recipe[1]);
			C = Integer.parseInt(recipe[2]);
			R = Integer.parseInt(recipe[3]);
			if (r0 == 0 && w0 == 0 && C == 0 && R == 0) {
				break;
			}
			cc.calcXY(r0, w0, C, R);
		}

	}

}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 2005;

/* ...o(^-^)o... */


int main(){
    double r; cin >> r;
    setpre(10); out(r*(double)44/(double)7);
}

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

int main() {
  vector<char> s(4);
  int i;
  for (i = 0; i < 4; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]

S.sort()
A = sum(S)
if A % 10 == 0:
    m = 0
    for s in S:
        if s % 10 != 0:
            m = s
            break
    A -= s
    if m == 0:
        A = 0
print(A)

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

int main() {
int N,K;
cin>>N>>K;
int A[200010]={};
int B[200010]={};
int C[200010]={};
for(int i=0; i<N; i++){
   int a;
    cin>>a;
    A[i]=a;
}
int t=0;
while(t<K){
for(int i=0; i<N; i++){
   int b=max(i-A[i],0);
   int c=min(A[i]+i,N);
  B[b]+=1; B[c+1]+=(-1);
  
    
}
for(int q=0; q<=N;q++){
    if(0<q) B[q]+=B[q-1];
}


for(int i=0; i<N; i++){
A[i]=B[i];
B[i]=0;
}
bool s=true;
for(int u=0; u<N; u++){
    if(A[u]!=N){ s=false; break;}
}
if(s==true){break;}
t++;

}

for(int i=0; i<N; i++){
    cout<<A[i]<<endl;
}
}

Measured memory_bytes: 5196
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int l = s.length();
    int lt = t.length();
    vector<char> str(l, '?');
    for (int i=0; i<l; ++i){
        if(s[i] != '?'){
            str[i] = s[i];
        }
    }
    bool key = false;
    for (int i=l-lt; i>=0; --i){
        if(key){break;}
        if(s[i] == t[0] || s[i] == '?'){
            bool key_insert = true;
            for (int j=0; j<lt; ++j){
                if(!(s[i+j] == t[j] || s[i+j] == '?')){
                    key_insert = false;
                    break;
                }
            }
            if(key_insert){
                for (int j=0; j<lt; ++j){
                    str[i+j] = t[j];
                }
                key = true;
            }
        }
    }
    if(!key){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    else {
        for (int i=0; i<l; ++i){
            if(str[i] == '?'){
                str[i] = 'a';
            }
        }
        for (int i=0; i<l; ++i){
            cout << str[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 888
import sys
from io import StringIO
import unittest

def resolve():
    lines = sys.stdin.readlines()
    lines = list(map(lambda x: int(x.rstrip()), lines))
    n = lines[0]
    i = 1
    for c in range(1, n+1):
        i = lines[i]
        if i == 2:
            print(c)
            return
    print(-1)
    
resolve()

Measured memory_bytes: 93004
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int H,W,K;
vector<string> S(10);

int main(){
    cin>>H>>W>>K;
    rep(i,H) cin>>S[i];

    int ans=100100100;
    for(int n=0;n<1<<(H-1);n++){
        int group=0;
        vector<int> id(H);
        vector<int> white={0};
        for(int i=0;i<H;i++){
            id[i]=group;
            if(n>>i&1){
                group++;
                //cout<<"group++"<<endl;
                white.push_back(0);
            }
        }

        int res=group;
        bool first=true;
        //cout<<"n="<<n<<endl;
        for(int j=0;j<W;j++){
            //cout<<" j="<<j<<endl;
            for(int i=0;i<H;i++){
                //cout<<"  (i,j)=("<<i<<","<<j<<")"<<endl;
                if(S[i][j]=='1'){
                    white[id[i]]++;
                    //cout<<"     white["<<id[i]<<"]="<<white[id[i]]<<endl;
                    if(white[id[i]]>K && first){
                        goto a;
                    }else if(white[id[i]]>K){
                        j--;
                        res++;
                        fill(white.begin(),white.end(),0);
                        first=true;
                        //cout<<"  <|="<<j+1<<">"<<endl;
                        goto b;
                    }
                }
            }
            first=false;
            b:;
        }
        ans=min(ans,res);
        a:;
        //cout<<"[ans="<<ans<<"]"<<endl;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256