akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, k;
int main() {
    cin >> n >> k;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    vector<long long> aup;
    long long start = a.at(0)+1;
    for(int i = 1; i < n; ++i) aup.push_back(a.at(i));
    int uplen = aup.size();
    k--;

    long long mincost = 1e18;
    for(int bit = 0; bit < (1<<uplen); ++bit) {
        vector<int> ss(uplen, 0);
        int cnt = 0;
        for(int i = 0; i < uplen; ++i) {
            if(bit & (1<<i)) {
                ss.at(i) = 1;
                cnt++;
            }
        }

        if(cnt == k) {
            long long cstart = start;
            long long sum = 0;
            for(int j = 0; j < uplen; ++j) {
                if(ss.at(j) == 1) {
                    if(cstart < aup.at(j)) {
                        cstart = aup.at(j)+1;
                    }else {
                        sum += (cstart - aup.at(j));
                        cstart++;
                    }
                }else {
                    if(cstart < aup.at(j)) {
                        cstart = aup.at(j)+1;
                    }
                }
            }
            chmin(mincost, sum);
        }
    }
    cout << mincost << endl;
}

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

const double pi = atan(1) * 4;

int main ()
{
    double S, L, h;
    double a, b, C;
    
    cin >> a >> b >> C;
    
    double angle = pi/180 * C;
    
    S = 0.5 * a * b * sin(angle);
    L = a + b + sqrt(a*a + b*b - 2 * a * b * cos(angle));
    h = b * sin(angle);
    
    cout << setprecision(10) << S << endl;
    cout << setprecision(10) << L << endl;
    cout << setprecision(10) << h << endl;
    return 0;
}


Measured memory_bytes: 3480
a, b = map(int, (input().split()))


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def factorization(n):
    factors = []
    if n == 1: return factors
    i = 2
    while i ** 2 <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1: factors.append(n)
    return factors


print(len(set(factorization(gcd(a, b)))) + 1)


Measured memory_bytes: 3060
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    auto T = sread();
    auto b = new long[][](26);
    foreach (i, c; S)
        b[c - 'a'] ~= i;
    foreach (c; T)
        if (b[c - 'a'].empty)
        {
            writeln(-1);
            return;
        }
    long ptr;
    long ans;
    foreach (j, c; T)
    {
        long k = () {
            long ok = 0;
            long ng = b[c - 'a'].length;
            while (1 < ng - ok)
            {
                long m = (ok + ng) / 2;
                if (b[c - 'a'][m] <= ptr)
                    ok = m;
                else
                    ng = m;
            }
            return ok;
        }();
        long m = long.max;
        foreach (i; [
                b[c - 'a'][k], b[c - 'a'][(k + 1) % $], b[c - 'a'][($ + k - 1) % $]
            ])
        {
            if (ptr == i)
                m = m.min((j != 0 && T[j - 1] == c) ? S.length : 0);
            if (ptr < i)
                m = m.min(i - ptr);
            if (i < ptr)
                m = m.min(S.length + i - ptr);
        }
        ptr += m;
        ptr %= S.length;
        ans += m;
    }
    writeln(ans + 1);
}


Measured memory_bytes: 5900
// template {{{
#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

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

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int N = 305;
int n;
double mem[N][N][N];
double dp(int one, int two, int three)
{
    double &ret = mem[one][two][three];
    int empty = n-one-two-three;
    if (empty == n) return 0.0;
    if (ret >= 0.0) return ret;
    ret = 0.0;
    ret += (one) ? one * (1.0 + dp(one-1, two, three)) : 0.0;
    ret += (two) ? two * (1.0 + dp(one+1, two-1, three)) : 0.0;
    ret += (three) ? three * (1.0 + dp(one, two+1, three-1)) : 0.0;
    if (empty) ret = ((double)n / (double)(n-empty)) * (empty + ret);
    ret /= n;
    return ret;
}

void solve()
{
    cin >> n;
    int three = 0, two = 0, one = 0;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++)
        for (int k = 0; k < N; k++) mem[i][j][k] = -1.0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a == 1) one++;
        if (a == 2) two++;
        if (a == 3) three++;
    }
    cout << fixed << setprecision(12) << dp(one, two, three) << endl;
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


