akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  if(s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
  } else if(s.size() == 26) {
    bool flag[26] = {false};
    for(int i = 25; i >= 0; i--) {
      flag[(int)(s[i] - 'a')] = true;
      if(s[i] > s[i-1]) {
        for(int j = 0; j <= 25; j++) {
          if(flag[j] && (char)('a' + j) > s[i-1]) {
            string ss = s.substr(0, i - 1);
            cout << ss << (char)('a' + j) << endl;
            return 0;
          }
        }
      }
    }
  } else {
    bool flag[26] = {false};
    rep(i,s.size()) {
      flag[(int)(s[i] - 'a')] = true;
    }
    rep(i,26) {
      if(!flag[i]) {
        cout << s << (char)('a' + i) << endl;
        return 0;
      }
    }
  }

  return 0;

}


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

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    
    public static void main(String[] args) {
        int N = nint();
        char[] S = nchars();
        for (int i = 0; i < S.length; i++) {
            int val = S[i] + N;
            if (val > 'Z') val -= 26;
            S[i] = (char) val;
        }
        String ans = new String(S);
        System.out.println(ans);
    }
        

    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(0, N, 0);
    }

    @Deprecated
    private static int[] nints(int padL, int N, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(0, N, 0);
    }

    static long[] nlongs(int padL, int N, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(0, N, 0);
    }

    static double[] ndoubles(int padL, int N, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>

int main (){
  int h,w,i,hi,wi;

  for ( i = 1; 1; i++){
    scanf("%d %d",&h, &w);
    if ( h ==0 && w == 0)
      break;
    for ( hi = 0; hi < h; hi++){
      for ( wi = 0; wi < w; wi++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int r, c;
    cin >> r >> c;
    vector<vector<char>> grid(r, vector<char>(c));
    for(int i = 0; i < r; i++)for(int j = 0; j < c; j++) cin >> grid[i][j];
    vector<vector<int>> ans(r, vector<int>(c,0));
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            if(grid[i][j] == '.') {
                int cnt = 0;
                for(int k = 0; k < 8; k++) {
                    int x = i + ddx[k];
                    int y = j + ddy[k];
                    if(x >= 0 && x < r && y >= 0 && y < c && grid[x][y] =='#') cnt++;
                }
                ans[i][j] = cnt;
            }
        }
    }
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            if(grid[i][j] == '#') {
                cout << '#';
            }else{
                cout << ans[i][j];
            }
        }
        cout << endl;
    }
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool flag = true;
  for (int i = 1; i * K <= 1000; i++) {
    if (A <= i * K && i * K <= B) {
      cout << "OK" << endl;
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "NG" << endl;
  }
}

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

#define ii pair<int, int>
#define vi vector<int>
#define LL long long int 
#define VLL vector<LL>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define INF int(1e9)
#define LD long double
#define cd complex<LD>
#define TAM int(1e5 + 5)

using namespace std;

const LD PI = acos(-1);
 
void fft(vector<cd> & a, bool invert) {
    LL n = a.size();
    if (n == 1)
        return;
 
    vector<cd> a0(n / 2LL), a1(n / 2LL);
    for (int i = 0; 2 * i < n; i++) {
        a0[i] = a[2LL*i];
        a1[i] = a[2LL*i+1LL];
    }
    fft(a0, invert);
    fft(a1, invert);
 
    LD ang = 2LL * PI / n * (invert ? -1LL : 1LL);
    cd w(1LL), wn(cos(ang), sin(ang));
    for (int i = 0; 2 * i < n; i++) {
        a[i] = a0[i] + w * a1[i];
        a[i + n/2] = a0[i] - w * a1[i];
        if (invert) {
            a[i] /= 2;
            a[i + n/2] /= 2;
        }
        w *= wn;
    }
}
 
vector<LL> multiply(vector<LL> const& a, vector<LL> const& b) {
    vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
    LL n = 1;
    while (n < a.size() + b.size()) 
        n <<= 1;
    fa.resize(n);
    fb.resize(n);
 
    fft(fa, false);
    fft(fb, false);
    for (int i = 0; i < n; i++)
        fa[i] *= fb[i];
    fft(fa, true);
 
    vector<LL> result(n);
    for (int i = 0; i < n; i++)
        result[i] = round(fa[i].real());
    return result;
}

int main () {
    ios_base::sync_with_stdio(false);
    LL n, k;
    cin >> n >> k;
    vector<LL> a(TAM), b(TAM), c(TAM);

    map<int, int> counter;

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

    LL ans = 0, s = 0;

    for(int i = c.size()-1; i>=0; i--){
        ans+=(max(0LL, min(c[i], k-s)))*i;
        s+=c[i];

        if(s>=k)
            break;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a + b + c >21) cout << "bust" << endl;
    else cout << "win" <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long; using uint = unsigned int; using uInt = unsigned long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rer(i,l,r) for(int i=(l); i<=(r); ++i)
#define gnr(i,l,r) for(int i=(r); i>=(l); --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
#define fil(a,v) memset((a),v,sizeof(a))
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;


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

  cin>>n>>m>>q; int c[n][m]={}; V(int)b[n]; rep(i,n)b[i].eb(-1);
  rep(i,n)rep(j,m){
    cin>>cf;
    if(cf=='#'){
      b[i].eb(j);
    }
  }
  rep(i,n)b[i].eb(m-1);
  int col=1;
  rep(i,n){
    if(b[i].size()==2){
      continue;
    }
    rer(j,1,b[i].size()-1){
      if(j==b[i].size()-1)col--;
        rer(k,b[i][j-1]+1,b[i][j])c[i][k]=col;
        col++;
    }
  }
  int id=0;
  if(b[0].size()==2)rep(i,n)if(b[i].size()>2){id=i; break;}
  rep(i,m)rep(j,id)c[j][i]=c[id][i];
  id=n-1;
  if(b[n-1].size()==2)gnr(i,0,n-1)if(b[i].size()>2){id=i; break;}
  rep(i,m)gnr(j,id+1,n-1)c[j][i]=c[id][i];
  rer(i,1,n-1){
    if(b[i].size()==2)rep(j,m)c[i][j]=c[i-1][j];
  }
  rep(i,n)rep(j,m)cout<<c[i][j]<<(j==m-1?'\n':' ');
}

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

int main(){
	int l,r;
	int d;
	cin>>l>>r>>d;
	
	int ans=r/d-(l-1)/d;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint K, T; cin >> K >> T;
    vec<lint> a_list(T);
    range(i, 0, T) cin >> a_list.at(i);
    lint max_a = 0, rest_a = 0;
    range(i, 0, T) {
        rest_a += a_list.at(i);
        max_a = max(max_a, a_list.at(i));
    }
    rest_a -= max_a;
    cout << max(max_a - rest_a - 1, 0LL) << "\n";
}

Measured memory_bytes: 256
n=gets.to_i
l=gets.split.map(&:to_i).sort

cnt = 0
(2...n).each{|i|
  (1...i).each{|j|
    min_k = l[i]-l[j]
    cnt += j - ((0...j).bsearch{|k| min_k < l[k]} || j)
  }
}
p cnt

Measured memory_bytes: 1788
import bisect

n = int(input())

a = sorted([int(x) for x in input().split()])
b = sorted([int(x) for x in input().split()])
c = sorted([int(x) for x in input().split()])

res = 0
for bb in b:
    b_res = bisect.bisect_left(a, bb)
    c_res = len(c) - bisect.bisect_right(c, bb)
    res += (b_res*c_res)

print(res)

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

#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vll vector<long long>
#define vin(v, n) for (ll i = 0ll; i < n; i++) cin >> v[i];
#define vout(v) for (auto i=v.begin();i!=v.end(); i++) cout << (*i) << " ";cout << nl
#define fill(a,val) memset(a,val,sizeof(a))
#define all(x) x.begin(), x.end()
#define sortall(x) sort(x.begin(), x.end())
#define arrSort(x,n) sort(x,x+n)
#define rarrSort(x,n) sort(x,x+n,greater<ll>())
#define rsortall(x) sort(x.begin(), x.end(),greater<ll>())
#define ll long long
#define ld long double
#define sp " "
#define nl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define maxv(v) *(max_element(v.begin(),v.end()))
#define minv(v) *(min_element(v.begin(),v.end()))
#define prec(n) fixed<<setprecision(n)
#define llsetBits(x) __builtin_popcountll(x)            //counts number of set bits in ll x
#define llcountTz(x) __builtin_ctzll(x)                 //counts trailing zeroes in ll x
#define debug(x) cout << #x << " " << x << "\n"; 
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << "\n";
#define debug3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << "\n";
#define PI 3.14159265358979323846264338327950l;

ll gcd(ll a, ll b){if(b==0) return a; return gcd(b,a%b);}
ll lcm(ll a, ll b){return (a*b)/gcd(a,b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
bool isPrime(ll n);

const ll mod = 1e9+7ll;

void solve(ll testCaseNo)
{
	ll n;
	cin >> n;
	ll h[n];
	ll dp[n];
	vin(h,n);
	dp[0]=0ll;
	dp[1ll]=abs(h[1]-h[0]);
	for(ll i=2ll;i<n;i++)
	{
		dp[i]=min(dp[i-2ll]+abs(h[i-2ll]-h[i]),dp[i-1ll]+abs(h[i-1ll]-h[i]));
	}
	cout << dp[n-1ll];
}

int main()
{
	fio()
	ll t=1ll;
	//cin >> t;
	ll tTemp=1ll;
	while (tTemp<=t) {solve(tTemp);tTemp++;}
	return 0;
}
bool isPrime(ll n)
{
	for(int i=2;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
} 


Measured memory_bytes: 5164
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
    static int dp[];
    static ArrayList<Integer>arr;
    public static void main (String[] args)
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        ArrayList<Integer>six=new ArrayList<>(),nine=new ArrayList<>();
        int i=6;
        while(i<=100000){
            six.add(i);
            i=i*6;
        }
        i=9;
        while(i<=100000){
            nine.add(i);
            i=i*9;
        }
        arr=new ArrayList<>();
        arr.addAll(six);
        arr.addAll(nine);
        arr.add(1);
        dp=new int[n+1];
        Arrays.fill(dp,(int)1e9);
        System.out.println(r(n));
    }
    static int r(int n){
        /*if(n==0){
            return 0;
        }
        if(n<0){
            return (int)1e9;
        }
        if(dp[n]!=-1){
            return dp[n];
        }
        int min=(int)1e9;
        for (int i =arr.size()-1; i>=0; i--) {
            min=Math.min(min,1+r(n-arr.get(i)));
        }
        return dp[n]=min;*/
        dp[0]=0;
        for(int i=1;i<=n;i++){
            for(int j=0;j<arr.size();j++){
                if(i-arr.get(j)>=0) {
                    dp[i] = Math.min(dp[i], dp[i - arr.get(j)]);
                }
            }
            dp[i]++;
        }
        return dp[n];
    }
}

Measured memory_bytes: 22100
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let mut a = read_as_vec::<usize>();
    let mut ans: Vec<usize> = vec![];
    'outer: while a.len() > 0{
        for i in (0..a.len()).rev(){
            if a[i] == i+1{
                a.remove(i);
                ans.push(i+1);
                continue 'outer;
            }
        }
        println!("-1");
        return;
    }

    ans.reverse();
    for x in ans{
        println!("{}", x);
    }
}


