akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IO ios::sync_with_stdio(false),cin.tie(0)
#define FIN freopen("D://code//in.txt", "r", stdin)
#define ppr(i,x,n) for(int i = x;i <= n;i++)
#define rpp(i,n,x) for(int i = n;i >= x;i--)
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

inline int read() {//读入挂
    int ret = 0, c, f = 1;
    for(c = getchar(); !(isdigit(c) || c == '-'); c = getchar());
    if(c == '-') f = -1, c = getchar();
    for(; isdigit(c); c = getchar()) ret = ret * 10 + c - '0';
    if(f < 0) ret = -ret;
    return ret;
}
int nextt[maxn][26];
int now[26],area[maxn];
int tot,tmp;
set<int >S;
int main()
{
	IO;
	tot = 0;
	string s;
	string ans;
	cin>>s;
	rpp(i,s.size()-1,0)
	{
		int gg = s[i] - 'a';
		S.insert(gg);
		area[i] = tot;
		if(S.size() == 26)
		{
			tot++;
			S.clear();
		}
	}
	if(tot == 0)
	{
		ppr(i,0,25)
		{
			if(S.count(i) == 0)
			{
				char minn= i+'a';
				cout<<minn<<endl;
				return 0;
			}
		}
	}
	rpp(i,s.size()-1,0)
	{
		ppr(j,0,25)
		{
			nextt[i][j] = now[j];
		}
		now[s[i] - 'a'] = i;
	}
	ppr(i,0,25)
	{
		if(S.count(i) == 0)
		{
			ans += (i + 'a');
			tmp = now[i];
			break;
		}
		
	}
	ppr(i,1,tot)
	{
		ppr(j,0,25)
		{
			if(area[nextt[tmp][j]] == area[tmp]-1)
			{
				char minn = j + 'a';
				ans += minn;
				tmp = nextt[tmp][j];
				break;
			}
		}
	}
	ppr(i,0,25)
	{
		if(nextt[tmp][i] == 0)
		{
			char minn = i + 'a';
			ans += minn;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21652
N, M = [int(i) for i in input().split()]
a = []
b = []
c = []
d = []
for i in range(N):
    a_, b_ = [int(i) for i in input().split()]
    a.append(a_)
    b.append(b_)
for i in range(M):
    c_, d_ = [int(i) for i in input().split()]
    c.append(c_)
    d.append(d_)
for i in range(N):
    road_old  = float("inf")
    for n in range(M):
        road = abs(a[i] - c[n]) + abs(b[i] - d[n])
        if road < road_old:
            ans = n + 1
            road_old = road
    print(ans)

Measured memory_bytes: 3316
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
 
process.stdin.on('end', _ => {
    inputString = inputString.split(/\n/);
    main();    
});
 
function readLine() {
    return inputString[currentLine++];
}

function main() {
  const [a, b, c, d] = readLine().split(/\s/).map(BigInt)
  console.log([a * c, a * d, b * c, b * d].reduce((a, b) => a > b ? a : b).toString())
}

Measured memory_bytes: 29960
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 17;

void solve()
{
	int n, a, b, c;
	scanf ("%d", &n);
	printf("%d\n", (n+1)/2);
} 
 
int main()
{
    int t;
    t = 1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}




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

int main() {
    int i;
    string str;

    getline(cin, str);
    for(i=0; i<str.length(); ++i) {
        if(islower(str[i])) str[i] = toupper(str[i]);
        else if(isupper(str[i])) str[i] = tolower(str[i]);
    }
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n,m,x;
  cin>>n>>m>>x;
  int L=0;
  int R=0;
for (int i = 0; i < m; i++) {
 int a;
  cin>>a;
  if(a<x){
    L++;
  }
  else{
    R++;
  }
}
  cout<<min(L,R)<<endl;
  

}

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

int main(){
  string S;
  cin >> S;
  
  if(S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2))
    cout << "Yes" << endl;
  else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1))
	cout << "Yes" << endl;
  else if (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  vector<int> w(n);
  REP(i, n) cin >> w[i];
  int s1 = w[0], s2 = 0;
  FOR(i, 1, n) s2 += w[i];
  int ans = abs(s1-s2);
  FOR(i, 1, n-1){
    s1 += w[i];
    s2 -= w[i];
    chmin(ans, abs(s1-s2));
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b == 2 ? a : gcd(b, a % b);};
ll poww(ll a, ll b, ll md) {
   return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;int sum=0,x=0;
    for(int i=0;i<s.size();i+=1){
        /*for(int j=i+1;j<s.size();j+=1){
            if(s[i]==s[j])
        }*/
        if(s[i]=='R' && x==0) sum++;
        else if(s[i]=='R' && x==1) sum+=2;
        else if(s[i]!='R' && i==1){
                x = 1;sum--;
        }
    }
    if(x==1 && sum==0) cout<<"1\n";
    else if(x==1 && sum==2) cout<<sum-1<<endl;
    else if(sum<0) cout<<"0\n";
    else cout<<sum<<endl; //if(x==1 && sum==2) cout<<sum-1<<endl;









    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = (N - 1LL) * (B - A) + A - B + 1;
    cout << (ans > 0 ? ans : 0) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<ll>> c(10, vector<ll>(10)), a(h, vector<ll>(w));
    vector<vector<ll>> dp(10, vector<ll>(10));
    rep(i, 10)rep(j, 10){
        cin >> c[i][j];
        dp[i][j] = c[i][j];
    }
    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i, h)rep(j, w){
        cin >> a[i][j];
        if(a[i][j] != 1 && a[i][j] != -1){
            ans += dp[a[i][j]][1];
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	cout << setprecision(10);

	int n, m;
	cin >> n >> m;
	vector<int> b(n);
	rep(i,m) cin >> b[i];

	//0段目は壊れていないことが保証されている。
	ll dp[100100];
	//壊れたところは0にしたいところだが、それだと、全部初期化で0にしないといけないので不都合
	//仕方ないので-1にして、-1ならその段差への～通りの計算はしない。で配るときだけ0を用いるようにする
	rep(i,100100){
		dp[i] = 0;
	}
	dp[0] = 1;
	dp[1] = 1;
	rep(i,m){
		dp[b[i]] = -1;
	}
	
	For(i,2,n+1){
		if(dp[i]!=-1){
			ll plus_one = dp[i-1];
			ll plus_two = dp[i-2];
			if(plus_one<0) plus_one = 0;
			if(plus_two<0) plus_two = 0;
			dp[i] = plus_two+plus_one;
			dp[i]%=mod;
		}
	}
	if(dp[n]==-1) cout << 0 << endl;
	else cout <<dp[n] << endl;

}


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

p = 7+pow(10,9)
def cmb(n,r,p):
    numerator = 1
    for i in range(n-r+1, n+1):
        numerator = numerator * i % p
    denominator = 1
    for i in range(1, r+1):
        denominator = denominator * i % p
    return numerator * pow(denominator, p-2, p) % p


print(cmb(n,2,p)+cmb(m,2,p))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  string s,t;
  cin>>s;
  cin>>t;
  string tar = s+t[t.length()-1];
  if(tar==t) {
    pr("Yes");
  } else {
    pr("No");
  }
  return 0;
}


Measured memory_bytes: 3596
def resolve():
    n = int(input())
    d, x = map(int, input().split())
    al = list()
    ans = 0
    for i in range(n):
        a = int(input())
        al.append(a)
    cl = list()
    for i in range(n):
        counter = 1
        day = 1
        while day + al[i] <= d:
            counter += 1
            day += al[i]
        cl.append(counter)
    ans = 0
    for i in cl:
        ans += i
    ans += x
    print(ans)
resolve()

Measured memory_bytes: 9092
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

double dp[310][310][310];
int N;

// dp[i][j][k] = dp[i][j][k] * (N-i-j-k)/N + dp[i-1][j+1][k] * i/N + dp[i][j-1][k+1] * j/N + dp[i][j][k-1] * k/N + 1
// (i+j+k)dp[i][j][k] = i*dp[i-1][j+1][k] + j*dp[i][j-1][k+1] + k*dp[i][j][k-1] + N
// dp[i][j][k] = dp[i-1][j][k] * i / (i+j+k) + dp[i][j-1][k+1] * j / (i+j+k) + dp[i][j][k-1] * k / (i+j+k) + N / (i+j+k)

double rec(int i,int j,int k){
    if(dp[i][j][k]!=-1) return dp[i][j][k];
    double denom = i + j + k;
    if(denom==0) return 0.0;
    double ret = N / denom;
    if(i > 0) ret += rec(i-1,j+1,k) * i / denom;
    if(j > 0) ret += rec(i,j-1,k+1) * j / denom;
    if(k > 0) ret += rec(i,j,k-1) * k / denom;
    return dp[i][j][k] = ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int t,one=0,two=0,three=0; cin >> N;
    REP(i,N){
        cin >> t;
        if(t==1) ++one;
        else if(t==2) ++two;
        else ++three;
    }
    REP(i,N+1) REP(j,N+1) REP(k,N+1) dp[i][j][k] = -1;
    cout << fixed << setprecision(15) << rec(three,two,one) << endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int m;
  for(int i = 1; i <= n; i++){
    if(i * (i+1) / 2 >= n){
      m = i;
      break;
    }
  }
  vector<int> ans;
  ans.push_back(m);
  int k = m;
  for(int i = m-1; i >= 1; i--){
    if(k + i > n) continue;
    k += i;
    ans.push_back(i);
    if(k == n) break;
  }
  for(auto x : ans) cout<<x<<endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
#define maxn 100010
using namespace std;
typedef long long ll;
int v[11][11][11], n, sum, p1[11], p2[11], p3[11];
char s[31000];
int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    ff(i, 1, n) {
        if(p1[s[i] - '0'])continue;
        p1[s[i] - '0'] = 1;
        memset(p2, 0, sizeof(p2));
        ff(j, i + 1, n) {
            if(p2[s[j] - '0'])continue;
            p2[s[j] - '0'] = 1;
            memset(p3, 0, sizeof(p3));
            int pan = 0;
            ff(k, j + 1, n) {
                if(p3[s[k] - '0'])continue;
                p3[s[k] - '0'] = 1;
                pan++;
                if(!v[s[i] - '0'][s[j] - '0'][s[k] - '0']) {
                    sum++;
                    v[s[i] - '0'][s[j] - '0'][s[k] - '0'] = 1;
                }
                if(pan == 10)
                    break;
            }
        }
    }
    printf("%d", sum);
    return  0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
sum=0
for i in range(m):
    b.append(list(map(int,input().split())))
b.sort(key=lambda x: x[1])
B=len(b)
b1=b[B-1][0]
b2=b[B-1][1]
b3=0
for i in range(n):
    if a[i]<b2 and b3==0:
        sum+=b2
        b1-=1
    else:
        sum+=a[i]
    if b1==0:
        B-=1
        if B==0:
            b3=1
        b1=b[B-1][0]
        b2=b[B-1][1]
print(sum)


Measured memory_bytes: 81304
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
int n;
int l[222];
int main(void){
  cin >> n;
  for(int i = 0; i < 2*n; i++){
    cin >> l[i];
  }
  sort(l,l+2*n);
  int sum = 0;
  for(int i = 0; i < 2*n; i+=2){
    sum += l[i];
  }
  cout << sum << endl;
}


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

int main(){
    float r;
    cin >> r;
    cout << 2*3.14*r << "\n";
    return 0;
}

Measured memory_bytes: 3788
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 700;
    for(int i = 0 ; i < s.length() ; ++i){
      if(s.charAt(i) == 'o'){
        ans += 100;
      }
    }

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i,a[n],b[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++)
	{
		if(a[i]==b[n-1])
		{
			cout<<b[n-2]<<endl;
			continue;
		}
		cout<<b[n-1]<<endl;
	}
}

Measured memory_bytes: 5108
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  ll a[5];
  ll N; cin >> N;
  ll minNum = 1e18;
  for ( int i = 0; i < 5; i++ ) {
    cin >> a[i];
    minNum = min(minNum,a[i]);
  }
  if ( minNum >= N ) {
    cout << 5 << endl;
    return 0;
  }

  ll k = (N-1)/minNum;
  ll ans = 5 * (k+1);
  ans -= 4*k;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, a, b, c;
  cin >> n;
  a = n / 100; 
  b = (n - a * 100) / 10; 
  c = n - a * 100 - b * 10; 
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,n,count=0,a[100];
    scanf("%d",&n);
     for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]%2==1 && i%2==1)
    {
        count++;
    }
    }

    printf("%d\n",count);

    return 0;
}


Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		if(a+b>=c){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
import java.util.Scanner;

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

        switch (s){
            case "SUN":
                System.out.println("7");
                break;
            case "MON":
                System.out.println("6");
                break;
            case "TUE":
                System.out.println("5");
                break;
            case "WED":
                System.out.println("4");
                break;
            case "THU":
                System.out.println("3");
                break;
            case "FRI":
                System.out.println("2");
                break;
            case "SAT":
                System.out.println("1");
                break;
            default:
                System.out.println("?");
                break;
        }
    }
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