Measured memory_bytes: 221952
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B, H, M = map(int, input().split())

RA = (H * 60 + M) / 720 * 360
RB = M / 60 * 360

rad = abs(RA - RB)

sq = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(rad))

print(abs(math.sqrt(sq)))

Measured memory_bytes: 10012
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int x = Integer.parseInt(s);

            System.out.println(x < 1200 ? "ABC" : "ARC");
        }
    }
}


Measured memory_bytes: 20820
import java.util.*;
public class Main{
  public static void main(String []args){
  Scanner sc = new Scanner(System.in);

  int[] data = new int[3];
  int count = 0;

  for (int i = 0;i<3 ;i++ ) {
    data[i] = sc.nextInt();
  }

  Arrays.sort(data);

  for (int i = 0;i<2 ;i++ ) {
    for (;data[i]<data[2]-1 ; ) {
        count++;
        data[i] +=2;
    }
  }
  if ((data[2]!=data[1])&&data[2]==data[0]) {
    System.out.println(count+2);
    System.exit(0);
  }else if (data[2]==data[1]&&data[2]!=data[0]) {
    System.out.println(count+2);
    System.exit(0);
  }else if (data[0]==data[1]&&data[2]==data[0]) {
    System.out.println(count);
    System.exit(0);
  }
  System.out.println(count+1);

  }
}


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


int main() {
	string input;
	cin >> input;
	if (input == "SAT")
		cout << 1;
	else if (input == "MON")
		cout << 6;
	else if (input == "TUE")
		cout << 5;
	else if (input == "WED")
		cout << 4;
	else if (input == "THU")
		cout << 3;
	else if (input == "FRI")
		cout << 2;
	else if (input == "SUN")
		cout << 7;
}

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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MX = 107, INF = 1e9;
int res[MX][MX];
queue<pii> Q;
bool vis[MX];
int pred[MX];
int n, m; 

int BFS(){
	memset(vis, 0, sizeof(vis));
	while(!Q.empty()) Q.pop();
	vis[1] = 1; Q.push({1, INF});
	while(!Q.empty()){
		pii p = Q.front(); Q.pop();
		int u = p.ST, flo = p.ND;
		if(u == n){
			while(u != 1){
				res[pred[u]][u] -= flo;
				res[u][pred[u]] += flo;
				u = pred[u];
			}
			return flo;
		}
		for(int v = 1; v <= n; ++v){
			if(v != u && !vis[v] && res[u][v] > 0){
				vis[v] = 1;
				pred[v] = u;
				Q.push({v, min(res[u][v], flo)});
			}
		}
	}
	return 0;
}

int32_t main()
{
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; ++i){
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		++a; ++b;
		res[a][b] = c;
	}
	LLI maxflow = 0;
	int pom;
	do{
		pom = BFS();
		maxflow += pom;
	}while(pom > 0);
	printf("%lld\n", maxflow);
}




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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=1;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#define taskname "A"

#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
#define long long long

const int N = 1e5 + 10;

int n, h[N];
long f[N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &h[i]);
    f[1] = 0, f[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i)
        f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
    cout << f[n];

    return 0;
}


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

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

signed main(void)
{
	int h, w, cnt;
	cin >> h >> w;
	string s[h];

	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, w)
	{
		cnt = 0;
		if (s[i][j] == '#') continue;
		for (int k = 0; k < 8; k++)
		{
			if (i + dx[k] < 0 || j + dy[k] < 0 ||\
					i + dx[k] >= h || j + dy[k] >= w) continue;
			if (s[i + dx[k]][j + dy[k]] == '#') cnt++;
		}
		s[i][j] = cnt + '0';
	}
	rep(i, h)
	{
		rep(j, w)
			cout << s[i][j];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import Counter
from collections import deque

H, W = map(int, input().split())
s = [list(input().rstrip()) for h in range(H)]

bc = 0
for h in range(H):
  n = Counter(s[h])
  bc += n['#']


def dfs():
  que = deque()
  que.append((0,0))
  di = [1, 0, -1, 0]
  dj = [0, 1, 0, -1]
  d = [[float('inf')]*W for h in range(H)]
  d[0][0] = 0
  while que:
    point = que.popleft()
    if point[0] == H-1 and point[1] == W-1:
      break
    for i in range(4):
      ni = point[0] + di[i]
      nj = point[1] + dj[i]
      if 0 <= ni < H and 0 <= nj < W and d[ni][nj] == float('inf') and s[ni][nj] != '#':
        que.append((ni, nj))
        d[ni][nj] = d[point[0]][point[1]] + 1
  return d[H-1][W-1]

    
score = H*W - bc - dfs() -1 
if dfs() == float('inf'):
  score = -1
print(score)

Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int mod = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int ans = 1;
    rep(i, 1, n + 1){
        ans = ans * i % mod;
    }
    o(ans);
}

