akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int serch(char str)
{
    if(str=='I')return 1;
    else if(str=='V')return 5;
    else if(str=='X')return 10;
    else if(str=='L')return 50;
    else if(str=='C')return 100;
    else if(str=='D')return 500;
    else return 1000;
}
int main()
{
    int fron=0,bac=0,sum=0;
    string str;
    while(cin>>str){
        for(int i=0;str[i]!='\0';i++){
            bac=serch(str[i]);
            if(fron>=bac)sum+=bac;
            else sum+=bac-fron*2;
            fron=bac;
            bac=0;
        }
        cout<<sum<<endl;
        sum=0;fron=0;
    }
}

Measured memory_bytes: 1180
#include <stdio.h>
int main(void){
	int n,a,b,c;
	scanf("%d",&n);
	c=n%10;
	b=(n/10)%10;
	a=(n/100)%10;
	if(c==7){
		printf("Yes\n");
	}else if(b==7){
		printf("Yes\n");
	}else if(a==7){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s;
vi a;

int main(){
	cin>>s;
	n=s.size();
	a=vi(n);
	for(int i=0;i<n-1;i++) if(s.substr(i,2)=="RL"){
		for(int j=i;j>=0&&s[j]=='R';j--) a[((i-j)%2==0?i:i+1)]++;
		for(int j=i+1;j<=n&&s[j]=='L';j++) a[((j-i)%2==0?i:i+1)]++;
	}
	for(int i=0;i<n;i++) cout<<a[i]<<" \n"[i==n-1];
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }
  return 0;
}

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

class Dice{
private:
  int tmp;
public:
  int q[6];
  void roll(char d){
    if(d=='N'){
      tmp = q[4];
      q[4] = q[0];
      q[0] = q[1];
      q[1] = q[5];
      q[5] = tmp;
    } else if(d=='E'){
      tmp = q[2];
      q[2] = q[0];
      q[0] = q[3];
      q[3] = q[5];
      q[5] = tmp;
    } else if(d=='W'){
      tmp = q[3];
      q[3] = q[0];
      q[0] = q[2];
      q[2] = q[5];
      q[5] = tmp;
    } else if(d=='S'){
      tmp = q[1];
      q[1] = q[0];
      q[0] = q[4];
      q[4] = q[5];
      q[5] = tmp;
    }
  }
};


int main(){
  Dice d;
  for(int i=0; i<6; i++){
    cin >> d.q[i];
  }
  char r;
  while(cin>>r){
    d.roll(r);
  }
  cout << d.q[0] << endl;
}


Measured memory_bytes: 3116
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
})
process.stdin.on('end', function() {
  main(input.split('\n'));
});

function main (input) {

  var max, n;
  var i;
  while ((max = input.shift() - 0) !== 0) {
    var d = [];
    n = input.shift() - 0;
    d[0] = 0;
    d[n + 1] = 0;
    for (i = 1; i <= n; i++) {
        d[i] = input.shift() - 0;
    }
    console.log(solve(max, n, d) ? 'OK' : 'NG');
  }
}

function makeGraph(n){
  var i, j, g;
  g = [];
  for (i = 0; i < n; i++) {
    g[i] = [];
    for (j = 0; j < n; j++) {
      g[i][j] = i === j ? 0 : Infinity;
    }
  }
  return g;
}

function warshall_floyd(d) {
  var i, j, k,n= d.length;
  for (k = 0; k < n; k++) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        d[i][j] = d[i][j] > d[i][k] + d[k][j] ? d[i][k] + d[k][j] : d[i][j];
      }
    }
  }
  return d;
}


function solve(max, n, d) {
    var g = makeGraph(n + 2);
    var i, j;
    var pos;
    for (i = 0; i <= n; i++) {
        for (j = 1; j <=max; j++) {
            pos = i + j + (i + j < n + 1 ? d[i + j] : 0);
            pos = Math.min(Math.max(pos, 0), n + 1);
            if(pos !== i) {
                g[i][pos] = 1;
            }
        }       
    }

    warshall_floyd(g);

    for (i = 0; i <= n; i++) {
      if(g[0][i] < Infinity && g[i][n+1] === Infinity) {
        return false;
      }
    }
    return true;
    
}

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