X = INT()

cur = 100
ans = 0
while cur < X:
    cur = cur * 1.01 // 1
    ans += 1
print(ans)


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  ll ans = 0;
  vector<int> dp(n + 1, 1e9);
  dp[0] = 0;
  auto ch = [&] (int i, int v) {
    if(i <= n) dp[i] = min(dp[i], v);
    return i <= n;
  };
  for(int i = 0; i < n; i++) {
    ch(i + 1, dp[i] + 1);
    int t = 6;
    while(ch(i + t, dp[i] + 1)) t *= 6;
    t = 9;
    while(ch(i + t, dp[i] + 1)) t *= 9;
  }
  cout << dp[n] << endl;
  return 0;
}


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

int gcd(int a, int b) {
	if(a == 0) return b;
	if(b == 0) return a;
	if(a > b) swap(a, b);
	int r = b % a;
	if(r == 0) return a;
	else return gcd(r, a);
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &x: A) cin >> x;
	vector<int> L(N+1, 0), R(N+1, 0);
	for(int i = 0; i < N; i++) {
		L[i + 1] = gcd(L[i], A[i]);
	}
	for(int i = N - 1; i >= 0; i--) {
		R[i] = gcd(R[i + 1], A[i]);
	}
	int res = 0;
	for(int i = 0; i < N; i++) {
		int m = gcd(L[i], R[i + 1]);
		res = max(res, m);
	}
	cout << res << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    //int dp[3001][3001] = {{}};
    vector<vector<int>> dp(3001, vector<int>(3001, 0));
    string S, T;
    cin >> S;
    cin >> T;
    
    for(int i = 1; i < S.size()+1; i++){
        for(int j = 1; j < T.size()+1; j++){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(S[i-1] == T[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
        }
    }
   
  	if(dp[S.size()][T.size()] > 0){
          int i = S.size();
          int j = T.size();
          char output[3001];
          long long count_output = 0;
          long long count = 0;
          while(true){
              if(i == 0 and j == 0)
                break;
                
              if(i > 0 && j > 0 && dp[i][j] == dp[i-1][j-1]){
                i--;
                j--;
              }
              else if(i > 0 && dp[i][j] == dp[i-1][j])
                i--;
              else if(j > 0 && dp[i][j] == dp[i][j-1])
                j--;
              else{
                output[dp[S.size()][T.size()]-count_output-1] = S[i-1];
                count_output++;
                i--;
                j--;
              }
              
        }
        
        for(int i = 0; i < count_output; i++)
            cout << output[i];
    }
    else
      	cout << ' ';
}


Measured memory_bytes: 35584
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n=int(input())
ans=0
ans=int(input())
if n==1:
    print(ans)
    exit()

for i in range(n-1):
    t=int(input())
    ans=lcm(ans,t)

print(ans)

Measured memory_bytes: 5688
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=220,M=100100,oo=1000000000;
int i,j,k,n,m,En,S,T,ans;
int h[N],c[N],d[N];
char s[N][N];
struct edge { int s,n,v;} E[M];
void E_add(int x,int y,int v) {
	E[++En].s=y;E[En].v=v;
	E[En].n=h[x];h[x]=En;
}
bool bfs() {
	memset(c,0,sizeof c);
	int i,j,k;
	i=0;j=1;d[1]=S;c[S]=1;
	while (i<j) {
		i++;
		for (k=h[d[i]];k;k=E[k].n) if (E[k].v && !c[E[k].s]) {
			c[E[k].s]=c[d[i]]+1;
			d[++j]=E[k].s;
		}
	}
	return c[T];
}
int dfs(int x,int y) {
	if (x==T || !y) return y;
	int t,k,Y=y;
	for (k=h[x];k;k=E[k].n) if (E[k].v && c[x]+1==c[E[k].s]) {
		t=dfs(E[k].s,min(y,E[k].v));
		y-=t;
		E[k].v-=t;
		E[k^1].v+=t;
		if (!y) return Y;
	}
	if (Y==y) c[x]=-1;
	return Y-y;
}
int main() {
	scanf("%d%d",&n,&m);
	S=n+m+1;T=S+1;En=1;
	for (i=1;i<=n;i++) {
		scanf("%s",s[i]+1);
		for (j=1;j<=m;j++) if (s[i][j]!='.') {
			if (s[i][j]=='o') E_add(i,n+j,1),E_add(n+j,i,1);
			else {
				if (s[i][j]=='S') {
					E_add(S,i,oo);
					E_add(i,S,0);
					E_add(S,n+j,oo);
					E_add(n+j,S,0);
				}
				else {
					E_add(i,T,oo);
					E_add(T,i,0);
					E_add(n+j,T,oo);
					E_add(T,n+j,0);
				}
			}
		}
	}
	while (bfs()) ans+=dfs(S,oo);
	if (ans>=oo) puts("-1");
	else printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define INF 999999999
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

set<int> d;

int main()
{
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		d.insert(num);
	}

	cout << d.size() << endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()

	es := make([][]edge, n)

	for i := 0; i < n-1; i++ {
		a,b,c := scanInt()-1, scanInt()-1, scanInt()
		es[a] = append(es[a], edge{b,c})
		es[b] = append(es[b], edge{a,c})
	}

	q := scanInt()
	k := scanInt()-1

	queue := make([]int, 0)
	queue = append(queue, k)

	dist := make([]int, n)
	for i := 0; i < n; i++ {
		dist[i] = -1
	}
	dist[k] = 0

	for len(queue) != 0 {
		next := queue[0]
		for _, e := range es[next] {
			if dist[e.to] != -1 {
				continue
			}

			dist[e.to] = dist[next] + e.c
			queue = append(queue, e.to)
		}
		queue = queue[1:]
	}

	for i := 0; i < q; i++ {
		x, y := scanInt()-1, scanInt()-1
		fmt.Fprintln(wr, dist[x]+dist[y])
	}
	wr.Flush()
}

type edge struct {
	to int
	c int
}


Measured memory_bytes: 15232
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int r, c, q;
	
	while (scanf("%d %d %d", &r, &c, &q) && r){
		int row[50000], col[50000];
		vector<int> rIn, cIn;
		vector<int> rOut, cOut;
		int ans = 0;
		for (int i = 0; i < r; i++) row[i] = -99999;
		for (int i = 0; i < c; i++) col[i] = -99999;
		
		for (int i = 1; i <= q; i++){
			int a, b, c;
			scanf("%d %d %d", &a, &b, &c);
			if (a == 0) row[b] = c ? i : -i;
			else col[b] = c ? i : -i;
		}
		
		for (int i = 0; i < r; i++){
			if (row[i] != -99999){
				(row[i] > 0) ? (rIn.push_back(row[i])) : (rOut.push_back(-row[i]));
			}
		}
		
		for (int i = 0; i < c; i++){
			if (col[i] != -99999){
				(col[i] > 0) ? (cIn.push_back(col[i])) : (cOut.push_back(-col[i]));
			}
		}
		
		sort(rIn.begin(), rIn.end()); sort(rOut.begin(), rOut.end());
		sort(cIn.begin(), cIn.end()); sort(cOut.begin(), cOut.end());
		
		for (int i = 0; i < rIn.size(); i++){
			int minus = cOut.size() - (lower_bound(cOut.begin(), cOut.end(), rIn[i]) - cOut.begin());
			minus += cIn.size() - (lower_bound(cIn.begin(), cIn.end(), rIn[i]) - cIn.begin());
			ans += c - minus;
		}
		
		for (int i = 0; i < cIn.size(); i++){
			int minus = rOut.size() - (lower_bound(rOut.begin(), rOut.end(), cIn[i]) - rOut.begin());
			minus += rIn.size() - (lower_bound(rIn.begin(), rIn.end(), cIn[i]) - rIn.begin());
			ans += r - minus;
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 1720
N,X,Y=[int(s) for s in input().split()]
ans=[0 for i in range(N)]
def distance(i,j):
  return min([j-i,abs(j-Y)+abs(i-X)+1])
  
for i in range(1,N):
  for j in range(i+1,N+1):
    d=distance(i,j)
    ans[d]+=1

for i in range(1,N):
  print(ans[i])

Measured memory_bytes: 9184
#include<stdio.h>
int main()
{
  int	an;
  char s[3];
  
  scanf("%s", s);
  for(int i=0;i<3;i++){
  	if(s[i]=='a') an+=1;
  	if(s[i]=='b') an+=2;
  	if(s[i]=='c') an+=3;
  }
  
  if(an==6) printf("Yes");
  else printf("No");
  
  return 0;
}


Measured memory_bytes: 128
while True:
    a,b,c=map(int,input().split())
    d = a+b
    
    if a == -1 and b == -1 and c == -1:
        break
    
    if a == -1 or b == -1:
        print("F")
    elif d < 30:
        print("F")
    elif d < 50:
        if c >= 50:
            print("C")
        else:
            print("D")
    elif d < 65:
        print("C")
    elif d < 80:
        print("B")
    else:
        print("A")



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

using namespace std;

string solve(string s) {
  if (s.size() < 26) {
    for (int ch='a'; ch<='z'; ch++) {
      if (find(s.begin(), s.end(), ch) == s.end()) {
	s += ch;
	return s;
      }
    }
  }

  auto o = s;
  auto ret = next_permutation(o.begin(), o.end());
  if (!ret)
    return "-1";
  
  while (o.substr(0, o.size()-1) > s) {
    o.pop_back();
  }

  return o;
}

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

  cout << solve(s) << endl;

}


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

long long n;
vector<long long> two, three, six;

int main() {
  cin >> n;
  if(n == 3) {
    cout << "2 5 63" << endl;
    return 0;
  }
  if(n == 20000) cout << 6 << " ";
  assert(n != 3);
  for(int i = 2; i <= 30000; ++i)
    if(i % 6 == 0)
      six.push_back(i);
    else if(i % 2 == 0)
      two.push_back(i);
    else if(i % 3 == 0)
      three.push_back(i);
  cout << three[0] << " " << three[1];
  n -= 2;
  for(int i = 0; i + 1 < min(n, (long long)two.size());
      i += 2) {
    cout << " " << two[i] << " " << two[i + 1];
  }
  if(n % 2) {
    cout << " " << six[0];
    --n;
  }
  n -= min(n, (long long)two.size());
  n += 2;
  for(int i = 2; i + 1 < min(n, (long long)three.size());
      i += 2) {
    cout << " " << three[i] << " " << three[i + 1];
  }
  n -= min(n, (long long)three.size());
  ++n;
  for(int i = 1; i < min(n, (long long)six.size()); ++i)
    cout << " " << six[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

#define PLUS 0
#define MINUS -1
#define MUL -2
#define DIV -3

int main(){
	int formula[200];
	int stack[200];
	int sp = 0;
	int cnt = 0;
	char inputs[6];

	//input data
	while(scanf("%s", inputs) != EOF){
		//printf("%s\n", inputs);
		//printf("%c\n", inputs[0]);
		if(inputs[0] == '+'){
			formula[cnt] = PLUS;
		}else if(inputs[0] == '-'){
			formula[cnt] = MINUS;
		}else if(inputs[0] == '*'){
			formula[cnt] = MUL;
		}else if(inputs[0] == '/'){
			formula[cnt] = DIV;
		}else{
			formula[cnt] = atoi(inputs);
		}
		//printf("inputs: %d\n", formula[cnt]);
		cnt++;
	}

/*
	printf("formula: ");
	for(int i = 0; i < cnt; i++){
		printf("%d, ", formula[i]);
	}
	printf("\n");
*/
	
	//acc
	for(int i = 0;i < cnt;i++){
		if(formula[i] == PLUS){
			sp--;
			stack[sp - 1] += stack[sp];
		}else if(formula[i] == MINUS){
			sp--;
			stack[sp - 1] -= stack[sp];
		}else if(formula[i] == MUL){
			sp--;
			stack[sp - 1] *= stack[sp];
		}else if(formula[i] == DIV){
			sp--;
			stack[sp - 1] /= stack[sp];
		}else{
			stack[sp] = formula[i];
			sp++;
		}
/*
		printf("stack: ");
		for(int j = 0; j < sp; j++){
			printf("%d, ", stack[j]);
		}
		printf("\n");
*/
	}

	printf("%d\n", stack[sp - 1]);


}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
const i64 MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<int> V(2 * N);
    // 0 で l , 1 で r
    for(int i = 0; i < S.size(); i++) {
        V[i] = S[i] == 'B';
    }
    int st = 0;
    i64 ans = 1;
    for(int i = 0; i < S.size(); i++) {
        if(V[i] != (st % 2)) {
            st++;
        } else {
            ans *= st;
            ans %= MOD;
            st--;
        }
        if(st < 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    if(st != 0) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i <= N; i++) {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1412
y,k,i,j;main(n){scanf("%d%d",&n,&y);for(;i<=n;i++)for(j=0;j<=n;j++){k=n-i-j;if(k>=0&&i*1e4+j*5e3+k*1e3==y){printf("%d %d %d",i,j,k);return 0;}}printf("-1 -1 -1");}

Measured memory_bytes: 128
<?php
$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$array = range('A','Z');
for($i=0; $i < strlen($s); $i++) {
    for($j = 0; $j < count($array); $j++) {
        if($s[$i] == $array[$j]) {
            $num = $j + $n;
            if($num > 25) {
                $num = abs(26 - $num);
            }
            $s[$i] = $array[$num];
            break;
        }
    }
}
echo $s;
?>

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pq 	priority_queue<int, vector<int>, greater<int> >
ll e=  1000000007;
using namespace std;


int main()
{
	
ll n,wt;
cin>>n>>wt;
ll w[n+1]={0},v[n+1]={0};
for(ll i=1;i<n+1;i++)
{	cin>>w[i]>>v[i];
	}	
	ll wn[wt+1]={0};
	for(ll i=1;i<n+1;i++)
	{
		for(ll j=wt;j>0;j--)
		{    
		    if(j+w[i]<=wt){
		
			 if((wn[j]+v[i])>wn[j+w[i]]&&wn[j]!=0)(wn[j+w[i]]=wn[j]+v[i]);
		}}
		
	    if(v[i]>wn[w[i]])	wn[w[i]]=v[i];
	//	cout<<" new"<<endl;
		for(ll i=1;i<wt+1;i++)
	{
		
//	cout<<wn[i]<<endl;
	}
	}
	
	ll k=0;
	for(ll i=1;i<wt+1;i++)
	{
		
		if(wn[i]>k)k=wn[i];
	}

cout<<k;
	
 return 0;
}

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

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

const long long INF = 1LL << 60;

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

  cout << (n-1) * (m-1) << endl;

  return 0;
}


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

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  if(B<A){
    cout << 0 << endl;
    return 0;
  }else if(N==1&&A!=B){
    cout << 0 << endl;
    return 0;
  }
  cout << (N-2)*(B-A) + 1 << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int X; cin >>X;
    
    int ans = 1;
    for (int b=2;b*b<X;b++) {    
        for (int p=2; ;p++) {
            int n = (int)pow(b,p);
            if (n > X) break;
            ans=max(ans,n);
        }
    }
    cout << ans << endl;
}


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

#pragma GCC optimize("Ofast")
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(){
	int n,k; cin >> n >> k;
    ll sum = 0;
    ll a[n+1]; rep(i,0,n+1) a[i] = i;
    for(int i = n-1; i >= 0; i--) a[i] += a[i+1];

    for(ll i = n+1; i >=k; i--){
        ll tmp = a[n+1-i]-i*(i-1)/2+1;
        sum = (sum+tmp)%MOD;
    }    
    cout << sum << "\n";
}

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

ll x,y,tmp;

inline ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}

int main(){

	cin >>x>>y;

	ll g = gcd(x,y);

	for(ll i=2; i<= g / i; i++){
		if(g%i==0)
			{
				tmp++;
				while(g%i == 0) g /= i;
			}
    }
	if(g>1)tmp++;
	cout<<tmp+1<<endl;

	return 0;
}


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

int main() {
	int N;
	cin >> N;
	int p[N+1];
	p[0] = -100000;
	for (int i = 1;i < N+1;i++) {
		cin >> p[i];
	
	}
	

	
	for (int i = 1;i < N+1;i++) {
		int key = p[i];
		for (int j= 0;j <i ;j++) {

			if (p[j] <=key && key <= p[j + 1]) {
				for (int l = i-1; l >= j+1;l--)
					p[l + 1] = p[l];
				p[j + 1] = key;
				break;
			}
		}
	
		for (int k = 1;k < N + 1;k++) {
			cout << p[k] ;
			if(k !=N)
			cout << ' ';
		}
		
		
		cout << '\n';
	}
	
	
}


Measured memory_bytes: 3092
import java.util.Scanner;

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

		String we = sc.next();

		if(we.equals("Sunny")) {
			System.out.println("Cloudy");
		}else if(we.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}
	}
}

Measured memory_bytes: 22228
#include<iostream>
using namespace std;
#include<vector>
#include<cmath>
#include<algorithm>
#define int long long int
#define mod 1000000007
#define inf 200000000001
int function(int h,int memo[],int arr1[],int arr2[],int n)
{
	if(h<=0)
	   return 0;
	if(memo[h]!=-1)
	   return memo[h];
	else
	{
		int answer=inf;
		int j;
		for(j=0;j<n;j++)
		{
			int val=arr2[j]+function(h-arr1[j],memo,arr1,arr2,n);
			answer=min(answer,val);
		}
		memo[h]=answer;
		return memo[h];
	} 
}
int32_t main()
{
   int h;
   cin>>h;
   int memo[h+1];
   int j;
   for(j=0;j<=h;j++)
      memo[j]=-1;
   int n;
   cin>>n;
   int arr1[n],arr2[n];
   for(j=0;j<n;j++)
   {
	   cin>>arr1[j]>>arr2[j];
   }
   int answer=function(h,memo,arr1,arr2,n);
   cout<<answer<<endl;
}


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

	cin >> s;
	for(int i=0;i<s.length()/2;i++){
		if (s.substr(i,1)!=s.substr(s.length()-i-1,1)){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

  if (N < 10)
  {
    cout << R + 100 * (10 - N) << endl;
  }
  else
  {
    cout << R << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int m,f,r;
    while(1)
    {
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1)
        {
            break;
        }
        if(m==-1 || f==-1 || (m+f)<30)
        {
            printf("F\n");
        }
        else if((m+f)>=80)
        {
            printf("A\n");
        }
         else if((m+f)>=65 && (m+f)<80)
        {
            printf("B\n");
        }
         else if((m+f)>=50 && (m+f)<65 || r>=50)
        {
            printf("C\n");
        }
         else if((m+f)>=30 && (m+f)<50)
        {
            printf("D\n");
        }

    }
    return 0;
}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t;
	scanf("%d %d",&n,&t);
	int a[100000];
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	int Min=1e9+7,count=0,maxcount=0,ans=0,cc=0;
	for(int i=0;i<n;i++){
		if(Min>a[i]){
			Min=a[i];
			count=1;
			ans+=min(count,maxcount);
			maxcount=0;
		}
		else if(Min==a[i]){
			count++;
		} 
		if(a[i]-Min>cc){
			cc=a[i]-Min;
			maxcount=1;
			ans=0;
		}
		else if(a[i]-Min==cc){
			maxcount++;
		}
	//	printf("%d\n",ans);
	}
	ans+=min(count,maxcount);
	printf("%d\n",ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,w,k;
  cin>>h>>w>>k;
  int sum=0;
  vint hsum(10,0);
  vint wsum(10,0);
  vector<string> c(h);
  rep(i,h){
      cin>>c[i];
  }
  rep(i,h){
      rep(j,w){
          if(c[i][j]=='#'){
              sum++;
          }
      }
  }
  int count=0;
  for(int bit=0;bit<(1<<(h+w));bit++){
      int tmp=sum;
      vector<vector<bool> > fg(h,vector<bool>(w,false));
      for(int i=0;i<h+w;i++){
          if(bit & (1<<i)){
              if(i<h){
                  rep(j,w){
                      if(!fg[i][j]){
                          if(c[i][j]=='#'){
                            fg[i][j]=true;
                            tmp--;
                          }
                      }
                  }
              }
              else{
                  rep(j,h){
                      if(!fg[j][i-h]){
                          if(c[j][i-h]=='#'){
                            fg[j][i-h]=true;
                            tmp--;
                          }
                      }
                  }
              }
                  
          }
          
      }
      if(tmp==k){
          count++;
      }
  }
  cout<<count<<'\n';
  return(0);
}

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

int main(){
  int n,m;
  
  while(1){
    cin>>n>>m;
    if(n==0 && m==0) break;
    int array[n],sum=0;
    for(int i=0;i<n;i++)
      cin>>array[i];
    sort(array,array+n);
    reverse(array,array+n);
    for(int i=0;i<n;i++){
      if((i+1)%m==0) array[i]=0;
      sum+=array[i];
    }   
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
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;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
#define MAX 100000
int a[MAX],n;
int partition(int p,int r){
    int x,i,j,t;
    x=a[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(a[j]<=x){
            i++;
            swap(a[i],a[j]);
        }

    }
    swap(a[i+1],a[r]);
    return i+1;
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int i,q;cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    q=partition(0,n-1);
    for(i = 0;i<n;i++){
        if(i)cout<<" ";
        if(i==q)cout<<'[';
        cout<<a[i];
        if(i==q)cout<<']';
    }
    cout<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































Measured memory_bytes: 3540
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsTest
{
    static class CsTest { 
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).Aggregate(1, (i, j) => i * j));
        }
    }
}

Measured memory_bytes: 28308
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int N = int.Parse(input1[0]);
        int M = int.Parse(input1[1]);
        long[] A = new long[N];
        int[] B = new int[N];
        for(int i = 0; i < N; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            A[i] = long.Parse(input[0]);
            B[i] = int.Parse(input[1]);
        }
        Array.Sort(A, B);
        long c = 0;
        long sum = 0;
        for(int i = 0; i < N; i++)
        {
            if(c + B[i] >= M)
            {
                sum += (M - c) * A[i];
                break;
            }
            else
            {
                sum += A[i] * B[i];
                c += B[i];
            }
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 16328
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int main(){
  int n, A, B; cin >> n >> A >> B;
  string s; cin >> s;

  int a = 0, b = 0;
  REP(i, s.size()){
    if(s[i] == 'a'){
      if(a+b < A+B){
        a++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else if(s[i] == 'b'){
      if(a+b < A+B && b < B){
        b++;
        cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 896
//*****************************believer******************************//
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef map<ll,ll> mi;
 
#define f first
#define ss second
#define ins insert
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define pq priority_queue
#define sqr(n) floor(sqrt(n))
#define sz(v) ((ll)(v.size()))
#define trav(a,x) for (auto& a: x)
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define mem(a) memset(a, -1, sizeof (a))
#define ssort(v) sort((v).begin(),(v).end())
#define rsort(v) sort((v).rbegin(),(v).rend())
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define foo(i,a,b) for (ll i = (a); i < (b); ++i)
#define foor(i,a,b) for (ll i = (a); i >= (b); --i)

const ll N=2e5+100;
ll dp[N];
vi a;
ll n,k;

ll solve(ll x)
{
    if(dp[x]!=-1)
    return dp[x];
    
    dp[x]=solve(x-1)+abs(a[x]-a[x-1]);
    
    foo(i,2,k+1)
    if(x-i>=0)
    dp[x]=min(dp[x],solve(x-i)+abs(a[x]-a[x-i]));
    
    return dp[x];
    
}

int main()
{
    
        cin>>n>>k;
        a.resize(n);
        foo(i,0,n)
        cin>>a[i];
        mem(dp);
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        ll ans=solve(n-1);
        cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 10328