Measured memory_bytes: 256
def animal(x,y):
    if x*4==y or x*2==y:
        return "Yes"
    for i in range(1,x+1):
        if ((x-i)*4 + i*2) == y:
            return "Yes"
    return "No"

if __name__ == "__main__":
    x,y = map(int,input().split())
    print(animal(x,y))

Measured memory_bytes: 9184
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b; cin >> a >> b;
    cout << (a+b+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num1 = Integer.parseInt(s.next());
		int num2 = Integer.parseInt(s.next());
		int sub;
		
		if(num2 > num1){
			sub = num2;
			num2 = num1;
			num1 = sub;
		}
		
		System.out.println(num1 != num2 ? gcd(num1, num2) : num1);
	}
	
	public static int gcd(int num1, int num2){
		int sub = num1;
		num1 = Math.max(num1 - num2, num2);
		num2 = Math.min(sub - num2, num2);
		if(num1 != num2){
			return gcd(num1, num2);
		}else{
			return num2;
		}
	}

}

Measured memory_bytes: 26048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
ll dp[2][20001];
ll w[1000], s[1000], v[1000];
int main() {
	int N;
	cin >> N;
	vector<P> vec;
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> s[i] >> v[i];
		vec.emplace_back(w[i] + s[i], i);
	}
	sort(vec.begin(), vec.end());
	dp[0][w[vec[0].second]] = v[vec[0].second];
	for (int i = 0; i + 1 < N; i++) {
		int x = vec[i + 1].second;
		for (int j = 0; j <= 20000; j++) dp[(i + 1) & 1][j] = dp[i & 1][j];
		for (int j = 0; j <= s[x]; j++) {
			dp[(i + 1) & 1][j + w[x]] = max(dp[(i + 1) & 1][j + w[x]], dp[i & 1][j] + v[x]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= 20000; i++) ans = max(ans, dp[(N - 1) & 1][i]);
	cout << ans << endl;
}

Measured memory_bytes: 640
h, w = map(int, input().split())
s = [input().split() for _ in range(h)]
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(h):
    for j in range(w):
        if s[i][j] == 'snuke':
            print(alpha[j]+str(i+1))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void){
  string s;
  cin>>s;
  int a[26];
  for(int i = 0 ; i < 26 ; i ++)a[i] = 0;
  for(int i = 0 ; i < s.size() ; i ++){
    a[s[i]-'a'] = 1;
  }
  bool f = false;
  for(int i = 0 ; i < 26 ; i ++){
    if(!a[i]){
      cout<<(char)(i+'a')<<endl;
      f = true;
      break;
    }
  }
  if(!f)cout<<"None"<<endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    string str;cin>>str;
    int ctr =0,maxi=0;
    for(int i=0;i<str.length();i++){
        if(str[i]=='A'||str[i]=='C'||str[i]=='T'||str[i]=='G'){
            ctr+=1;
        }else{
            maxi = maxi>ctr?maxi:ctr;
            ctr =0;
        }
    }
    maxi = maxi>ctr?maxi:ctr;
    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);   
}
int dp[3001][3001],n,m;
string s,t,a;

