akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
#define PI 3.14159265359

const int MOD = 1e9 + 7;

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

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

int modpow(int base, int exp, int modulus) {
  base %= modulus;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

    double R;
    cin >> R;

    cout << R * 2 * PI << endl;

    return 0;
}


Measured memory_bytes: 3776
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
yenMax = 0

for i in s:
    cnt = s.count(i) - t.count(i)
    if yenMax < cnt:
        yenMax = cnt
print(yenMax)


Measured memory_bytes: 3060
use proconio::marker::*;
use proconio::*;
use std::cmp::min;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    };

    let f = |start: usize| -> usize {
        let l = t.len();
        let mut res = 0;
        for i in 0..l {
            if t[i] != s[i + start] {
                res += 1;
            }
        }

        res
    };

    let mut ans = usize::max_value();

    for i in 0..(s.len() + 1 - t.len()) {
        ans = min(f(i), ans);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2152
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
    int N,M,X;
    cin>>N>>M>>X;
    int a[N][M];
    int mi=1e9;
    int c[N];
    for(int i=0;i<N;i++){
        cin>>c[i];
      for(int j=0;j<M;j++){
        cin>>a[i][j];
      }
    }
    for(int i=0;i<(1<<N);i++){
      vector<int> v(M,0);
      int k=0;
      for(int j=0;j<N;j++){
        if((1<<j)&i){
          for(int h=0;h<M;h++){
            v[h]+=a[j][h];
          }
          k+=c[j];
        }
      }
      for(int j=0;j<M;j++){
        if(v[j]<X)break;
        if(j==(M-1))mi=min(mi,k);
      }
    }
    if(mi==1e9)cout<<-1;
    else cout<<mi;
    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class28
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToList();
            long max = a.Max();
            a.Remove(max);
            a = a.OrderBy(x => Math.Abs(max / 2 - x)).ToList();
            long sec = a.First();
            Console.WriteLine($"{max} {sec}");
        }
    }
}


Measured memory_bytes: 26976
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<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>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
//作者:中国江苏南京丁天行
using namespace std;
ll n,ans,jc[1000005];
ll f(ll x,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=ans*x%orz;
        x=x*x%orz,k>>=1;
    }
    return ans;
}
ll c(ll n,ll k){return jc[n]*f(jc[k],orz-2ll)%orz*f(jc[n-k],orz-2ll)%orz;}
int main(){
    cin>>n;
    jc[0]=1;
    for(ll i=1;i<=n;++i)jc[i]=jc[i-1]*i%orz;
    for(ll i=1;i<n;++i){
        ll N=n-2ll-i,K=i;
        if(N<K) break;
        ans=(ans+c(N,K)*jc[n-1ll-i]%orz*jc[i])%orz;
    }
    ans=jc[n-1]*(n-1ll)%orz-ans+orz;
    cout<<ans%orz<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>

int gcd(int x, int y)
{
    int t;

    while (y != 0) {
        t = x % y;  x = y;  y = t;
    }
    return x;
}

int main() {
    long long int K;
    long long int SUM = 0;
    scanf("%lld",&K);
    int s = 0;
    int t = 0;

    for(int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            for (int k = 1; k <= K; ++k) {
                s = gcd(i,j);
                t = gcd(s,k);
                SUM +=t;
            }
        }
    }

    printf("%lld",SUM);
    return 0;
}

int A(){
    int N;

    scanf("%d",&N);

    while(N){
        if(N % 10 == 7){
            printf("Yes");
            return 0;
        }

        N = N / 10;
    }
    printf("No");

    return 0;
}

int B(){
    long long int N;
    long long int SUM = 0;

    scanf("%lld",&N);
    for(long long int i = 1; i <= N; ++i){
        if(i % 3 == 0 || i % 5 == 0){
        }
        else{
            SUM += i;
        }
    }
    printf("%lld",SUM);
    return 0;
}


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

A = list(map(int, input().split()))

ans = int(1e9)
for i in range(N):
    cnt = 0
    while(A[i]%2 != 1):
        A[i] = A[i] // 2
        cnt = cnt + 1
    ans = min(ans, cnt)
    
print(ans)

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