int main(){
    int N;
    cin >> N;
    
    double price  = 380000.0;
    double amount = 0.00000000;
    string currency;
    double ans = 0.00000000;
    
    for(int i = 0; i < N; i++){
        cin >> amount >> currency;
        ans += currency == "JPY" ? amount : amount * price;
    }
    
    cout << fixed;
    cout << setprecision(8) << ans << endl;    
    return 0;
}


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

#define int long long
int ans;
int a[2000];
signed main(){
  int n,m,c;
  cin >> n >> m >> c;
  
  for(int i = 1;i<=m;i++)cin >> a[i];
  
  for(int j = 1;j<=n;j++){
    int temp = 0;
    for(int i = 1;i<=m;i++){
    int b;
    cin >> b;
    temp+=b*a[i];
    }
    temp+=c;
    if(temp>0)ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
  int N, M;
  cin >> N >> M;

  UnionFind uf(N);

  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    uf.unite(u, v);
  }

  set<int> s;
  REP(i, N){
    s.insert(uf.root(i));
  }

  cout << s.size()-1 << "\n";

  return 0;
}


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

ll mod = 998244353;
ll modsize = 200010;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc(){
    if(modsize == 0) abort();
    fac[0] = 1; fac[1] = 1; inv[1] = 1;
    facinv[0] = 1; facinv[1] = 1;
    for(ll i = 2 ; i < modsize ; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        facinv[i] = facinv[i-1] * inv[i] % mod;
    }
}

ll modinv(ll a){
    if(a==0) abort();
    ll b = mod, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= mod;
    if(u<0) u += mod;
    return u;
}

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

ll modcomb(ll n, ll k){
    if(n<0||k<0||n<k) return 0;
    return fac[n] * facinv[k] % mod * facinv[n-k] % mod;
}

ll modperm(ll n, ll k){
    if(n<0||k<0||n<k) return 0;
    return fac[n] * facinv[n-k] % mod;
}

ll modhom(ll n, ll k){
    if(n<0||k<0||(n==0&&k>0)) return 0;
    if(n==0&&k==0) return 1;
    return fac[n+k-1] * facinv[k] % mod * facinv[n-1] % mod;
}



int main(){
    int n,m,k; cin>>n>>m>>k;
    modcalc();
    ll ans = 0;
    rep(i,k+1) ans += modcomb(n-1,i)*m%mod*modpow(m-1,n-1-i)%mod;
    cout << ans%mod << endl;
}

Measured memory_bytes: 7812
#include <atcoder/convolution>
#include <iostream>

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    using mint = atcoder::modint998244353;
    
    int n, m;
    std::cin >> n >> m;
    std::vector<mint> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        int x;
        std::cin >> x;
        a[i] = mint(x);
    }
    for (int i = 0; i < m; ++i) {
        int x;
        std::cin >> x;
        b[i] = mint(x);
    }
    
    std::vector<mint> ans = atcoder::convolution(a, b);
    
    for (mint x : ans) std::cout << x.val() << " ";
    std::cout << "\n";
}


Measured memory_bytes: 19076
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();

            int max = 0;
            for (int i = 0; i < N; i++) {
                for (int j = 1 + max; j * 2 - 1 < N - i; j++) {
                    int last = i + j;
                    String t = S.substring(i, last);
                    if (S.indexOf(t, last) >= 0) {
                        max = Math.max(max, t.length());
                    } else {
                        break;
                    }
                }
            }
            out.println(max);
        }

    }
}



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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		char	ball  = 'A';
		char[]	trade = null;

		while ((trade = parseTrade()) != null) {
			ball = (ball == trade[0]) ? trade[1] : (ball == trade[1]) ? trade[0] : ball;
		}

		System.out.println(ball);
	}

	private static char[] parseTrade() {
		String	strIn = null;
		char[]	table = null;

		if ((strIn = parseStdin()) != null) {
			String[]	line = strIn.split(",");

			table    = new char[2];
			table[0] = line[0].charAt(0);
			table[1] = line[1].charAt(0);
		}
		
		return table;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16912
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n;
    while(cin>>n,n){
        vi l(n);
        rep(i,n) {cin>>l[i]; }
        string s,st="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        cin>>s;
        int t=0;
        for(auto c:s){
            cout<<st[(st.find(c)-l[t]+52)%52];
            t=(t+1)%n;
        }
        cout<<endl;

    }
}

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