void func()
{
  for(int i=n-1;i>=0;i--)
  {
    for(int j=m-1;j>=0;j--)
    {
      if(s[i]==t[j])
      {
        dp[i][j]=1+dp[i+1][j+1];
      }
      else{
        dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
  }

}
void solve()
{
  cin>>s>>t;n=s.size();m=t.size();
  func();
 // cout<<dp[0][0];
  int i=0,j=0;
  while(i<n && j<m)
  {
      if(s[i]==t[j]){a+=s[i];i++;j++;}

      else
      {
        if(dp[i+1][j]>dp[i][j+1]){i++;}
        else{j++;}
      }
      //cout<<i<<" "<<j<<endl;
  }
  cout<<a;
}
int main()
{
  fastio;
  //fopen();
  //int t;
  //cin>>t;
  rep(i,1)
  { 
    solve();
    cout<<endl;
  }
  
}


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

int main()
{
    double W,H,x,y;
    cin >> W >> H >> x >> y;

    if(x == W/2 && y == H / 2)
    {
        cout << fixed << setprecision(10) << W*H/2 << ' ' << 1 << endl;
    }
    else
    {
        cout << fixed << setprecision(10) << W*H/2 << ' ' << 0 << endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	char s[100], p[100];
	int slen,plen;
	int r = 0;
	int i,t;
	gets(s);
	gets(p);
	slen = strlen(s);
	plen = strlen(p);
	for(i = 0; i < slen; i++){//each start point
		for(t = 0; t < plen; t++){
			if(s[(i+t)%slen] != p[t%plen])break;
		}
		if(t == plen)r = 1;
	}
	if(r)puts("Yes");
	else puts("No");

	return 0;
}

Measured memory_bytes: 524
N = int(input())
p = list(map(int,input().split(" ")))
counter = 0
for i in range(N):
    if p[i] != i+1 and counter <= 1:
        counter = counter + 1
    elif p[i] != i+1 and counter > 1:
        counter = counter + 1
        break;
if counter <= 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <stdio.h>


int fee(int x, int y, int b, int p)
{
	int fee1, fee2;
	
	fee1 = x * b + y * p;
	
	if (b >= 5 && p >= 2){
		return ((x * b + y * p) * 4 / 5);
	}
	
	if (b < 5 && p >= 2){
		fee2 = (x * 5 + y * p) * 4 / 5;
		if (fee1 < fee2){
			return (fee1);
		}
		return (fee2);
	}

	if (b >= 5 && p < 2){
		fee2 = (x * b + y * 2) * 4 / 5;
		if (fee1 < fee2){
			return (fee1);
		}
		return (fee2);
	}

	fee2 = (x * 5 + y * 2) * 4 / 5;
	if (fee1 < fee2){
		return (fee1);
	}
	return (fee2);
}

int main(void)
{
	int N;
	int x, y, b, p;
	int i;
	
	scanf("%d", &N);
	for (i = 0; i < N; i++){
		scanf("%d%d%d%d", &x, &y, &b, &p);
		printf("%d\n", fee(x, y, b, p));
	}
	
	return (0);
}

Measured memory_bytes: 600
/*
 * @Author: BilyHurington
 * @Date: 2020-05-30 19:58:44
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-05-30 20:07:01
 */ 
#include<bits/stdc++.h>
using namespace std;
int n;
char s[200010];
int main(){
    scanf("%s",s+1);n=strlen(s+1);
    for(int i=1;i<=n;i++) if(s[i]=='?') s[i]='D';
    printf("%s",s+1);
    return 0;
}

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


int main(){
    // あとで消す
    //std::ifstream in("bin3.txt");
    //std::cin.rdbuf(in.rdbuf());

    vector< vector<int> > bingo(3, vector<int>(3, 0));

    for(size_t i=0;i<3;i++) for(size_t j=0;j<3;j++) cin >> bingo[i][j];
    
    int N,b;
    cin >> N;

    //for(size_t i=0;i<3;i++) for(size_t j=0;j<3;j++) cout << bingo[i][j] << endl;

    //cout << N << "hoge";
    for(int k=0;k<N;k++){
        cin >> b;
        //cout << b << endl;
        for(size_t i=0;i<3;i++){
            for(size_t j=0;j<3;j++){
                if(bingo[i][j]==b){
                //cout << "piyo" << endl;
                    bingo[i][j]=-1;
                }
            }
        }
    }

    //cout << N << "hoge";


    //for(size_t i=0;i<3;i++) for(size_t j=0;j<3;j++) cout << bingo[i][j] << endl;

    if(bingo[0][0]==-1&&bingo[1][1]==-1&&bingo[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[2][0]==-1&&bingo[1][1]==-1&&bingo[0][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }

    if(bingo[0][0]==-1&&bingo[1][0]==-1&&bingo[2][0]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[0][1]==-1&&bingo[1][1]==-1&&bingo[2][1]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[0][2]==-1&&bingo[1][2]==-1&&bingo[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }


    if(bingo[0][0]==-1&&bingo[0][1]==-1&&bingo[0][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[1][0]==-1&&bingo[1][1]==-1&&bingo[1][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }
    if(bingo[2][0]==-1&&bingo[2][1]==-1&&bingo[2][2]==-1){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;


    return 0;
}


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

public class Main {

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

		String strLine ="";
		BufferedReader stdReader =
				new BufferedReader(new InputStreamReader(System.in));
		int maxDataSize = 200;

		int argsCnt = 0;
		char[] dataSet = new char[maxDataSize];


		while ( ((strLine = stdReader.readLine()) != null)) {
			break;
		}

		byte[] asciiArray = strLine.getBytes("US-ASCII");

		for (int i = 0; i < asciiArray.length; i++) {

			if((asciiArray[i] >=  'a') && (asciiArray[i] <='z')){
				byte b = 32;
				asciiArray[i] = (byte)(Byte.toUnsignedInt(asciiArray[i]) -32);
			}


	}
		String resultString = new String(asciiArray, "US-ASCII");
		System.out.println(resultString);
	}

}

Measured memory_bytes: 24092
package main
 
import (
  	"fmt"
)
 
func main() {
  var N, M int
  fmt.Scan(&N)
  fmt.Scan(&M)
  
  a := make([]string, N)
  for i := 0; i < N; i++ {
  	fmt.Scan(&a[i])
  }
  b := make([]string, M)
  for i := 0; i < M; i++ {
  	fmt.Scan(&b[i])
  }
  
  ans := "No"
  for i := 0; i < N; i++ {
    for j := 0; j < N; j++ {
      if (i + M > N) || (j + M > N) {
        continue
      }
      
  	  flag := true
      for y := 0; y < M; y++ {
        for x := 0; x < M; x++ {
          if a[i+y][j+x:j+x+1] != b[y][x:x+1] {
            flag = false
          }
        }
      }
      if flag {
        ans = "Yes"
      }
    }
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1852
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int a=scan.nextInt();
            int b=scan.nextInt();
            int c=scan.nextInt();
            int k=scan.nextInt();
            boolean pos=recur(a,b,c,k);
            if(pos){
                out.println("Yes");
            }else{
                out.println("No");
            }
        }
        out.flush();
        out.close();
    }
    static boolean recur(int a,int b,int c,int k){
        if(c>b&&b>a){
            return true;
        }
        if(k==0){
            return false;
        }
        return recur(a,b*2,c,k-1)||recur(a,b,c*2,k-1);
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


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

int main() {
    int N;
    cin >> N;
    map<int, int> ma;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ma[a]++;
    }

    int res = 0;
    for (auto it = ma.begin(); it != ma.end(); it++) {
        pair<int, int> p = *it;
        if (p.second % 2) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll time=0;
	ll lt=0;
	ll i;
	pair<ll,ll> times[5];
	for(i=0;i<5;i++){
		cin>>lt;
		times[i]=make_pair((10-(lt%10))%10,lt);
	}
	sort(times,times+5);
	for(i=0;i<4;i++){
		time+=times[i].first;
		time+=times[i].second;
	}
	time+=times[i].second;
	cout<<time<<endl;
}

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

int main(){
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a -= 1;
    b -= 1;
    c -= 1;
    d -= 1;

    for(int i=b+1; i+1<=d-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=a+1; i+1<=c-1; i++){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }

    bool flag = false;
    for(int i=b; i<=d; i++){
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') flag = true;
    }
    if(c > d && flag == false) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main(){
    string S,T,U;
    int A,B;
    cin>>S>>T>>A>>B>>U;

    if(U==S){
        A--;
        cout<<A<<" "<<B<<endl;
    }
     else{
        B--;
        cout<<A<<" "<<B<<endl;
    }
}

Measured memory_bytes: 256
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    s = input()

    n = 0

    for c in s:
        if c == '+':
            n += 1
        else:
            n -= 1

    print(n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <stdio.h>
 #include <math.h>
 int main()
{
 double x1, y1, x2, y2, distance;
 scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
 distance=sqrt((pow(x2-x1, 2)+pow(y2-y1, 2)));
 printf("%f\n", distance);
 return 0;
 }


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

int main(){
  int n;
  while(cin>>n,n){
    string str[50];
    for(int i=0;i<n;i++)cin>>str[i];


    int num[]={5,7,5,7,7},ans=1000000;
    for(int i=0;i<n;i++){
      for(int j=i,idx=0,cnt=0;j<n;j++){
	cnt+=str[j].size();
	if(cnt==num[idx]) idx++,cnt=0;
	if(cnt>num[idx])break;
	if(idx==5) ans=min(ans,i);
      }    
    }
    cout <<ans+1<<endl;
  }
  return 0;
}

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

int main() {

    vector<vector<int>> Bingo(3, vector<int>(3));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) cin >> Bingo.at(i).at(j);
    }

    int N, S;
    cin >> N;
    vector<int> Bi(N);
    for(int i = 0; i < N; i++) {
        cin >> Bi.at(i);
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < N; k++) {
                if (Bingo.at(i).at(j) == Bi.at(k)) Bingo.at(i).at(j) = 0;
            }
        }
    }

    bool ans = false;
    for (int i = 0; i < 3; i++) {
        if (Bingo.at(i).at(0) == 0 && Bingo.at(i).at(1) == 0 && Bingo.at(i).at(2) == 0) ans = true;
        if (Bingo.at(0).at(i) == 0 && Bingo.at(1).at(i) == 0 && Bingo.at(2).at(i) == 0) ans = true;
    }
    if (Bingo.at(0).at(0) == 0 && Bingo.at(1).at(1) == 0 && Bingo.at(2).at(2) == 0) ans = true;
    else if (Bingo.at(0).at(2) == 0 && Bingo.at(1).at(1) == 0 && Bingo.at(2).at(0) == 0) {ans = true;}

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
	char c[22];
	int i,j;
	scanf("%s",c);
	for(i=0;c[i]!='\0';i++);
	for(j=0;j<i;j++){
		printf("%c",c[i-j-1]);
	}printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

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

    int p = 0;
    int n = 0;
    for (int i = 1; i < s.length(); ++i)
    {
        //cout << "p=" << p << " s[p]=" << s[p] << " i=" << i << " s[i]=" << s[i] << endl;
        //cout << s << endl; 
        if (s[p] != s[i])
        {
            s[p] = 'x'; s[i] = 'x';
            while (p >= 0)
            {
                p--;
                if (s[p] != 'x') 
                {
                    break;
                }
            }
            
            if (p == -1)
            {
                i++;
                p = i;
            } 

            ++n;
        }
        else 
        {
            if (p == i - 1)
            {
                p++;
            }
            else 
            {
                p = i;
            }
        }
    }
    
    cout << n*2;
        
    return 0;
}

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

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

    int a, b, c;
    cin >> a >> b >> c;

    int max_num = max(a, max(b, c));
    int diff = max_num * 3 - (a + b + c);
    if (diff % 2) {
        diff += 3;
    } 
    cout << diff / 2 << '\n';


    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int maxi = -1;
        int mini = 1e9;
        int sum = 0;
        for(int i = 1; i <= n; i++) {
            int in;
            cin >> in;
            maxi = max(maxi, in);
            mini = min(mini, in);
            sum += in;
        }
        cout << (sum - maxi - mini) / (n - 2) << endl;

    }
    return 0;
}


Measured memory_bytes: 3028
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


A, B, C = list(map(int, sys.stdin.buffer.readline().split()))

ans = 0
while not (A & 1 or B & 1 or C & 1):
    A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
    ans += 1
    if ans >= 1000000:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 13672
N = int(input())
honest = [[] for _ in range(N)]
liar = [[] for _ in range(N)]

for i in range(N):
    for _ in range(int(input())):
        x, y = map(int, input().split())
        if y == 1:
            honest[i].append(x - 1)
        elif y == 0:
            liar[i].append(x - 1)

ans = 0
for i in range(2 ** N):
    flag = True
    for j in range(N)[::-1]:
        if i >> j & 1:
            for k in honest[N - j - 1]:
                if not i >> (N - k - 1) & 1:
                    flag = False
            for k in liar[N - j - 1]:
                 if i >> (N - k - 1) & 1:
                     flag = False
            if flag is False:
                break
    if flag is True:
        ans = max(ans, bin(i).count("1"))

print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	map<char, int> roma;
	roma.insert(make_pair('I', 1));
	roma.insert(make_pair('V', 5));
	roma.insert(make_pair('X', 10));
	roma.insert(make_pair('L', 50));
	roma.insert(make_pair('C', 100));
	roma.insert(make_pair('D', 500));
	roma.insert(make_pair('M', 1000));

	char str[128];
	while(scanf("%s", str) != EOF){
		int v = 0;
		rep(i, strlen(str)){
			if(i && roma[str[i-1]]<roma[str[i]])
				v -= roma[str[i-1]]*2;
			v += roma[str[i]];
		}
		printf("%d\n", v);
	}
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] letters = scanner.nextLine().toCharArray();
		
		boolean[] exits = new boolean[26];
		Arrays.fill(exits, false);
		
		String ans = "yes";
		for (int i = 0; i < letters.length; i++) {
			if (exits[letters[i]-'a']) {
				ans = "no";
				break;
			}
			exits[letters[i]-'a'] = true;
		}
		System.out.println(ans);
		
		scanner.close();
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n)
	{
		cout << s[i] << t[i];
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
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);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }   
    vector<ll> F(N);
    for (int i = 0; i < N; i++) {
        cin >> F[i];
    }
    SORT(F);
    RSORT(A);
    vector<pair<ll, pii>> c(N);
    REP(i, N){
        c[i].fi = A[i]*F[i];
        c[i].se.fi = A[i];
        c[i].se.se = F[i];
    }

    ll l=-1, r=1e13L;
    while(r-l>1){
        ll mid = (r+l)/2;
        ll num = 0;
        REP(i, N){
            if(c[i].fi <= mid) continue;
            num += ((c[i].fi-mid)/c[i].se.se)+(((c[i].fi-mid)%c[i].se.se)==0?0:1);
        }
        if(num <= K) r = mid;
        else l = mid;
    }
    pr(r);
}

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

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int int
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 100010

char s[N] ;
int ans ;

int main() {
	scanf("%s" , s) ; 
	int n = strlen(s) ;
	for(int i = 0 ; i < n ; i ++) s[i] -= '0' ;
	ans = s[0] * 100 + s[1] * 10 + s[2] ;
	for(int i = 1 ; i < n - 2; i ++) {
		int c = s[i] * 100 + s[i + 1] * 10 + s[i + 2] ;
		if(abs(753 - c) < abs(753 - ans)) ans = c ;
	} 
	outn(abs(753 - ans)) ;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = ''
    n = '\n'
    A, B, K = map(int, input().split())
    AK = min(A+K, B)
    for i in range(A, AK):
        ans += str(i) + n
    BK = max(B-K+1, AK)
    for i in range(BK, B+1):
        ans += str(i) + n
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
read = sys.stdin.readline


# 下の桁から貪欲に見ていくと解ける
# 1の位が4以下ならそのまま紙幣で支払うのが得→自身をそのまま答えに採用 (枚数として加算)
# 6以上ならばお釣り狙いのほうが得→自身は0にセットして、上位桁を+1する (枚数として10-自身を加算)
# 5ちょうどのときは、お釣りもそのまま払っても枚数は変わらない。だけど555みたいに、上位桁に+1すると得になる可能性がある。
# 555→15枚, 1000-445→15枚
# つまり5が出たときは更に上位の桁を見て、4以下ならそのまま払うほうが得,5以上なら桁上りのほうが得

# 5ちょうどのときは？ #お釣りもそのまま払っても同じ。だけど上位 お釣り狙いだと上の桁が多くなって支払う金額が増える可能性がある？
# 5ピッタリのときに上位桁に+1すると悪くなる場合が存在する 455 とは 15にってしまう
# 5ピッタリのときはどうするのがよいのか？

N = '00' + read()[:-1]

N = N[::-1]
ans = 0

i = 0
lo = int(N[i])
while i < len(N) - 1:
    hi = int(N[i + 1])
    # loが5以外のとき (お釣りが良いか、そのまま払うのが良いか考えるだけ)
    if lo == 5:
        ans += lo
        if hi < 5:
            pass
        else:
            hi += 1
    elif lo < 5:  # 5が連続しないときもここに入る
        ans += lo
    else:
        ans += 10 - lo
        hi += 1  # 上の桁が繰り上がる
    lo = hi  # 桁を一つずらす
    i += 1


print(ans)


Measured memory_bytes: 5516
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 10000000000ll
#define ll long long
using namespace std;

int deg[111111];

int main() {
    int N,M;
    cin>>N>>M;
    
    for(int i=1;i<=N;i++)
        deg[i]=0;
    
    for(int i=1;i<=M;i++) {
        int u,v;
        cin>>u>>v;
        deg[u]++;
        deg[v]++;
    }
    
    bool ok=true;
    for(int i=1;i<=N;i++) {
        if (deg[i]%2)
            ok=false;
    }
    
    if (ok)
        printf("YES\n");
    else
        printf("NO\n");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int N;
int b[100];
#define rep(v,n) for(int v=0;v<n;v++)
#define REP(i, n) rep(i,n)

#define EXIST(c, a) c.find(a)!=c.end()

#define DIGIT(a, n) ((a>>n)%2)

typedef long long ll;

int main(){
	int n;
	scanf("%d", &n);
	REP(i, n){
		int x = 0;
		scanf("%x", &x);
		if(DIGIT(x, 31)) printf("-");
		int a = 0, b = 1;
		for(int i=7;i<31;i++){
			if(DIGIT(x, i)) a+=b;
			b*=2;
		}
		printf("%d.", a);
		a = 0; b = 10000000;
		for(int i=6;i>=0;i--){
			b/=2;
			if(DIGIT(x, i)) a+=b;
		}
		if(a==0){
			printf("0");
		}else{
			int k = a, l = 0;
			while(k%10==0 && k) k/=10, l++;
			b = 1000000;
			for(int i=7;i>l;i--){
				printf("%d", (a/b)%10);
				b/=10;
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 1196
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void){
  int n;
  scanf("%d",&n);
  int i,j,t;
  int s1=0,s2=0;
  int w[n];
  int min=1000000;
  int tmp;
  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
  }
  for(i=0;i<n;i++){

    s1=0;
    s2=0;
    for(j=0;j<i;j++){
      s1=s1+w[j];
    }
    for(j=i;j<n;j++){
      s2=s2+w[j];
    }
    if(s2>s1)
    tmp=s2-s1;
    else
    tmp=s1-s2;

    if(tmp<min)
    min=tmp;
  }
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 128
import "dart:io";

void main() {
    final n = int.parse(stdin.readLineSync());
    final List<String> color = stdin.readLineSync().split('');
    
    //条件1に該当する組み合わせ(R,G,Bの個数から求める)
    int r, g, b;
    r = g = b = 0;    
    for (int i = 0; i < n; i++) {
        switch (color[i]) {
            case "R":
                r++;
                break;
            case "G":
                g++;
                break;
            case "B":
                b++;
                break;
            default:
                break;
        }
    }
    
    //条件2に該当する組み合わせ(等間隔に並んだ文字を調べる)
    int ex = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; 2*j-i < n; j++) {
            if (color[i] != color[j] && color[j] != color[2*j-i] && color[2*j-i] != color[i]) {
                ex++;
            }
        }
    }
    print(r*g*b - ex);
}

Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
} 
int dfs(vector<int> &a,vector<int> &b,int k,int i,int j){
  if(k<a.at(i)&&k<b.at(j))
    return i+j;
  if(k>=a.at(i)&&k>=b.at(j))
    return max(dfs(a,b,k-a.at(i),i+1,j),dfs(a,b,k-b.at(j),i,j+1));
  if(k>=a.at(i)&&k<b.at(j))
    return dfs(a,b,k-a.at(i),i+1,j);
  return dfs(a,b,k-b.at(j),i,j+1);
}
int main(){
  vector<ll> a(10000000);
  rep(i,10000000){
    int j=i+1;
    while(10000000>=j){
      a.at(j-1)++;
      j+=(i+1);
    }
  }
  ll ans=0;
  int n;
  cin >> n;
  rep(i,n){
    ans+=(i+1)*a.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 81204