int main() {
    int n;
    int a;
    cin >> n;
    cin >> a;
    while(n>=500){
        n -= 500;
    }
    if(n <= a){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

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

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b;
    cin>>a>>b;
    ll now=1;
    ll res=0;
    while (now<b)
    {
        now+=a-1;
        res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3512
s = input()
def BFunc(s):
    s = list(s)
    if s[0] != 'A':
        return False
    s.pop(0)
    c_cnt = 0
    for i in range(1, len(s) - 1):
        if s[i] is 'C':
            c_cnt += 1
            if c_cnt > 1:
                return False
            s.pop(i)
    if c_cnt != 1:
        return False
    for i in range(len(s)):
        if not s[i].islower():
#             print(s)
            return False
    return True
if BFunc(s):
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;


int main(){
    int n,x;
    cin>>n>>x;
    vec<int> v(n);
    rep(i,0,n)cin>>v[i];

    ll ans=0;
    rep(i,0,n-1){
        if(v[i]+v[i+1]>x){
            ans+=v[i]+v[i+1]-x;
            if(v[i]<=x){
                v[i+1]=x-v[i];
            }else {
                v[i+1]=0;
                v[i]=x;
            }
        }
    }
cout<<ans<<endl;
    
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<pair<int,int>> p(N);
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    p.at(i)=make_pair(a+b,a-b);
  }
  sort(p.begin(),p.end());
  int A=p.at(0).first,Z=1;
  for(int i=1;i<N;i++){
    if(A<=p.at(i).second){
      Z++;
      A=p.at(i).first;
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
lst = list(map(int,input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(1, min(k, len(lst))):
    dp[i] = abs(lst[i] - lst[0])
for i in range(k, n):
    for j in range(1, k+1):
        dp[i] = min(dp[i], dp[i-j]+abs(lst[i]-lst[i-j]))
print(dp[-1])

Measured memory_bytes: 54880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, M = 1e9 + 7;
    cin >> n;

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

    for (auto& i : a)
        for (auto& j : i) cin >> j;

    vector<int> dp(1 << n), cnt(1 << n);
    dp[0] = 1;

    queue<int> q;
    q.push(0);

    while (!q.empty()) {
        int msk = q.front(), i = cnt[msk];
        q.pop();

        if (i == n) break;

        for (int j = 0; j < n; ++j) {
            if (a[i][j] && !(msk & (1 << j))) {
                if (!cnt[msk | (1 << j)]) {
                    q.push(msk | (1 << j));
                    cnt[msk | (1 << j)] = cnt[msk] + 1;
                }
                dp[msk | (1 << j)] = (dp[msk | (1 << j)] + dp[msk]) % M;
            }
        }
        dp[msk] = 0;
    }
    cout << dp[(1 << n) - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 18304
(defun solve (n k h)
  (let ((h-sorted (sort (copy-seq h) #'>)))
    (if (> n k)
        (apply #'+ (subseq h-sorted k))
        0)))


(defun main ()
  (let ((n (read))
        (k (read))
        (h (read-from-string (concatenate 'string "(" (read-line)")"))))
    (format t "~a~%" (solve n k h))))

(main)


Measured memory_bytes: 64416
n, x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
if sum(a) < x:
    print(n-1)
    exit()
    
elif sum(a) == x:
    print(n)
    exit()
    
else:
    a = sorted(a)
    for i in range(n):
        ans += a[i]
        if ans > x:
            print(i)
            exit()

Measured memory_bytes: 9192
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n, m;
    cin >> n >> m;
    
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 101


int main(){

  int V[N][N],i,j,n,t,s,u;


  scanf("%d",&n);

  for(i=1;i<=n;i++){
 for(j=1;j<=n;j++){
     V[i][j]=0;
    }}

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&t);
    for(j=1;j<=t;j++){
      scanf("%d",&s);
      V[u][s]=1; 
    }
  }



 for(i=1;i<=n;i++){
 for(j=1;j<=n;j++){
   if(j==n) printf("%d",V[i][j]);
   else if(printf("%d ",V[i][j]));
 }
 printf("\n");
}

 return 0;
}

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

int main()
{
    int n;
    cin >> n;
    
    bool flag = false;
    for (int i = 0; i < 25; i++)
    {
        for (int j = 0; j < 25; j++)
        {
            if ((i*4 + j*7) == n)
            {
                flag = true;
            }
        }
    }

    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include<cstdio>
int N,K,M,f[310][310][310];
int main(){
	scanf("%d%d%d",&N,&K,&M);
	f[0][1][0]=1;
	for(int i=0;i<=N;i++){
		for(int j=1;j<=K;j++){
			for(int k=i;k>=0;k--)if(f[i][j][k]){
				if(k)(f[i][j][k-1]+=f[i][j][k])%=M;
				else(f[i][j+1][i]+=f[i][j][k])%=M;
				f[i+1][j][k]=(f[i+1][j][k]+(k+1ll)*f[i][j][k])%M;
			}
		}
	}
	printf("%d\n",f[N][K+1][N]);
}

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

#define I inline void 

using ll = long long ; 
using ld = long double ; 

using namespace std ; 

const int N = 500 + 7 , mod = 1e9 + 7 ; 

int n; 

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

	//freopen("in.in" , "r" , stdin) ;  

	cin >> n ; 
	int ans = 0 ; 
	int a[n+1] ; 
	for(int i = 0 ; i < n;i++){
		cin >> a[i] ; 
	}
	for(int i = 0 ; i< n;i++){
		for(int j = i+1 ;j < n ;j++){
			for(int k = j +1  ; k < n ; k++){
				std::vector<int> v = {a[i] , a[j] , a[k]};
				sort(v.begin() , v.end()) ; 
				if(v[0] == v[1] || v[1] == v[2])
					continue ; 
				ans+= (v[0] + v[1] > v[2]) ; 
			}
		}
	}
	cout<< ans ; 
	return 0 ; 
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
ll fast_int()
{
	ll x;
	scanf("%lld",&x);
	return x;
}
void fast_out(ll x)
{
	printf("%lld",x);
}
using namespace std;
int main()
{
string s;
cin>>s;
if(s[2]==s[3]&&s[4]==s[5])
cout<<"Yes";
else
cout<<"No";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	
	cities := make([]int, n)
	
	a,b := 0,0
	for i := 0; i < m; i++ {
		fmt.Scan(&a,&b)
		cities[a-1]++
		cities[b-1]++
	}
	for i := 0; i < n; i++ {
		fmt.Println(cities[i])
	}
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

ll dp[3000][3000];
bool vis[3000][3000];
ll a[3000];
int n;

ll solve(int l, int r) {
    if (vis[l][r])
        return dp[l][r];
    vis[l][r] = true;
    bool taro = (n - 1 - (r - l)) % 2 == 0;
    ll ret;
    if (taro) {
        if (l == r)
            ret = a[l];
        else {
            ret = -INF;
            chmax(ret, solve(l + 1, r) + a[l]);
            chmax(ret, solve(l, r - 1) + a[r]);
        }
    } else {
        if (l == r)
            ret = -a[l];
        else {
            ret = INF;
            chmin(ret, solve(l + 1, r) - a[l]);
            chmin(ret, solve(l, r - 1) - a[r]);
        }
    }
    return dp[l][r] = ret;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cout << solve(0, n - 1) << "\n";
    return 0;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int k1,k2,h1,h2,a,b,c,d,x,y;
scanf("%d%d",&h1,&h2);
scanf("%d%d",&k1,&k2);
scanf("%d%d%d%d",&a,&b,&c,&d);
x=((h1*a)+(h1/10*c))+((h2*b)+(h2/20*d));
y=((k1*a)+(k1/10*c))+((k2*b)+(k2/20*d));
if(x>y){
printf("hiroshi\n");
}else if(x<y){
printf("kenjiro\n");
}else{
printf("even\n");
}
return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define int long long
#define vin vector<int>
#define vcn vector<char>
#define ver pair<int,int>
#define ld long double
#define pb push_back
#define x first
#define y second
#define blush fflush(stdout);fflush(stdin);
#define $(a) (int)a.size()
#define scanf ;
#define printf ;
using namespace std;
void i_love_misaka_mikoto();
int32_t main(){
    #ifdef RNS
        freopen("input.txt","r",stdin);
        #ifndef DBG
        freopen("output.txt","w",stdout);
        #endif
    #else
        ios_base::sync_with_stdio(false);
    #endif
    i_love_misaka_mikoto();
    #ifdef RNS
        cout<<'\n'<<(ld)clock()/CLOCKS_PER_SEC<<" セクンド\n";
    #endif
    return 0;
}


void i_love_misaka_mikoto(){
    int a, b;
    cin>>a>>b;
    if(b%a==0)
        cout<<a+b;
    else 
        cout<<b-a;
}

Measured memory_bytes: 256
# coding: utf-8
class Case02

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @s = gets.chomp
  end

  # 回答
  def solve
    @result = true
    1.upto(@s.length) do |i|
      if (i % 2) == 0 then
        unless @s[i-1] =~ /[LUD]/ then
          @result = false
          break
        end
      else
        unless @s[i-1] =~ /[RUD]/  then
          @result = false
          break
        end
      end
    end
  end
  
  # 出力
  def output
    puts @result ? 'Yes' : 'No'
  end

end

Case02.new.execute if $0 == __FILE__



Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <stack>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
const int mxn = 20020;
const int mod = 1e9+7;

long long powmod(long long a, long long b) {
	long long ret = 1;
	while(b) {
		if(b&1ll) ret*=a, ret%=mod;
		a*=a; a%=mod;
		b>>=1;
	}
	return ret;
}

long long dp[mxn];


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

	dp[0] = 1;
	for(int i=0; i<s; i++) {
		for(int j=3; j<=(s-i); j++) {
			dp[i+j]+=dp[i]; dp[i+j]%=mod;
		}
	}

	cout << dp[s] << '\n';

	return 0;
}
//comparator function in sorting
//swapping arguments
//missing cases in dp
//dividing in modulo
//Beware of overflow and modulo
//Be mindful of overflow
//s is a matrix but forget
//length of ranges
//working with bit using ull

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int flag=0;
    for (int i=1;i<=9;i++) {
        for (int j=1;j<=9;j++) {
            if (i*j==n) {
                cout<<"Yes"<<endl;
                flag=1;
                break;
            }
        }
        if (flag==1) {
            break;
        }
    }
    if (flag==0) {
        cout<<"No"<<endl;
    }
}

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


int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  
  // できるだけ後ろにcoderを入れる
  int index = S.size();
  for(int i = S.size() - T.size(); i >= 0; i--){
    bool flg = true;
    for(int j = 0; j < T.size(); j++){
      if(S[i+j] == '?' || S[i+j] == T[j]){
        continue;
      } else { 
        flg = false;
        break;
      }
    }
    if(flg){
      index = i;
      break;
    }
  }
  cerr << index << endl;
  string ans = "";
  for(int i = 0; i < S.size(); i++){
    if(i < index || i > index + T.size()-1){
      // Sから表示
      if(S[i] == '?') ans += "a";
      else ans += S[i];
    } else { 
      ans += T[i-index];
    }
  }
  if(index == S.size()){
    ans = "UNRESTORABLE";
  }
  cout << ans << endl;
      
}

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

using namespace std;

int H,W,mr[2000][2000],mc[2000][2000];
string S[2001];

int dr(int n,int m)
{
  int num;
  
  if(mr[n][m] !=-1)
  {
    return mr[n][m];
  }
  
  if(S[n][m]=='#')
  {
    mr[n][m]=0;
    return 0;
  }
  
  if(n>0)
  {
    if(S[n-1][m]=='.')
    {
      mr[n][m]=dr(n-1,m);
      return mr[n][m];   
    }
    else
    {
      num=0;
      while(S[n+num][m]=='.' && n+num <H)
      {
        num++;
      }
      mr[n][m]=num;
      return num;
    }
  }
  else
  {
      num=0;
      while(S[n+num][m]=='.' && n+num <H)
      {
        num++;
      }
      mr[n][m]=num;
      return num;
  }

}

int dc(int n,int m)
{
  int num;
  
  if(mc[n][m] !=-1)
  {
    return mc[n][m];
  }

    if(S[n][m]=='#')
  {
    mc[n][m]=0;
    return 0;
  }
  
  if(m>0)
  {
    if(S[n][m-1]=='.')
    {
      mc[n][m]=dc(n,m-1);
      return mc[n][m];   
    }
    else
    {
      num=0;
      while(S[n][m+num]=='.' && m+num <W)
      {
        num++;
      }
      mc[n][m]=num;
      return num;
    }
  }
  else
  {
      num=0;
      while(S[n][m+num]=='.' && m+num <W)
      {
        num++;
      }
      mc[n][m]=num;
      return num;
  }

}

int main()
{
  
  cin >> H >> W;
  int i,j,k,ans=0;

  
  for(i=0;i<H;i++)
  {
    cin >> S[i];
  }
  /*
  for(i=0;i<H;i++)
  {
    cout << S[i] << endl;
  }
  
  for(i=0;i<H;i++)
  {
    for(j=0;j<W;j++)
    {
      cout << S[i][j] ;
    
    }cout <<  endl;
  }
  */
  for(i=0;i<H;i++)
  {
    for(j=0;j<W;j++)
    {
      mc[i][j]=-1;
      mr[i][j]=-1;
    }
  }

  for(i=0;i<H;i++)
  {
    for(j=0;j<W;j++)
    {
      ans=max(ans,dr(i,j)+dc(i,j)-1);

    }

  }

//  cout << dr(1,1) << endl << dc(1,1) << endl;
  cout <<ans;

}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll arr[N];
ll pre[N],suf[N];
int main(){
  ll a,b,c,d,e;
  scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e);
  ll ans = 0;
  int x = a%2+d%2+e%2;
  if(x==3){
    ans=3; a--;d--;e--;
  }else if(x==2){
    if(a&&d&&e){
      ans=3; a--;d--;e--;
    }
  }
  ans+=2*(a/2+d/2+e/2)+b;
  printf("%lld\n",ans);
  return 0;
}

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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

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

    bool ok = true;
    
    if (n%2) {
        if (a[0] != 1) ok = false;
        for (int i = 2; i <= n-1; i+=2) {
            if (a[i] != 2) ok = false;
        }
    } else {
        for (int i = 1; i <= n-1; i+=2) {
            if (a[i] != 2) ok = false;
        }
    }

    if (!ok) {
        cout << 0 << endl;
    } else {
        ll ans = 1;
        for (int i = 0; i < n/2; i++) {
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 640
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)


def solve(x):
    if x == 1:
        return 1

    return solve(math.floor(x/2)) * 2 + 1

def main():
    H = int(input())


    print(solve(H))


if __name__ == "__main__":
  main()


Measured memory_bytes: 12396
<?php
    $a = str_split(trim(fgets(STDIN)));
    $b = str_split(trim(fgets(STDIN)));
    $c = count($a);
    $ans = 0;
    for($i = 0; $i < $c; $i++){
        if($a[$i] != $b[$i]){
            $ans++;
        }
    }
    echo $ans;
?>

Measured memory_bytes: 41204
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007


const int MAX_V = 200;

int d[MAX_V][MAX_V];
int e[MAX_V][MAX_V];
int V;
 
void warshall_floyd_init(){
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(i == j) d[i][i] = e[i][i] = 0;
			else d[i][j] = e[i][j] = INF;
		}
	}
}

void warshall_floyd() {
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
			}
		}
	}
}

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n == 0 && m == 0) break;
		V = m;
		int a,b,cost,time;
		warshall_floyd_init();
		rep(i, n) {
			cin>>a>>b>>cost>>time;
			a--; b--;
			d[a][b] = d[b][a] = cost;
			e[a][b] = e[b][a] = time;
		}
		warshall_floyd();
		int k, c;
		cin>>k;
		for(int i = 0; i < k; i++){
			cin>>a>>b>>c;
			a--; b--;
			if(c == 0) cout<<d[a][b]<<endl;
			else cout<<e[a][b]<<endl;
		}
	}
	
}

Measured memory_bytes: 1316
fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val G = Array<MutableList<Int>>(N) { mutableListOf<Int>() }
    repeat(M) {
        val (a, b) = listOfInt(-1)
        G[a].add(b); G[b].add(a)
    }
    for (n in 0 until N) G[n].sort()
    var ans = false
    for (x in 1 until N - 1) {
        if (G[0].binarySearch(x) > -1 && G[x].binarySearch(N - 1) > -1) {
            ans = true; break
        }
    }
    println(if (ans) "POSSIBLE" else "IMPOSSIBLE")
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }



Measured memory_bytes: 106836
local h,w=io.read("n","n")
local a={}
for i=1,h do
    a[i]={}
    for j=1,w do
        a[i][j]=io.read("n")
    end
end

local bit=require("bit")
local operation={}
for i=1,h do
    for j=1,w do
        if a[i][j]%2==1 then
            if j<w then
                a[i][j+1]=a[i][j+1]+1
                a[i][j]=a[i][j]-1
                table.insert(operation,{i,j,i,j+1})
            elseif i<h then
                a[i+1][j]=a[i+1][j]+1
                a[i][j]=a[i][j]-1
                table.insert(operation,{i,j,i+1,j})
            end
        end
    end
end

local n=#operation
print(n)
for i=1,n do
    print(table.concat(operation[i]," "))
end

Measured memory_bytes: 20172
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int[] diameter;
        int step = 0;
        int massdia = 0;
		
        int cnt = sc.nextInt();
        diameter = new int[cnt];
        
        for(int i = 0; i < cnt; i++){
            diameter[i] = sc.nextInt();
        }
        
        int[] sort;
        sort = Arrays.stream(diameter).distinct().toArray();
        
        
        System.out.println(sort.length);
	}
}

Measured memory_bytes: 27860
import java.util.*;

public class Main {
	char[][] c;
	boolean[] r = new boolean[11];
	boolean flag;
	int id;
	
	void loop(int n){
		if(flag==false) return;
		if(n==11){
			id = 0;
			boolean t0 = exp(0);
			id = 0;
			boolean t1 = exp(1);
			if(t0!=t1) flag = false;
		}else{
			r[n] = true;
			loop(n+1);
			r[n] = false;
			loop(n+1);
		}
	}
	
	boolean exp(int m){
		boolean q = fact(m);
		id++;
		if(id<c[m].length){
			char p = c[m][id];
			if(p=='+'){
				id++;
				q = q|exp(m);
			}else if(p=='*'){
				id++;
				q = q&exp(m);
			}else if(p=='/'){
				id++;
				boolean v = exp(m);
				if(q==true && v==false) q = false;
				else q = true;
			}
		}
		return q;
	}
	
	boolean fact(int m){
		char p = c[m][id];
		boolean q = false;
		if(p=='('){
			id++;
			q = exp(m);
		}else if(p=='-'){
			id++;
			q = !fact(m);
		}else{
			if(97<=(int)p && (int)p<=107) q = r[(int)p-97];
			else if(p=='T') q = true;
			else if(p=='F') q = false;
		}
		return q;
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String s = sc.next();
			if(s.compareTo("#")==0) break;
			String[] t = s.replace("->", "/").split("=");
			c = new char[2][];
			c[0] = t[0].toCharArray();
			c[1] = t[1].toCharArray();
			flag = true;
			loop(0);
			if(flag==true) System.out.println("YES");
			else System.out.println("NO");
		}	
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

Measured memory_bytes: 48432
j, y = map(int, input().split())
memo = {}
ans = []
def dfs(a, b, R):
    key = (a, b)
    if key == (j, y):
        ans.append(''.join(R))
    if key in ((5, 4), (4, 5)) or (a < 5 and b < 5):
        R.append('A')
        dfs(a+1, b, R)
        R[-1] = 'B'
        dfs(a, b+1, R)
        R.pop()
dfs(0, 0, [])
print(*ans, sep='\n')


Measured memory_bytes: 5616
n,m = map(int,input().split())

l = []

for i in range(m):
    ta,tb = map(int,input().split())
    l.append((ta-1,tb))
ans = [0]*n
l.sort()
if m ==0 and n==1:
    print(0)
    exit()
elif m ==0:
    print('1'+'0'*(n-1))
    exit()
elif n == 1:
    if len(set(l)) ==1:
        print(l[0][1])
    else:
        print(-1)
    exit()
elif l[0][1] == 0 and l[0][0]==0:
    print(-1)
    exit()
else:
    l = set(l)
    for i,j in l:
        if ans[i] ==0:
            ans[i] = j
        else:
            # print(i,j)
            print(-1)
            exit()
a = ''
for i in ans:
    a+=str(i)
if a[0]=='0':
    a='1'+a[1:]
print(a)

        
        


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define FI first
#define SE second
using namespace std;
typedef pair<int,int> pii;
static const int inf = 1ll<<60;
static const int MAX_N = 16777216;
int N,D;
int W[35];
int V[35];
int dat[MAX_N*2];
vector<pii> An,Bu;

class Segment{
    public :
        int n;
        void inti(int n_){
            n=1;
            while(n<n_)n*=2;
            for(int i=0;i<2*n-1;++i)dat[i]=-INT_MAX;
        }

        void update(int k,int a){
            k+=n-1;
            dat[k]=a;
            while(k>0){
                k=(k-1)/2;
                dat[k]=max(dat[k*2+1],dat[k*2+2]);
            }
        }

        int query(int a,int b,int k,int l,int r){
            if(a<=l&&r<=b)return dat[k];
            if(r<=a||b<=l)return -INT_MAX;
            else {
                int vl=query(a,b,k*2+1,l,(l+r)/2);
                int vr=query(a,b,k*2+2,(l+r)/2,r);
                return max(vl,vr);
            }
        }
};

void dfs(int n,int l,int w,int v,vector<pii> & res){
    if(n==l){
        res.PB(pii(w,v));
        return ;
    }
    dfs(n-1,l,w+W[n],v+V[n],res);
    dfs(n-1,l,w-W[n],v-V[n],res);
    dfs(n-1,l,w,v,res);
}

signed main(){
    cin>>N>>D;
    for(int i=1;i<=N;++i)cin>>W[i]>>V[i];
    Segment seg;
    int N1=N/2;
    An.reserve(MAX_N);
    dfs(N1,0,0,0,An);
    Bu.reserve(MAX_N);
    dfs(N,N1,0,0,Bu);
    seg.inti(Bu.size());
    sort(Bu.begin(),Bu.end());
    for(int i=0;i<Bu.size();++i)seg.update(i,Bu[i].SE);
    int ans=0;
    for(int i=0;i<An.size();++i){
        int x=An[i].FI+D;
        int y=An[i].FI-D;
        int r=upper_bound(Bu.begin(),Bu.end(),make_pair(x,inf))-Bu.begin();
        int l=lower_bound(Bu.begin(),Bu.end(),make_pair(y,-inf))-Bu.begin();
        if(l==Bu.size())continue;
        if(l>=r)continue;
        ans=max(ans,seg.query(l,r,0,0,seg.n)-An[i].SE);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 712864
#include<stdio.h>

#define MAX 105
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(void);
void visit(int);
  
int m[MAX][MAX];
int d[MAX];
int f[MAX];
int color[MAX];
int n;
int time;
  
int main(){
  
  int i,j,u,k,ne;
  
  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      m[i][j] = 0;
    }
  }
  for(i = 1; i <= n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 1; j <= k; j++){
      scanf("%d",&ne);
      m[i][ne] = 1;
    }
  }
  dfs();
  for(i = 1; i <= n; i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  
  return 0;
}
void dfs(void){
  
  int u;
  
  for(u = 1; u <= n; u++){
    color[u] = WHITE;
  }
  time = 0;
  for(u = 1; u <= n; u++){
    if(color[u] == WHITE) visit(u);
  }
}
void visit(int u){
  
  int v;
  
  color[u] = GRAY;
  d[u] = ++time;
  for(v = 1; v <= n; v++){
    if(m[u][v] == 1 && color[v] == WHITE) visit(v);
  }
  color[u] = BLACK;
  f[u] = ++time;
}

Measured memory_bytes: 644
#include<stdio.h>
#include<stdlib.h>
#define Max 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<n+1;j++){
    scanf("%hu",&A[j]);
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]+=C[i-1];
  }
  for(i=n;i>0;i--){
    B[C[A[i]]]=A[i];
    C[A[i]]--;
  }
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);
  return 0;
}