Measured memory_bytes: 4352
a = '2000 20000000'
a = input()
d = a.split()
n = int(d[0])
y = int(d[1])

a = -1
b = -1
c = -1
for k in range(0,n+1):
    for j in range(0,n+1):
        i = n - k - j
        if(i<0):
            break
        sum_ = 10000 * i + 5000 * j + 1000 * k
        if(sum_<y):
            break
        if(sum_==y):
            a = i
            b = j
            c = k
            break

print(("%d %d %d") %(a,b,c))


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
    int H,W;
    for(;;){
        scanf("%d%d", &H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

void change(char *,char *,int);

int main(void)
{
  int len;
  char s[101];
  char t[101];

  scanf("%s",s);
  scanf("%s",t);

  len = strlen(s);

  change(s,t,len);

  return 0;

}

void change(char *pt,char *pt1,int n)
{
  int count = 0;
  int m = n - 1;
  void sort(char *,char *);
  for(int i = 0;i < n;i++){
    sort(pt,pt + m);
    for(int j = 0;j < n - 2;j++){
      sort(pt + m - j,pt + m - (j + 1));
    }
    if(strcmp(pt,pt1) == 0){
      printf("Yes");
      break;
    }
    count++;
  }
  if(count == n){
    printf("No");
  }
}

void sort(char *p0,char *p1)
{
    int tmp;
    tmp = *p0;
    *p0 = *p1;
    *p1 = tmp;
}


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

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

  vector<int> d(N);
  rep(i,N) cin >> d.at(i);
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());

  vector<int> mochi(1, d.at(0));
  rep(i,N) {
    if (mochi.at(mochi.size()-1) > d.at(i)) { mochi.push_back(d.at(i)); }
  }
  cout << mochi.size() << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    if (s[0] == s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  vector<int> now = A;
  for(int i(0);i<K;i++){
    vector<int> B(N);
    for(int j(0);j<N;j++){ 
      B[max(0,j-A[j])]++;
      if(j+A[j]+1 < N){
        B[j+A[j]+1]--;
      }
    }
    for(int j(1);j<N;j++){ 
      B[j] += B[j-1];
    }
    A = B;
    bool flag = true;
    for(int j(0);j<N;j++){
      if(A[j] != N) flag = false;
    }
    if(flag) break;
  }
  for(int i(0);i<N;i++){
    cout << A[i] << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 5544
/**
 * @Author:      H S-J
 * @DateTime:    2017-11-11 20:07:37
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int X, Y, Z;
    cin >> X >> Y >> Z;
	cout << floor((X-Z)/(Y+Z)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N; cin >> N;
    vector<ll> A(N+1,0);
    REP(i,N) cin >> A[i];
    ll ans = 0;
    REP(i,N){
        if(A[i]==0) continue;
        if(A[i+1]==0){
            ans += (A[i]/2)*2;
        }else{
            ans += (A[i]%2 ? A[i]+1:A[i]);
            if(A[i]%2) A[i+1]-=1;
        }
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    ll c = GCD(a, b);
    vll y;
    repb(i, 1, (int)(sqrt(c)+1))
    {
        if(c % i == 0)
        {
            y.push_back(i);
            if(i*i != c)
                y.push_back(c/i);
        }
    }
    sort(y.rbegin(), y.rend());
    cout << y[k-1] << endl;
}

Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

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

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


const ll N=2e5+5;


int main()
{ 

IOS;

ll n;cin>>n;

vl a(n);
FOR(i,n)cin>>a[i];
ll c=0;

sort(all(a));

for(int i=0;i<n;i++){
  for(int j=i+1;j<n;j++){
    for(int k=j+1;k<n;k++){
      if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]&&a[i]+a[j]>a[k])
   c++;
   // d3(a[i],a[j],a[k]);
    }
  }
}


d1(c);
//end_routine();

return 0;
 
 }


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

int main(){
  int n,k;cin>>n>>k;
  vector<int> a(n,0);
  REP(i,k){
      int d;cin>>d;
      REP(j,d){
          int tmp;cin>>tmp;tmp--;
          a.at(tmp)++;
      }
  }
  
  int ans=0;
  REP(i,n) if(!(a.at(i))) ans++;

  cout<<ans;
}

Measured memory_bytes: 3628
program main
implicit none
integer A,B,C,D
integer L,R
 
read(*,*) A, B, C, D
L=A+B
R=C+D
if(L>R)then
	write(*,*) "Left"
elseif(L<R)then
	write(*,*)	"Right"
else
	write(*,*) "Balanced"
endif
end program

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

using namespace std;
typedef long long ll ;
int main(){
  int n ,l;
  cin >> n >> l;
  vector<string > tmp(n);
  for(int i=0;i<n;i++){
    cin >> tmp[i];
  }
  sort(tmp.begin(),tmp.end());
  for(auto it: tmp){
    cout << it;
  }
  cout <<endl;
}


Measured memory_bytes: 256
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($N,$M,$X) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

for($i=0;$i<$N;$i++) {
  $A[] = array_map('intval',explode(" ",trim(fgets(STDIN))));

}
$ans = 10**9;
for($mask = 0;$mask < (1 << ($N)); ++$mask) {
  $m=array();
  for($i=0;$i<$N;++$i) {
    if ($mask >> $i & 1) {
      //使う
      $m[]=$i;
    }
  }
  $ans = min($ans,gettotal($m));
}
if ($ans == 10**9) $ans=-1;
printf("%d\n",$ans);
function gettotal($used)
{
  global $A,$M;
  $tot = 0;
  $m=array_fill(0,$M,0);
  foreach($used as $v) {
    for($i=1;$i<=$M;$i++) {
      $m[$i-1]+=$A[$v][$i];
    }
    $tot+=$A[$v][0];
  }
  //printf("%d\n",$tot);
  if (isok($m)) {
    return $tot;
  }
  return 10**9;
}
function isok($m)
{
  global $M,$X;
  for($i=0;$i<$M;$i++) {
    if ($m[$i]<$X)
      return false;
  }
  return true;
}


Measured memory_bytes: 16108
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val x = nextInt()
    val a = nextInt()
    val b = nextInt()
    println(x - ((x - a) / b) * b - a)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31680
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

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

    int i = 0;
    char c = n[0];
    if (n[0] != n[1]) {
        i = 1;
        c = n[1];
    }

    for (int idx = i; idx < i + 3; idx++) {
        if (n[idx] != c) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
ll ar[200005];
ll br[200005];

void solve()
{
    ll n,m,a,t,b,c,i,j,l=1,r=0,k=0,kk=0,z=0,ans=0,sum=0,y=0,x=0,s1,sk;
    vector < ll > v,vv;
    string s;

    cin >> a >> b >> c >> k;

    if(k<=a)
    {
        cout << k << endl;
    }
    else if(k<=a+b)
    {
        cout << a << endl;
    }
    else
    {
        cout << 2*a+b-k << endl;
    }

}

int main()
{
    int t;
    solve();
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

// http://koturn.hatenablog.com/entry/2018/08/01/010000
template <typename T, typename U>
vector<U> make_vector(T&& n, U&& val) {
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
decltype(auto) make_vector(T&& n, Args&&... args) {
  return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...));
}

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<vi32> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi32 a(n), b(n);
  rep(u, n) {
    for (int v : g[u]) {
      if (s[v] == 'A') a[u] += 1;
      if (s[v] == 'B') b[u] += 1;
    }
  }
  vector<bool> disable(n);
  queue<int> q;
  rep(u, n) {
    if (a[u] == 0 || b[u] == 0) {
      disable[u] = true;
      q.push(u); 
    }
  }
  while (sz(q)) {
    int u = q.front();
    q.pop();
    for (int v : g[u]) {
      if (disable[v]) continue;
      if (s[u] == 'A') a[v]--;
      if (s[u] == 'B') b[v]--;
      if (a[v] == 0 || b[v] == 0) {
        disable[v] = true;
        q.push(v); 
      }
    }
  }
  rep(u, n) {
    if (!disable[u]) yes();
  }
  no();
}


Measured memory_bytes: 15468
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T &a, const T &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T> inline bool chmax(T &a, const T &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll N;
    cin >> N;
    vl A(N);
    FOR(i, 0, N) cin >> A[i];
    ll DP[N][2];
    FOR(i, 0, N) FOR(j, 0, 2) DP[i][j] = -LINF;
    DP[0][0] = A[0];
    FOR(i, 1, N) {
        DP[i][0] = A[i] + max(DP[i - 1][0], DP[i - 1][1]);
        DP[i][1] = -A[i] + max(DP[i - 1][0] - 2 * A[i - 1],
                               DP[i - 1][1] + 2 * A[i - 1]);
    }
    cout << max(DP[N - 1][0], DP[N - 1][1]) << endl;
}

Measured memory_bytes: 2560
def is_prime(x):
    if x == 0 or x == 1:
        return False
    i = 2
    while i*i <= x:
        if x%i == 0:
            return False
        i += 1
    return True

n = int(input())
ans = 0
for i in range(n):
    ans += is_prime(int(input()))
print(ans)


Measured memory_bytes: 5612
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		if(a == 9 || a == 19 || a == 29 || a == 39 || a == 49 || a == 59 || a == 69 || a == 79 || a == 89 || a == 90 || a == 91 || a == 92 || a == 93 || a == 94 || a == 95 ||a == 96 || a == 97 || a == 98 || a == 99){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  string s,t;
  cin >> s >> t;
  int ns = s.length();
  int nt = t.length();
  bool good = nt == ns+1;
  if (good) t.pop_back();
  if (good && t == s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3612
N = int(input())
a = list(map(int, input().split()))
a.sort()
search = [i for i in range(a[0], a[-1]+1)]
ans = 100000

cost = [0] * len(search)
for i in range(len(search)):
    for j in range(len(a)):
        cost[i] += (search[i] - a[j])**2


print(min(cost))


Measured memory_bytes: 3060
while True:
    m,f,r = map(int,input().split())
    if m==f==r==-1:
        break
    if m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print('A')
    elif m+f>=65:
        print('B')
    elif m+f>=50:
        print('C')
    elif m+f>=30:
        if r>=50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int v = Integer.parseInt(str[0]);
        int e = Integer.parseInt(str[1]);


        int[][] map = new int[v][v];
        for(int i=0; i<v; i++) Arrays.fill(map[i], -Integer.MAX_VALUE / 2);
        for(int i=0; i<v; i++) map[i][i] = 0;


        for(int i=0; i<e; i++){
            str = br.readLine().split(" ");
            int s = Integer.parseInt(str[0]);
            int t = Integer.parseInt(str[1]);
            map[s][t] = 1;
        }

        for(int k=0; k<v; k++){
            for(int i=0; i<v;i++){
                for(int j=0;j<v;j++){
                    if(map[i][j] < map[i][k] + map[k][j]){
                        map[i][j] = map[i][k] + map[k][j];
                    }
                }
            }
        }

        boolean closed = false;
        for(int i=0; i<v; i++){
            if(map[i][i] != 0){
                closed = true;
                break;
            }
        }

        if(!closed){
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 26212
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int calc(int a, int L) {
	stringstream ss; ss << a;
	string s = ss.str();
	while (s.length() < L) s = '0' + s;
	sort(s.begin(), s.end());
	stringstream ss1(s);
	int mini; ss1 >> mini;
	reverse(s.begin(), s.end());
	stringstream ss2(s);
	int maxi; ss2 >> maxi;
	return maxi - mini;
}

int main() {
	for (;;) {
		int a, L; cin >> a >> L;
		if (a == 0 && L == 0) break;
		map<int, int> m;
		m[a] = 0;
		for (int i = 1; ; i++) {
			a = calc(a, L);
			if (m.count(a)) {
				cout << m[a] << ' ' << a << ' ' << i - m[a] << endl;
				break;
			}
			m[a] = i;
		}
	}
}

Measured memory_bytes: 1244
#include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <chrono>
#include <queue>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <complex>
#include <cstring>
constexpr int L = 128;
int query(std::string s) {
    std::cout << "? " << s << std::endl;
    int res;
    std::cin >> res;
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    char alpha[62];
    for (int i = 0; i < 26; ++i)
        alpha[i] = 'a' + i;
    for (int i = 0; i < 26; ++i)
        alpha[26 + i] = 'A' + i;
    for (int i = 0; i < 10; ++i)
        alpha[52 + i] = '0' + i;
    int cnt[62];
    for (int i = 0; i < 62; ++i)
        cnt[i] = L - query(std::string(L, alpha[i]));
    int n = std::accumulate(cnt, cnt + 62, 0);
    std::function<std::string(int, int)> work = [&](int l, int r) {
        if (r - l == 1)
            return std::string(cnt[l], alpha[l]);
        int m = (l + r) / 2;
        auto s = work(l, m), t = work(m, r);
        std::string a;
        int i = 0, j = 0;
        while (i < int(s.length()) && j < int(t.length())) {
            if (query(a + s[i] + t.substr(j, t.length() - j)) == n - int(a.length()) - 1 - (int(t.length()) - j)) {
                a += s[i++];
            } else {
                a += t[j++];
            }
        }
        return a + s.substr(i, s.length() - i) + t.substr(j, t.length() - j);
    };
    auto s = work(0, 62);
    std::cout << "! " << s << std::endl;
    return 0;
}

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

typedef pair<int,int> p;
int dh[4] = {0, 1, 0, -1};
int dw[4] = {1, 0, -1, 0};
int main(void){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H,vector<char>(W));
    vector<vector<int>> times(H,vector<int>(W,-1));
    queue<p> que;
    for (int h=0;h<H;h++){
        for (int w=0;w<W;w++){
            cin >> A[h][w];
            if (A[h][w] == '#') {
                que.push(make_pair(h,w));
                times[h][w] = 0;
            }
        }
    }
    while (!que.empty()){
        p pt = que.front();que.pop();
        for (int i=0;i<4;i++){
            int h = pt.first+dh[i];
            int w = pt.second+dw[i];
            if (h < 0 || h >= H || w < 0 || w >= W) continue;
            if (A[h][w] == '.' && times[h][w] < 0){
                times[h][w] = times[pt.first][pt.second] + 1;
                A[h][w] = '#';
                que.push(make_pair(h,w));
            }
        }
    }
    
    int ans = 0;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            ans = max(ans, times[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13328
#include<iostream>
#include<cstdio>
#include<stack>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    stack<int> S1;
    stack<pair<int,int> > S2;
    char ch;
    int sum = 0;
    for(int i=0;cin>>ch;i++)
    {
        if(ch == '\\')
            S1.push(i);
        else if(ch == '/' && S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            sum += i-j;
            int a = i-j;
            while(S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }

    vector<int> ans;
    while(S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    for( int i = 0; i <ans.size(); i++)
    {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3208
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n,k,q;
int a[maxn];
int d[maxn]={0};

int main(){
  scanf("%d%d%d",&n,&k,&q);
  for(int i=1;i<=q;i++) scanf("%d",&a[i]);
  for(int i=1;i<=q;i++) d[a[i]]++;
//  for(int i=1;i<=n;i++) cout<<d[i]<<" ";cout<<endl;
  for(int i=1;i<=n;i++) d[i]=q-d[i];
  for(int i=1;i<=n;i++) d[i]=k-d[i];
//  for(int i=1;i<=n;i++) cout<<d[i]<<" ";cout<<endl;
  for(int i=1;i<=n;i++)
    if (d[i]<=0) cout<<"No\n";
    else cout<<"Yes\n";
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	static final Scanner scan = new Scanner(System.in);
	public static void main(String[] args) {
		int n = scan.nextInt();
		while(n!=0){
			routine(n);
			n = scan.nextInt();
		}
	}
	
	private static void routine(int n){
		int x[] = new int[2];
		int sum[] = new int[2];
		
		for(int i=0; i<n; i++){
			x[0] = scan.nextInt();
			x[1] = scan.nextInt();
			if(x[0] > x[1])
				sum[0] += x[0]+x[1];
			else if(x[0] < x[1])
				sum[1] += x[0]+x[1];
			else{
				sum[0] += x[0];
				sum[1] += x[1];
			}
		}
		
		System.out.println(sum[0]+" "+sum[1]);
	}

}

Measured memory_bytes: 12000