const int MOD = 1000000007;

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

int N;
vector<long long> H;

// first: all, second: oxoxoxoxox
pll rec(int left, int right) {
    long long resall = 0, resalt = 0;

    // height
    long long height = 1LL<<60;
    for (int i = left; i < right; ++i) if (H[i] < height) height = H[i];
    for (int i = left; i < right; ++i) H[i] -= height;
    vector<pll> subs;
    int nleft = left;
    int width = 0;
    for (int i = left; i < right; ++i) {
        if (H[i] == 0) {
            if (i > nleft) subs.push_back(rec(nleft, i));
            nleft = i+1;
            ++width;
        }
    }
    if (right > nleft) subs.push_back(rec(nleft, right));
    
    // second
    long long facalt = 1;
    for (auto p : subs) facalt *= p.second, facalt %= MOD;
    resalt += facalt * modpow(2LL, height, MOD) % MOD;
    resalt %= MOD;
    
    // first
    resall += resalt;
    long long fac = 1;
    for (auto p : subs) {
        fac *= (p.first + p.second); fac %= MOD;
    }
    resall += fac * modpow(2LL, width, MOD) % MOD;
    resall += MOD - facalt * 2 % MOD;
    resall %= MOD;
    
    // result
    return pll(resall, resalt);
}

int main() {
    cin >> N;
    H.resize(N); for (int i = 0; i < N; ++i) cin >> H[i];
    pll res = rec(0, N);
    cout << res.first << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = asakatsu0404e()

fun asakatsu0404e() {
    val (n, t) = readLine()!!.split(' ').map { it.toLong() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    var maxPriceDiff = 0L to 0
    var leftMin = Long.MAX_VALUE / 100

    for (a in aList) {
        val diff = a - leftMin
        if (diff > maxPriceDiff.first) {
            maxPriceDiff = diff to 1
        } else if (diff == maxPriceDiff.first) {
            maxPriceDiff = diff to (maxPriceDiff.second + 1)
        }
        leftMin = Math.min(leftMin, a)
    }

    val answer = maxPriceDiff.second

    println(answer)
}


Measured memory_bytes: 50064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  
  if(A*N < B){
    cout<<A*N<<endl;
  }
  
  if(A*N==B){
    cout<<B<<endl;
  }
  
  if(A*N>B){
    cout<<B<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAXN 21
#define QQQ 1000000007

int S[1<<MAXN];
int A[MAXN][MAXN];

const int BT[256] = {
    0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
};

int cntbit ( int bit )
{
  int n = 0;
  int tmp,i;

  for ( i = 0; i < 8; i++ ) {
    tmp = (bit&(15<<(4*i))) >> ( 4*i);
    n += BT[tmp];
  }

  return n;

}

int matching ( int x, int n )
{
  if (S[x] != -1 ) return S[x];

  int i,b,bitn;
  long tmp = 0;

  bitn = cntbit(x);
  for ( i = 0; i < n; i++ ) {
    if ( x & (1<<i) ) {
      b = ( x & (~(1<<i)));
      tmp += matching(b,n)*A[bitn-1][i];
    }
  }

  return S[x] = tmp%QQQ;
}

int main(void)
{
  int i,j,n;

  scanf("%d",&n);

  for ( i = 0; i < n; i++ ) {
    for (j = 0; j < n; j++ ) scanf("%d", &A[i][j]);
  }

  for ( i = 0; i < ( 1<< n ); i++ ) S[i] = -1;
  S[0] = 1;

  printf("%d\n",matching((1<<n)-1,n));

  return 0;
}


Measured memory_bytes: 8320
/**
*    author:  boutarou
*    created: 11.07.2020 21:02:52
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int>ans(n + 1);
    rep(i, n + 1) ans[i] = 0;
    for (int i = 1; i * i <= n; i++) {
        for (int j = 1; j * j <= n; j++) {
            for (int k = 1; k * k <= n; k++) {
                if (i * i + j * j + k * k + i * j + j * k + k * i <= n) {
                    ans[i * i + j * j + k * k + i * j + j * k + k * i]++;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#ifdef LOCAL111
#else
	// #define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

const string chs = ".#";

int main()
{
	// ios_init();
	int n;
	cin >> n;
	string s1, s2;
	bool f = false;
	bool di = true;
	while(SZ(s1) < n){
		[&](){
			REP(i,2) REP(j,2){
				string ns1, ns2;
				if(di){
					ns1 = s1+chs[i];
					ns2 = s2+chs[j]; 
				}else{
					ns1 = chs.substr(i,1)+s1;
					ns2 = chs.substr(j,1)+s2;
				}
				cout << ns1 << endl << ns2 << endl;
				string r;
				cin >> r;
				if(r == "T"){
					s1 = ns1;
					s2 = ns2;
					return;
				}else if(r == "end"){
					f = true;
					return;
				}
			}
			di = false;
		}();
		if(f) return 0;
	}
	return 0;
}


Measured memory_bytes: 596
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        Console.WriteLine(input<1000?"ABC":"ABD");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def dfs(u=0,pu=-1,color=0):
        cc[u]=color
        cntc[color]+=1
        for cu in to1[u]:
            if pu==cu:continue
            dfs(cu,u,1-color)


    n=II()
    to1=[set() for _ in range(n)]
    cc=[0]*n
    cntc=[0]*2
    for _ in range(n-1):
        a,b=MI1()
        to1[a].add(b)
        to1[b].add(a)
    dfs()
    #print(cc)
    #print(cntc)
    m1=(n-1)//3+1
    m2=(n-2)//3+1
    m3=n//3
    #print(m1,m2,m3)
    if cntc[0]<cntc[1]:mnc=0
    else:mnc=1
    p1=list(range(1,n+1,3))
    p2=list(range(2,n+1,3))
    p3=list(range(3,n+1,3))
    ans=[-1]*n
    if cntc[mnc]<=m3:
        #mncの色に3の倍数、あと自由
        for u in range(n):
            if cc[u]==mnc:ans[u]=p3.pop()
            else:
                if p1:ans[u]=p1.pop()
                elif p2:ans[u]=p2.pop()
                else:ans[u]=p3.pop()
    elif cntc[1-mnc]>m1+m3:
        print(-1)
        exit()
    else:
        #多い方にm1、少ない方にm2を振って、残りをm3で埋める
        for u in range(n):
            if cc[u]==mnc:
                if p2:ans[u]=p2.pop()
                else:ans[u]=p3.pop()
            else:
                if p1:ans[u]=p1.pop()
                else:ans[u]=p3.pop()
    print(*ans)

main()

Measured memory_bytes: 217668
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var A = ReadArrayLong();
            var can = false;
            if (A.Contains(K)) can = true;
            else if (A.Max() < K) can = false;
            else
            {
                var g = A[0];
                for (int i = 1; i < N; i++) g = Gcd(g, A[i]);
                if (K % g == 0) can = true;
            }

            Console.WriteLine(can ? "POSSIBLE" : "IMPOSSIBLE");
            Console.ReadLine();
        }

        static long Gcd(long a, long b) { if (b == 0) return a; return Gcd(b, a % b); }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 29792
#include<iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n ;
  
  if(n<1200){
    cout << "ABC" << endl ;
  }else if(n>=1200 && n<2800){
        cout << "ARC" << endl ;
  }else if(n>=2800){
        cout << "AGC" << endl ;
  }
  
   return 0;
}


Measured memory_bytes: 256
n,x =map(int,input().split())
l1=list(map(int,input().split()))
l2=[0]
for i in range(n):
  l2.append(l2[i]+l1[i])
ans=0
i=0
while i<len(l2):
  if l2[i]<=x:
    ans+=1
  i+=1
print(ans)

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

const int mxn = 3001;
const int M = 1e9 + 7;

int n;
double ans;

//void rec(vector<double> p, int i, int heads, double prob) {
	//cerr << i << " " << heads << " " << " " << prob << "\n";
	//if(i >= n) {
		//if(heads > (n - heads)) {
			//ans += prob;
		//}
		//return;
	//}

	//rec(p, i+1, heads + 1, prob * p[i]);
	//rec(p, i+1, heads, prob * (1 - p[i]));
//}

int main() {
	ans = 0.0;
	cin >> n;
	vector<double> p(n);
	
	for(int i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<vector<double>> dp(n+1, vector<double> (n+1));
	dp[0][0] = 1.0;
	
	for(int i = 1; i <= n; i++) {
		for(int heads = 0; heads <= i; heads++) {
			if(heads == 0) {
				dp[i][heads] = dp[i-1][heads] * (1 - p[i-1]);
			}
			else dp[i][heads] = dp[i-1][heads] * (1 - p[i-1]) + dp[i-1][heads-1] * p[i-1];
		}
	}
	
	for(int i = 1; i <= n; i++) {
		if( i > (n-i)) {
			ans += dp[n][i];
		}
	}
	cout << setprecision(10);
	cout << ans << "\n";
}


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

int main(){
        int n;
        int s[117];
        int chk;
        while(1){
                scanf("%d",&n);
                if(!n)
                        break;
                for(int i=0;i<n;i++){
                        scanf("%d",&s[i]);
                }
                sort(s,s+n);
            chk=0;
                for(int j=1;j<n-1;j++)
                        chk+=s[j];
                printf("%d\n",chk/(n-2));
        }
        return 0;
}

Measured memory_bytes: 1188
fun main(array: Array<String>) {
    val (a, b, m) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toInt() }
    val bList = readLine()!!.split(" ").map { it.toInt() }
    var min = aList.min()!! + bList.min()!!
    repeat(m) {
        var temp = readLine()!!.split(" ").map { it.toInt() }
        var tempMin = aList[temp[0]-1] + bList[temp[1]-1] - temp[2]
        min = if(tempMin <= min) {
            tempMin
        }
        else {
            min
        }
    }
    print(min)
}

Measured memory_bytes: 102696
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int main() {
  int n,m;
  std::cin >> n >> m;
  std::vector<std::vector<int> > switches(m,std::vector<int>());
  std::vector<int> p(m);
  rep(i,m) {
    int k;
    std::cin >> k;
    rep(j,k) {
      int s;
      std::cin >> s;
      switches[i].emplace_back(s);
    }
  }
  rep(i,m) {
    std::cin >> p[i];
  }
  int count = 0;
  rep(i,1<<(n)) {
    int all = true;
    rep(j,m) {
      int oncount = 0;
      for(auto k:switches[j]) {
        if(i&(1<<(k-1))) oncount++;
      }
      if(oncount%2!=p[j]) {
        all = false;
        break;
      }
    }
    if (all) count++;
  }
  std::cout << count << std::endl;

  return 0;
}

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

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

  int max_num = -1;
  int total = 0;
  for (int i = 0; i < N; ++i) {
    int l;
    cin >> l;
    if (l > max_num) {
      max_num = l;
    }
    total += l;
  }

  if (max_num < total - max_num) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)

a, b, c = list(map(int, input().split(" ")))
k = int(input())

ans = []

for i in range(0, k+1, 1):
    for j in range(0, k-i+1, 1):
        ans.append(a*(2**i) + b*(2**j) + c*(2**(k-i-j)))

print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

struct pp {
    string name;
    int time;

    pp(string _name="", int _time=0) : name(_name), time(_time) {}
};

const int LEN = 101010;

pp q[LEN];
int head, tail;

void enqueue(pp x) {
    q[tail] = x;
    tail = (tail+1) % LEN;
}

pp dequeue() {
    pp x = q[head];
    head = (head+1) % LEN;
    return x;
}

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

    ll n, k; cin >> n >> k;
    if(n >= k) {
        n -= k * (n/k);
    }

    cout << min(n, k-n) << endl;
    
}


Measured memory_bytes: 7540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans = min(a,k);
  if(a>=k) {cout << ans << endl; return 0;}
  k-=a;
  if(b>=k){cout << ans << endl; return 0;}
  k-=b;
  ans-=k;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3624
import math

s = list(input())
k =int(input())
cnt1 = 0
cnt2 = 0
ans = 0
i = 0
j = len(s)-1
p = False
n = 0
if len(s) == 1:
  answer = math.floor(k/2)
else:
  while s[0] == s[n]:
    n += 1
    if n == len(s)-1:
      p = True
      break
  if p == True:
    answer = math.floor(len(s)*k/2)
  if p == False:
    t = False
    while s[0] == s[i]:
      i+= 1
    cnt1 = i 
    while s[-1] == s[j]:
      j = j-1
    cnt2 = len(s)-j-1
    if s[0] == s[-1]:
      t = True
    new_s = s[cnt1:len(s)-cnt2]
    for i in range(len(new_s)-1):
        if new_s[i] == new_s[i+1]:
          new_s[i+1] = "0"
          ans += 1
    if t == True:
      ans_2 = math.floor((cnt1+cnt2)/2)
      answer = ans*k + ans_2*(k-1) + math.floor(cnt1/2) + math.floor(cnt2/2)
    if t == False:
      answer = ans*k + math.floor(cnt1/2)*k + math.floor(cnt2/2)*k
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[101][100010];

int main(){
  int n,W;
  cin>>n>>W;
  ll w[n+1]={},v[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>w[i]>>v[i];
  }

  for(int i=1;i<=n;i++){
    for(int j=0;j<=W;j++){
      if(j+w[i]<=W) dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i-1][j]+v[i]);
      dp[i][j]=max(dp[i][j],dp[i-1][j]);
    }
  }

  ll ans=0;
  for(int i=0;i<=W;i++){
    ans=max(ans,dp[n][i]);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 78336
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

float distance(vector <int> y,vector <int> z)
{ 
    float ans = 0;
    for(int i = 0;i < y.size(); i++)
    {   
        ans += (y[i] - z[i])*(y[i] - z[i]);
    }
    ans = sqrt(ans);
    return ans;   
}

int main() {
    int N, D;
    cin >> N >> D;
    vector <vector <int>> X(N, vector<int>(D, 0));
    for(int i = 0;i < N; i++)
    {
        for(int j = 0;j < D; j++)
        {
            cin >> X[i][j];
        }
    }
    int count = 0;

    for(int i = 0; i < N ; i++)
    {
        for(int j = i + 1;j < N;j++)
        {
            float dist = distance(X[i], X[j]);
            if((dist - (int) dist) == 0 ) count++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF (1<<21)
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define Rrep(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=a;i<n;i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)

int main() {

	int N, Q;
	cin >> N >> Q;
	string str;
	cin >> str;

	vector<int>s(N + 1, 0);

	for (int i = 0; i < N; i++) {
		if (i + 1 < N && str[i] == 'A' && str[i + 1] == 'C') s[i + 1] = s[i] + 1;//str[N]は存在しない
		else s[i + 1] = s[i];
	}

	rep(i, Q) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		cout << s[r] - s[l] << endl;
	}

	return 0;

}

Measured memory_bytes: 1408
#include "bits/stdc++.h"                                          
using namespace std;

int main() {
        int a, b;
        cin >> a >> b;
        if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
        else cout << "Impossible" << endl;
        return 0;
}



Measured memory_bytes: 256
def _main(N, K, prices):
    prices.sort()
    print(sum(prices[0:K]))


def _entry():
    N, K = map(int, input().split())
    pricecs = list(map(int, input().split()))
    _main(N, K, pricecs)


if __name__ == "__main__":
    _entry()


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<char, int>> m;
    char p = s[0];
    int idx = 0;
    while (1) {
        int cnt = 0;
        while (s[idx]==p&&idx<n) {
            ++cnt;
            ++idx;
        }
        m.pb({p, cnt});
        if (idx>=n) break;
        p = s[idx];
    }
    int n2 = m.size();
    int ans = 0, cnt = 0, op = 0;
    int i = 0, j = 0;
    while (j < n2) {
        if (m[j].first=='1') {
            cnt += m[j].second;
            ++j;
            ans = max(ans, cnt);
        }
        else {
            if (op < k) {
                cnt += m[j].second;
                ++j;
                ++op;
                ans = max(ans, cnt);
            }
            else {
                if (m[i].first=='1') {
                    cnt -= m[i].second;
                    ++i;
                }
                else {
                    cnt -= m[i].second;
                    ++i;
                    --op;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;

#define fi first
#define se second

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

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

const int MAXN = 105, MAXK = 1e5 + 5;
int dp[MAXK], a[MAXN];
int N, K;

int rec(int k) {
	if (dp[k] != -1) return dp[k];
	dp[k] = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] > k) break;
		dp[k] |= (rec(k - a[i]) == 0);
	}
	return dp[k];
}

int main() {
	ios_base::sync_with_stdio(0);

	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> a[i];
	memset(dp, -1, sizeof(dp));
	if (rec(K)) cout << "First";
	else cout << "Second";

	return 0;
}

Measured memory_bytes: 8664
/*	Success may not come to me immediately,
 *	but it will come definitely....
 */
#include<bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li	int64_t
#define ld	double_t
#define ulli	uint64_t
//=====================================================================
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define repi(i,v)	for(i=v.begin();i!=v.end();i++)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
#define nl		cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>	 vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb	push_back
#define pob	pop_back
#define pf	push_front
#define pof	pop_front
#define all(v)	v.begin(),v.end()
#define itr	iterator
#define sz	size()
#define lb	lower_bound
#define ub	upper_bound
#define bs	binary_search
#define mp	make_pair
#define F	first
#define S	second
//=====================================================================
#define mod	1000000007
#define inf	1000000000000000005
#define MX1	100005
#define MX2	1000005
#define pi	acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return 1<<n;}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
    li i,n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<"0";
        return;
    }
    if(n==1){
        if(a==b){
            cout<<"1";
            return ;
        }
        cout<<"0";
        return;
    }
    li maxx=(n-1)*b+a;
    li minn=(n-1)*a+b;
    cout<<maxx-minn+1;
}

int main(){
    opt
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    li t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <iterator>
#include <bitset>
using namespace std;

#define CORD_SIZE 1010
#define SIZE 20

typedef struct _Node
{
    int x, y;
} Node;

Node arr[SIZE];

bool cntState[SIZE];

map<long long int, int> mp;

long long int ans;
int num;

long long int getId(int ka, int kb, int ksgn)
{
    return (1ll * ka * CORD_SIZE + kb) * ksgn;
}

void dfs(int cntNum)
{
    if (cntNum == num)
    {
        long long int cntAns = 0;
        for (map<long long int, int>::iterator it = mp.begin(); it != mp.end(); ++it)
        {
            cntAns += (1ll * (it -> second) * (it -> second - 1)) >> 1;
        }
        ans = max(ans, cntAns);
        return;
    }


    int i = 0;
    while (cntState[i])
        i++;

    for (int j = i + 1; j < num; j++)
    {
        if (cntState[j])
            continue;

        int cntKa = arr[i].y - arr[j].y;
        int cntKb = arr[i].x - arr[j].x;
        int cntKsgn = 1;

        if ((cntKa > 0) != (cntKb > 0))
            cntKsgn = -1;

        cntKa = abs(cntKa);
        cntKb = abs(cntKb);

        if (cntKb == 0)
        {
            cntKsgn = 1;
            cntKa = 1;
        }
        else if (cntKa == 0)
        {
            cntKsgn = 1;
            cntKb = 0;
        }

        if (cntKa != 0 && cntKb != 0)
        {
            int gcd = __gcd(cntKa, cntKb);
            cntKa /= gcd;
            cntKb /= gcd;
        }

        long long int id = getId(cntKa, cntKb, cntKsgn);
        mp[id]++;
        cntState[i] = true;
        cntState[j] = true;
        dfs(cntNum + 2);
        mp[id]--;
        cntState[i] = false;
        cntState[j] = false;
    }
}

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

    while (cin >> num)
    {
        memset(cntState, false, sizeof(cntState));
        mp.clear();
        for (int i = 0; i < num; i++)
        {
            cin >> arr[i].x >> arr[i].y;
        }

        ans = 0;
        dfs(0);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3164
function main(input) {
  input=input.trim();
  const a = parseInt(input.split("\n")[0], 10);
  const b = parseInt(input.split("\n")[1], 10);
  const c = parseInt(input.split("\n")[2], 10);
  console.log((a+b)*c*0.5);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
    cout<< fixed << setprecision(6);
    while(1){
        int n;
        cin>>n;
        if(n==0) break;
        double sum=0;
        vector<int> point(n);
        rep(i,n){
            
            cin>>point[i];
            sum+=point[i];
            
        }
        double ave=sum/n;
        sum=0;
        rep(i,n){
            sum+=(point[i]-ave)*(point[i]-ave);
        }
        sum/=n;
        cout<<sqrt(sum)<<endl;
    }
    
}


Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int main(){
	int N,M,X;
	std::cin >>N;
    std::vector<std::pair<int,int>> a(N);
    for(int i=0;i<N;i++){
        std::cin >> a[i].first >> a[i].second;
    }
    std::sort(a.begin(),a.end());
    
    std::cout << a[N-1].first+a[N-1].second << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N, M, X;
vector<int> vec;

//解法
void solve() {

	int front=0, back=0;
	rep(i, M) {
		if (vec[i] < X) {
			front += 1;
		}
		else {
			back += 1;
		}
	}
	cout << min(front, back);

	return;
}

int main() {
	//入力
	cin >> N >> M >> X;
	vec.resize(M);
	rep(i, M) cin >> vec[i];
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
  a=int(input())
  A.append(a)
res=sorted(A)

def binary_search(x):
  l=0
  r=N-1

  while True:
    mid=(l+r)//2
    if res[mid]==x:
      return mid
    elif res[mid]>x:
      r=mid-1
    elif res[mid]<x:
      l=mid+1

ans=0
for j,k in enumerate(A):
  cnt=binary_search(k)
  if abs(j-cnt)%2==1:
    ans+=1

print(ans//2)

Measured memory_bytes: 8284
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
using namespace std;
typedef vector <int> ivector;

int main(void){
	int a, b, i=0;
	string s;
	ivector buf(100);
	char *ends;

	while (cin >> s){
		if (s == "+"){
			b = buf[--i];
			a = buf[--i]; 
			buf[i++] = a + b;
		}else if (s == "-"){
			b = buf[--i];
			a = buf[--i]; 
			buf[i++] = a - b;
		}else if (s == "*"){
			b = buf[--i];
			a = buf[--i]; 
			buf[i++] = a * b;
		}else{
			buf[i++] = strtol(s.c_str(),&ends,0);
		}
	}
	cout << buf[i-1]  << endl;
	return 0;
}

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

int main()
{
    double n,a[100][100],z,b,c; int i,j,x=0,y=1;
    cin>>n;
    for(i=0; i<n; i++)
    {
        for(j=0; j<2; j++)
            cin>>a[i][j];
    }
    z=0;
    for(i=0; i<n-1; i++)
    {
        for(j=i+1;j<n;j++)
        {
            b=a[i][x]-a[j][x];
            b=b*b;
            c=a[i][y]-a[j][y];
            c=c*c;
            z+=sqrt(b+c);
        }
    }
    z=(z/n)*2;
    printf("%.8f\n",z);
    return 0;
}


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

using namespace std;

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

int main() {
  int N;
  long long W;
  cin >> N >> W;
  vector<long long> w(N);
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }

  const long long INF = 1e18;
  vector<vector<long long>> dp(N + 1, vector<long long>(101010, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 101010; j++) {
      if (0 <= j - v[i]) {
        chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
      }
      chmin(dp[i + 1][j], dp[i][j]);
    }
  }

  int ans;
  for (int i = 0; i < 101010; i++) {
    if (dp[N][i] <= W) ans = i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 81024
import java.util.Scanner;
 class Main{
  public static void main(String args[]){
  Scanner scan = new Scanner(System.in);
   int a = scan.nextInt(); 
   int b = scan.nextInt();
   
   int d=a/b;
   int r=a%b;
   double f=(double)a/b; 

   System.out.println(d+" "+r+" "+String.format("%.5f",f));

                                     }
            }


Measured memory_bytes: 26232