Measured memory_bytes: 9580
from itertools import product
import math

n = int(input())
ss = []

for i in range(3, 10):
    for per in product('357', repeat=i):
        if '3' in per and '5' in per and '7' in per:
            ss.append(int(''.join(per)))

ss.append(1000000000)
i = 0
while True:
    if ss[i] > n:
        print(i)
        break
    i += 1

Measured memory_bytes: 4212
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
#include<algorithm>
#define LONG long long int
using namespace std;


int main() {
	LONG a, b;
	cin >> a >> b;
	cout << max(a + b, max(a, b) + max(a, b) - 1) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int longs, number;
    cin >> longs;
    vector<char> one(longs);
    for(int i = 0; i < longs; i++){
        cin >> one.at(i);
    }
  cin >> number;
    for(int i = 0; i < longs; i++){
    if(one.at(i) != one.at(number - 1)) one.at(i) = '*';
    }
    for(int i = 0; i < longs; i++){
        cout << one.at(i);
        if(i == longs - 1) cout << endl;
    }
}

Measured memory_bytes: 256
"use strict";
function main(input) {
  let n = input[1].split(" ");
  n.sort(function(a, b) {
  	return a - b;
  });
  let before = -1; 
  for(let i=0;i<n.length;i++){
    if(n[i]===before){
      console.log("NO");
      break;
    }else if(i === n.length-1){
      console.log("YES");
    }
    before = n[i];
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 34088
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
void in_out()
{
	freopen("input.in", "r", stdin);
	freopen("output.in", "w", stdout);
}
int main()
{
	fast();
	string s;
	cin >> s;
	s[0] = '2';
	s[1] = '0';
	s[2] = '1';
	s[3] = '8';
		cout << s; 

	
}

Measured memory_bytes: 256
#中間テストの点数m,期末テストの試験f,再試験の点数r

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")
    elif m+f<30: print("F")


Measured memory_bytes: 5592
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		int halfN = n/2;
		int lessD = list.get(halfN-1);
		int greatD = list.get(halfN);




		System.out.println(greatD-lessD);

	}

}


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

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String target = scan.nextLine();
		
		String bigAlpha = "QWERTYUIOPASDFGHJKLZXCVBNM";
		
		String[] bigAlphaArray = bigAlpha.split("");
		
		String answer = Arrays.asList(bigAlphaArray).contains(target)
				? "A"
				: "a";

		println(answer);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int r;
	static int c;
	static int[][] a;
	static int initialCount;
	static int answer;

	public static void main(String[] args) {
		while (read()) {
			solve(0);
			System.out.println(answer);
		}
		
	}

	public static void solve(int rownum) {
		if (rownum == r) {
			swapColumns();
			return;
		}
		//if swap
		swapRow(rownum);
		// if not swap
		notSwapRow(rownum);
	}

	public static void notSwapRow(int n) {
		solve(++n);
	}

	public static void swapRow(int n) {
		for (int j = 0; j < c; j++) {
			a[n][j] = a[n][j] == 1 ? 0 : 1;
		}
		solve(++n);
	}

	public static void swapColumns() {
		for (int j = 0; j < c; j++) {
			if (countUpColumns(j) > r / 2) {
				// swap j Columns
				for (int i = 0; i < r; i++) {
					a[i][j] = a[i][j] == 1 ? 0 : 1;
				}
			}
		}
		if (countUpZero() > initialCount && countUpZero() > answer) {
			answer = countUpZero();
		}

	}

	public static int countUpColumns(int j) {
		int num = 0;
		for (int i = 0; i < r; i++) {
			if (a[i][j] == 1) {
				num++;
			}
		}
		return num;
	}

	public static int countUpZero() {
		int count = 0;
		// height
		for (int i = 0; i < r; i++) {
			// width
			for (int j = 0; j < c; j++) {
				if (a[i][j] == 0) {
					count++;
				}
			}
		}
		return count;
	}

	public static boolean read() {
		initialCount =0;
		r = sc.nextInt();
		c = sc.nextInt();
		if (r == 0 && c == 0) {
			return false;
		}
		a = new int[r][c];
		// end

		// height
		for (int i = 0; i < r; i++) {
			// width
			for (int j = 0; j < c; j++) {
				a[i][j] = sc.nextInt();
				if (a[i][j] == 0) {
					initialCount++;
				}
			}
		}
		answer = initialCount;
		return true;

	}

}

Measured memory_bytes: 79460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n,k; cin >> n;
	cin >> k;
	int check[10] = {0},a;
	for(int i = 0 ; i < k ; i++){
		cin >> a;
		check[a]++;
	}
	int ans,flag = 0;
	for(int i = n ; i < 1000000 ; i++){
		int temp = i , b;
		while(temp > 0){
			b =  temp % 10;
			if(check[b] != 0){
				temp = 0;
				flag = 1;
			}
			temp/=10;
		}
		if(flag == 0){
			ans = i;
			i+=1000000;
		}
		flag = 0;
	}
	cout<<ans<<"\n";		
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAX(a,b) (a>b?a:b)
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int x[N];
  rep(i,N) cin >> x[i];
  int cnt = 0;
  rep(i,N){
    if(abs(x[i]-K)<x[i]) cnt += 2*abs(x[i]-K);
    else cnt += 2*x[i];
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B,C=0,sum=0;

    cin>>A;
    cin>>B;
    C=B*2;
    sum=A-C;
    if (sum<=0)
    {
       sum=0;
    }
    cout<<sum<<endl;
    return 0;
}


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

const int M = 1e9 + 7;
ll mod_pow(ll a, ll b) {
	ll ans = 1;
	while (b){
		if (b&1) ans = ans * a % M;
		a = a * a % M;
		b >>= 1;
	}
	return ans;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> c(k+1);
	for (ll i = k; i >= 1; --i) {
		c[i] = mod_pow(k / i, n);
		int j = 2;
		while (i * j <= k) {
			c[i] = (c[i] + M - c[i*j])%M;
			++j;
		}
	}
	ll ans = 0;
	rep(i, k+1) {
		ans += (c[i] * i % M);
		ans %= M;
	}
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int ac=0,wa=0,re=0,tle=0;
  rep(i,N){
    string S;
    cin >> S;
    if(S=="AC"){
      ac++;
    }
    else if(S=="WA"){
      wa++;
    }
    else if(S=="RE"){
      re++;
    }
    else{
      tle++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

using namespace std;

int n;
int a[100005];

int main(void) {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    if (a[n-1] - a[0] > 1) return cout << "No" << endl, 0;
    if (a[n-1] == a[0]) {
        if (a[0] == n - 1) return cout << "Yes" << endl, 0;
        if (a[0] * 2 <= n) return cout << "Yes" << endl, 0;
        return cout << "No" << endl, 0;
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) if (a[i] == a[0]) ++cnt;
    if (cnt >= a[n-1]) return cout << "No" << endl, 0;
    int ncolors = a[n-1] - cnt;
    if (ncolors * 2 <= n - cnt) return cout << "Yes" << endl, 0;
    cout << "No" << endl;
}


Measured memory_bytes: 640
N = int(input())
N -= 1

alp = "abcdefghijklmnopqrstuvwxyz"



ans = ''
while N >= 0:
    j = N % 26
    if N == 0:
        ans += alp[j]
        break
    else:
        N = N // 26 - 1
        ans += alp[j]

print(ans[::-1])





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

namespace ABC144
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    if (N == i * j) { Console.WriteLine("Yes"); return; }
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092