akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

// dp[i] = True if winner is taro and i stone remaining.


void solve(){
    int n, k;
    cin >> n >> k;
    vi stones(n);
    rep(i, n){
        cin >> stones[i];
    }
    
    vector<bool> dp(k + 1, false);
    

    rep(st, k + 1){
        for(auto x : stones){
            if(st >= x && !dp[st - x]){
                dp[st] = true;
            }
        }
    }

    cout << (dp[k] ? "First" : "Second") << endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


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

int main(){
  
  int n,k;
  cin >>n>>k;
  int x[n+1];

  for(int i=1;i<=n;i++){
    cin >>x[i];
  }
  long long ans=LLONG_MAX;
  for(int r=k;r<=n;r++){
      int l=r-k+1;
  //   for(int i=l;i<=r;i++){
  //     cout <<x[i];
  //   }
  //  cout <<endl;
    long long temp,temp2;
    if(x[l]>=0){
        temp=x[r];
    }else if(x[r]<=0){
        temp=-x[l];
    }else if(x[l]<0 && x[r]>0){
      //左→→右
        temp=x[l]*(-2)+x[r];
      // 右→→左
        temp2=-x[l]+x[r]*2;
        if(temp>temp2)temp=temp2;
    }
    if(ans>temp)ans=temp;
 }
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
long long n;
int main() {
	scanf("%lld", &n);
	long long t = 1, nn = n, s = 0;
	while (nn/10) {
		nn /= 10;
		t *= 10;
		s += 9;
	}
	if ((nn + 1)*t - 1 <= n) {
		s += nn;
	}
	else s += (nn - 1);
	printf("%lld\n", s);
}

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

bool canMove(int interval, int xLen, int yLen) {
    if (interval == 0) {
        return xLen + yLen == 0;
    }
    if (interval == xLen + yLen) {
        return true;
    }
    if (interval < xLen + yLen) {
        return false;
    }
    if (interval % 2) {
        if (xLen + yLen == 1) {
            return true;
        }
        if ((xLen + yLen) % 2 == 0) {
            return false;
        }
    } else {
        if (xLen + yLen == 0) {
            return true;
        }
        if ((xLen + yLen) % 2) {
            return false;
        }
    }
    if (xLen > 0) {
        if (canMove(interval - xLen, 0, yLen)) {
            return true;
        }
    }
    if (yLen > 0) {
        if (canMove(interval - yLen, xLen, 0)) {
            return true;
        }
    }
    return false;
}

int main() {
    int n;
    std::cin >> n;
    int t0 = 0;
    int x0 = 0;
    int y0 = 0;
    bool failed = false;
    for (int i = 0; i < n; ++i) {
        int t1, x1, y1;
        std::cin >> t1 >> x1 >> y1;
        if (failed) {
            continue;
        }
        if (!canMove(t1 - t0, abs(x1 - x0), abs(y1 - y0))) {
            failed = true;
            continue;
        }
        t0 = t1;
        x0 = x1;
        y0 = y1;
    }

    if (failed) {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc056.contest.atcoder.jp/tasks/arc070_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		sc.close();
		
		long current = 0;
		long ans = 0;
		while(current<X){
			ans++;
			current += ans;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
void dfs(vector<ll>&v,ll src,map<ll,vector<ll>>&adjlist,ll cnt){
    v[src]=cnt;
    for(auto i:adjlist[src]){
        if(v[i]==-1){
            dfs(v,i,adjlist,cnt);
        }
    }
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<ll>v(n+1,-1);
    map<ll,vector<ll>>adjlist;
    ll cnt=1;
    for(ll i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        adjlist[x].push_back(y);
        adjlist[y].push_back(x);
    }
    for(ll i=1;i<=n;i++){
        if(v[i]==-1){
            dfs(v,i,adjlist,cnt);
            cnt++;
        }
    }
    map<ll,ll>sz;
    for(ll i=1;i<=n;i++){
        if(v[i]!=-1)sz[v[i]]++;
    }
    ll ans=0;
    for(auto i:sz)ans=max(i.second,ans);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 45408
#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int,int>Mp;
  for(int i = 0; i < 6; i++) {
      int a;cin >> a;
      Mp[a]++;
  }
  int X = 0,Y = 0;
  for(pair<int,int> x:Mp) {
      if(x.second == 1) {
          X++;
      }
      else {
          Y++;
      }
  }
  if(X == 2 && Y == 2) {
      cout <<"YES"<< endl;
  }
  else {
      cout << "NO" << endl;
  }
}

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

int w, h, x, y;

int main(){
  cin >> w >> h >> x >> y;
  int res = 0;
  if(w == x * 2 && h == y * 2){
    res = 1;
  }
  cout << setprecision(10) << (double)w * (double)h / 2 << " " << res << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    internal static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());

        if (N % 2 == 0) {
            WriteLine(N);
            return;
        }

        WriteLine(N * 2);
    } 
}

Measured memory_bytes: 13140
#include<stdio.h>

long total = 0;

void FizzBuzz(const int m) {
    if(m % 3 != 0) {
        if(m % 5 != 0) total += m;
    }
}

int main(void) {
    int i, m;

    scanf("%d", &m);
    for(i = 1;i <= m;i++) FizzBuzz(i);

    printf("%ld\n", total);

    return 0;
}


Measured memory_bytes: 1736
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line;
			ArrayList<String> text = new ArrayList<String>();
			ArrayList<Character> commands = new ArrayList<Character>();
			String buffer = null;
			int l=0, c=0;
			/* input */
			while(true){
				line = br.readLine();
				if(line.equals("END_OF_TEXT")) break;
				text.add(line);
			}
			while(true){
				line = br.readLine();
				if(line.equals("-")) break;
				commands.add(line.charAt(0));
			}
			/* processing */
			for(char cm : commands){
				switch(cm){
				case 'a':
					c = 0;
					break;
				case 'e':
					c = text.get(l).length();
					break;
				case 'p':
					if(l>0){
						l--;
					}
					c = 0;
					break;
				case 'n':
					if(l<text.size()-1){
						l++;
					}
					c = 0;
					break;
				case 'f':
					if(c==text.get(l).length()){
						if(l<text.size()-1){
							l++;
							c = 0;
						}
					} else {
						c++;
					}
					break;
				case 'b':
					if(c==0){
						if(l>0){
							l--;
							c = text.get(l).length();
						}
					} else {
						c--;
					}
					break;
				case 'd':
					if(c<text.get(l).length()){
						text.set(l, text.get(l).substring(0,c) + text.get(l).substring(c+1,text.get(l).length()));
					} else if(l<text.size()-1){
						text.set(l, text.get(l).substring(0,c) + text.get(l+1));
						text.remove(l+1);
					}
					break;
				case 'k':
					if(c==text.get(l).length()){
						if(l<text.size()-1){
							text.set(l, text.get(l).substring(0,c) + text.get(l+1));
							text.remove(l+1);
							buffer = "\n";
						}
					} else {
						buffer = text.get(l).substring(c);
						text.set(l, text.get(l).substring(0,c));
					}
					break;
				case 'y':
					if(buffer==null){
						break;
					} else if(buffer.equals("\n")){
						text.add(l+1,text.get(l).substring(c));
						text.set(l, text.get(l).substring(0,c));
						l++;
						c = 0;
					} else {
						text.set(l, text.get(l).substring(0,c) + buffer + text.get(l).substring(c));
						c += buffer.length();
					}
					break;
				}
			}
			/* output */
			for(String s : text){
				System.out.println(s);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16932
#!/usr/bin/perl

use strict;
use warnings;

my ($h, $n);
{
    my $in = <STDIN>;
    ($h, $n) = split(" ", $in);
}
my @a;
{
    my $in = <STDIN>;
    @a = split(" ", $in);
}
my $sum = sub
{
    my $x = 0;
    $x += $_ for @a;
    return $x;
};

print "Yes\n" if $h <= $sum->();
print "No\n" unless $h <= $sum->();

Measured memory_bytes: 16932
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
    int r;cin>>r;
    int d;cin>>d;
    int x;cin>>x;

    for(int i = 0;i<10;i++){
        cout<<r*x-d<<endl;
        x= r*x-d;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	sort(all(in));
	int mi=inf;
	rep(i,n)loop(j,max(0,i-3),min(n,i+3))if(i!=j)
		mi=min(mi,(in[i].first-in[j].first)*(in[i].first-in[j].first)+
			(in[i].second-in[j].second)*(in[i].second-in[j].second));
	cout<<mi<<endl;
}

Measured memory_bytes: 4896
// C++ (GCC 9.2.1)
// 解き直し.
// https://img.atcoder.jp/abc167/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 998244353;
const int LIMIT = 202020;
LL FAC[LIMIT], INV[LIMIT], C[LIMIT];

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL mPow(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 組み合わせ(nCk)計算用(mod版).
// ※配列FAC, INV は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果(mod版).
LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0LL;
    // k = 0 で, 256423756 (※挙動がおかしい) が 出力されたため, ロジック修正.
    if(n == k || k == 0LL) return 1LL;
    LL ret = FAC[n] * INV[k] % MOD * INV[n - k] % MOD;
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int N;
    LL M, K;
    scanf("%d %lld %lld", &N, &M, &K);
    FAC[0] = 1;
    repx(i, 1, LIMIT) FAC[i] = (LL)i * FAC[i - 1] % MOD;
    rep(i, LIMIT)     INV[i] = mPow(FAC[i], MOD - 2);
    
    // ※ 解説通り.
    // 2. (M - 1) の べき乗 を 用意.
    C[0] = 1;
    rep(i, LIMIT) C[i + 1] = C[i] * (M - 1) % MOD;
    
    // 3. 公式を適用.
    LL ans = 0;
    rep(k, (int)K + 1){
        LL t = M;
        t *= combination((LL)(N - 1), (LL)k);
        t %= MOD;
        t *= C[N - 1 - k];
        t %= MOD;
        ans += t;
        ans %= MOD;
    }
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 8560
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


namespace atPra
{
    class Class1
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            int nn = N;
            int dig ;
            int sum = 0;
            while(nn>0){
                dig = nn % 10;
                sum = sum + dig;
                nn = nn / 10;
            }
            if (N % sum == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
 
#define int ll
 
typedef int64_t ll;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,0,1,-1}, dy4[4] = {1,-1,0,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) signed((a).size())
#define LEN(a) signed((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end());reverse((c).begin(),(c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")
 

int power(int x, int n){
    int tmp = 1;
  
    if(n>0){
      tmp = power(x, n/2);
      if(n%2==0) tmp = (tmp*tmp)%MOD;
      else tmp = (((tmp*tmp)%MOD)*x)%MOD;
    }
    return tmp;
}

signed main(){
    int N;
    vector<int> a;
    cin >> N;
    REP(i,N) {
        int tmp;
        cin >> tmp;
        a.PB(tmp);
    }
    SORT(a);

    bool rullonz = true;
    if(N%2){
        rullonz &= a[0]==0;
        REP1(i,N-1){
            rullonz &= a[i]==(i%2?i+1:i);
        }
    } else REP(i,N){
        rullonz &= a[i]==(i%2?i:i+1);
    }

    if(rullonz) printf("%lld\n",int(power(2,N/2))%MOD);
    else puts("0");
}


Measured memory_bytes: 1400
#include<stdio.h>

int main(void)
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    while( (1>n||n>20) || (1>a||a>100) || (1>b||b>2000) )
    {
        scanf("%d%d%d",&n,&a,&b);
    }
    if(n*a<=b)
    {
        printf("%d\n",n*a);
    }
    else
    {
        printf("%d\n",b);
    }
    return 0;
}

Measured memory_bytes: 128
use proconio::input;

#[proconio::fastout]
pub fn main() {
    input! {
    n:usize,
    a:[usize;n-1],
    }
    let mut ans = vec![0; n+1];
    for b in a {
        ans[b] += 1;
    }
    for i in 1..=n {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 5528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int n,t,a; 

double TMP(int h) {
	return t - 0.006 * h;
}

int main() {
	cin >> n >> t >> a;
	double ans_num = 1e9;
	int ANS=0;

	for (int i = 0; i < n; ++i)
	{
		int h; cin >> h;
		if (ans_num > abs(TMP(h) - a))
		{
			ans_num = abs(TMP(h) - a);
			ANS = i + 1;
		}
	}

	cout << ANS << endl;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
flag = False
x = len(set(A))
if x == 1 and A[0] == 0:
  flag = True
elif x == 2 and A.count(0) == N // 3:
  flag = True
elif x == 3:
  X = A[0]
  Y = -1
  Z = -1
  i = 1
  while i < N:
    if A[i] != X:
      Y = A[i]
      break
    i += 1
  while i < N:
    if A[i] != X and A[i] != Y:
      Z = A[i]
    i += 1
  if X ^ Y ^ Z == 0 and A.count(X)  == N // 3 and A.count(Y)  == N // 3:
    flag = True
print("Yes" if flag else "No")

Measured memory_bytes: 14704
#include <iostream>

using namespace std;
#define MAX 100001
#define NIL -1
struct Node{
    int p,l,r;
};
struct Node T[MAX];
int D[MAX];
void rec(int u,int p){
    D[u] = p;
    if(T[u].r!=NIL) rec(T[u].r,p);
    if(T[u].l!=NIL) rec(T[u].l,p+1);
}
void print(int u){
    cout<<"node "<<u<<": parent = "<<T[u].p<<", depth = "<<D[u]<<", ";

    if(T[u].p == NIL){
        cout<<"root, ";
    }
    else if(T[u].l==NIL){
        cout<<"leaf, ";
    }
    else{
        cout<<"internal node, ";
    }
    cout<<"[";
    for(int i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
            if(i) cout<<", ";
            cout<<c;
    }
    cout<<"]"<<endl;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        T[i].p=T[i].l=T[i].r=NIL;
    }
    int id,k;
    for(int i=0;i<n;i++){
        cin>>id>>k;
        for(int j=0;j<k;j++){
            int c;
            int l;
            cin>>c;
            if(j==0){
                T[id].l = c;
            }else{
                T[l].r = c;
            }
            l=c;
            T[c].p = id;
        }
    }
    int r;
    for(int i=0;i<n;i++){
        if(T[i].p==NIL) r=i;
    }
    rec(r,0);
    for(int i=0;i<n;i++){
        print(i);
    }

    return 0;
}



Measured memory_bytes: 7728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  string s,t;
  cin >> s;
  cin >> t;
  int ans= 0;
  int len = s.length();
  for(int i =0; i < len; i++){
    if(s[i]!= t[i]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3836
import java.util.*;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 1段目の宝石数
		int n = sc.nextInt();

      	int min = 0;
      	BigDecimal max = new BigDecimal(0);
      	boolean isFirst = true;
      	int minusNum = 0;
		// 2段目の数値
		for (int i=0; i < n; i++) {
          	int  num = sc.nextInt();
			if (num < 0) {
              minusNum++;
            }
          	int tmp = Math.abs(num);
          	if (isFirst || tmp<min) {
              min = tmp;
              isFirst = false;
            }
          	max = max.add(new BigDecimal(tmp)); 

        }
      	
      	if(minusNum % 2 != 0){
          max = max.add(new BigDecimal(min).multiply(new BigDecimal(-2)));
        }

		System.out.println(max.toString());      

 	}
 
}

Measured memory_bytes: 48460
#include <stdio.h>
#define FOR(variable,a,b) for(variable=(a);variable<(b);variable++)

void swap(int* a, int* b) {
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
    return;
}

int main(){
    // import phase
    int i;
    int size, count;
    int map[30];
    int a, b;

    // calclate phase
    scanf("%d", &size);
    scanf("%d", &count);
    
    FOR(i, 0, size) {
        map[i] = i+1;
    }
    FOR(i, 0, count) {
        scanf("%d,%d", &a, &b);
        swap(&map[a-1], &map[b-1]);
    }

    // output phase
    FOR(i, 0, size) {
        printf("%d\n", map[i]);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans = 1;
    for(int i = 1; i < s.size() / 2; i++){
        bool flag = true;
        for(int j = 0; j < i; j++){
            if(s.at(j) != s.at(j + i))
                flag = false;
        }
        if(flag) ans = i;
    }
    cout << ans * 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    string s;
    cin >> n >> s;

    int x = 0;
    int maior = x;

    for ( auto l : s ) {
        if ( l == 'I' ) {
            x++;
            maior = max(x, maior);
        } else x--;
    }

    cout << maior << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boostup ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
int main()
{
    boostup;
    string s,r;
    cin>>s>>r;
    ll i,j;
    ll f=0;
    if(s.size()>=r.size())
    {
        f=1;
    }
    if(r.size()>s.size()+1)
    {
        f=1;
    }
    for(i=0;i<r.size()-1;i++)
    {
        if(r[i]!=s[i])
        {
            f=1;
            break;
        }
    }
    if(f)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}   

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][][] pattern = 
			{
				{
					{1,1,0,0},
					{1,1,0,0},
					{0,0,0,0},
					{0,0,0,0},
				},
				{
					{1,0,0,0},
					{1,0,0,0},
					{1,0,0,0},
					{1,0,0,0},
				},
				{
					{1,1,1,1},
					{0,0,0,0},
					{0,0,0,0},
					{0,0,0,0},
				},
				{
					{0,1,0,0},
					{1,1,0,0},
					{1,0,0,0},
					{0,0,0,0},
				},
				{
					{1,1,0,0},
					{0,1,1,0},
					{0,0,0,0},
					{0,0,0,0},
				},
				{
					{1,0,0,0},
					{1,1,0,0},
					{0,1,0,0},
					{0,0,0,0},
				},
				{
					{0,1,1,0},
					{1,1,0,0},
					{0,0,0,0},
					{0,0,0,0},
				},
			};
		Scanner sc = new Scanner(System.in);
		CASE: while(sc.hasNext()) {
			int[][] m = new int[12][12];
			for(int i=0;i<8;i++) {
				String s = sc.next();
				for(int j=0;j<8;j++) {
					m[i][j] = s.charAt(j) - '0';
				}
			}
			for(int k=0;k<7;k++) {
				for(int i=0;i<8;i++) {
					LOOP: for(int j=0;j<8;j++) {
						for(int i2=0;i2<4;i2++) {
							for(int j2=0;j2<4;j2++) {
								if ((m[i+i2][j+j2] ^ pattern[k][i2][j2]) != 0) {
									continue LOOP;
								}
							}
						}
						System.out.println((char) ('A' + k));
						continue CASE;
					}
				}
			}
		}

	}

}

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

int main() {
	int n,m;
	cin >> n >> m;
	long long ans=-1e18,x[n],y[n],z[n],A[n];
	for(int i=0;i<n;i++)
		cin >> x[i] >> y[i] >> z[i];
	for(int j=0;j<8;j++){
		for(int i=0;i<n;i++){
			A[i] = 0;
			A[i] += (j&1)?-x[i]:x[i];
			A[i] += (j&2)?-y[i]:y[i];
			A[i] += (j&4)?-z[i]:z[i];
		}
		sort(A,A+n);
		ans = max(ans,accumulate(A+n-m,A+n,0LL));
	}
	
	cout << ans << '\n';
	return 0;
}

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

namespace ABC086_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] * ab[1] % 2 == 0 ? "Even" : "Odd");
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K,X;
    cin >> K >> X;
    for(int i = K-1; i > 0 ; i--){
    cout << X - i << ' ';
    }
    for(int i = 0; i < K; i++){
    cout << X + i << ' ';
    }
    cout << endl;
}


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

int main(){
    long long n, t;
    cin >> n;
    long long x = 1;
    long long y = n;
    if(n == 1){
        cout << 0 << '\n';
        return 0;
    }
    for(long long i = 1; i*i <= n; i++){
        if(n % i == 0){
            t = n / i;
            if( t-1 + i-1 < x-1 + y-1){
                x = t;
                y = i;
            }
        }
    }
    cout << x-1 + y-1 << '\n';
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp::*;

const INF: i32 = std::i32::MAX / 2;

fn solve(n: usize, a: &[Vec<i32>]) -> i64 {
    let mut g = vec![vec![INF; n]; n];
    for i in 0..n {
        g[i][i] = 0;
    }
    let mut v = (0..n)
        .flat_map(|i| (0..i).map(move |j| (a[i][j], (i, j))))
        .collect::<Vec<_>>();
    v.sort();
    for &(d, (i, j)) in v.iter() {
        if (0..n)
            .filter(|&k| k != i && k != j)
            .all(|k| a[i][k] + a[k][j] > a[i][j])
        {
            g[i][j] = d;
            g[j][i] = d;
            //println!("{:?} ({}, {})", &g, i, j);
        }
    }
    let mut h = g.clone();
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                h[i][j] = min(h[i][j], h[i][k] + h[k][j]);
            }
        }
    }
    //println!("{:?}", &h);
    //println!("{:?}", &a);
    if h == a {
        (0..n)
            .flat_map(|i| {
                let gg = &g;
                (0..i).map(move |j| gg[i][j])
            })
            .filter(|&d| d < INF)
            .map(|d| d as i64)
            .sum::<i64>()
    } else {
        -1
    }
}

fn main() {
    input! {
        n: usize,
        a: [[i32; n]; n],
    }
    let r = solve(n, &a);
    println!("{}", r);
}


Measured memory_bytes: 5184
#include <stdio.h>

int main(void)
{

    int i_inputA;
    int i_inputB;

    scanf("%d%d", &i_inputA, &i_inputB);

    if (i_inputA < i_inputB)
    {
        for (int count = 0; count < i_inputB; count++)
        {
            printf("%d", i_inputA);
        }
    }
    else if (i_inputA > i_inputB)
    {
        for (int count = 0; count < i_inputA; count++)
        {
            printf("%d", i_inputB);
        }
    }
    else
    {
        for (int count = 0; count < i_inputA; count++)
        {
            printf("%d", i_inputB);
        }
    }

    printf("\n");

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

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

    if(M <= 2*N) cout << M/2 << endl;
    else cout << N + (M-2*N)/4 << endl;
}

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


#define all(a) (a).begin(),(a).end()

vector<vector<int>> g;

bool get_path(int cur, int pre, int goal, vector<int> &path){
    static map<pair<int,int>, int> path_id;
    if (cur == goal) return true;
    for(int to : g[cur]){
        if(to == pre) continue;
        pair<int,int> p = {min(cur, to), max(cur, to)};
        int id = path_id.count(p) ? path_id[p] : path_id.size();
        path_id[p] = id;
        path.push_back(id);
        if (get_path(to, cur, goal, path)) {
            return true;
        } else {
            path.pop_back();
        }
    }
    return false;
}

int main(void){
    int n;
    cin >> n;
    g.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int m;
    cin >> m;
    vector<vector<int>> paths(m);
    rep(i,m){
        int u, v;
        cin >> u >> v;
        u--, v--;
        get_path(u, -1, v, paths[i]);
    }
    long long res = 0;
    rep(mask, 1<<m){
        vector<int> st(n);
        rep(i,m){
            if (bit(i) & mask) {
                for(int e : paths[i]) {
                    // st.insert(e);
                    st[e] = true;
                }
            }
        }
        int cnt = 0;
        rep(i,n) if(st[i]) cnt++;
        res += (((int)__builtin_popcount(mask) & 1) ? -1 : +1) * (1LL<<((n-1)-cnt));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h> 
using namespace std;
int n,m,ans;
bool vis[33];
int main(){
	memset (vis,1,sizeof(vis));
	cin>>n>>m;
	while (n--){
		int k;
		cin>>k;
		bool vv[33];
		memset (vv,0,sizeof(vv));
		while (k--){
			int x;
			cin>>x;
			vv[x]=1;
		}
		for (int i=1;i<=m;i++)
			vis[i]&=vv[i]; 
	}
	for (int i=1;i<=m;i++)
		if (vis[i]) ans++;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n, m, t, f, r;
    cin >> n;
    m=26;
    t=26;
    r=1;
    f=0;
    while ((n-1)/t!=0)
    {
        f=t;
        t+=m*26;
        m*=26;
        r+=1;
    }
    n-=(f+1);
    for (int i=0; i<r; ++i)
    {
        m/=26;
        cout << (char)(n/m+'a');
        n=n%m;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    vector<vector<int>> v = vector<vector<int>>(10, vector<int>(0));
    for(int i = 0; i < n; i++) {
        v[s[i] - '0'].push_back(i);
    }
    
    int ans = 0;
    for(int i = 0; i < 10; i++) {
        if(v[i].empty()) {
            continue;
        }
        int dame1 = v[i][0];
        
        for(int j = 0; j < 10; j++) {
            if(v[j].empty()) {
                continue;
            }
            
            int dame2 = *upper_bound(v[j].begin(), v[j].end(), dame1);
            if(dame2 <= dame1 || (dame2 > 30000 || dame2 < 0)) {
                continue;
            }
            
            for(int k = 0; k < 10; k++) {
                if(v[k].empty()) {
                    continue;
                }
                
                int dame3 = *upper_bound(v[k].begin(), v[k].end(), dame2);
                if(dame3 <= dame2 || (dame3 > 30000 || dame3 < 0)) {
                    continue;
                }
                else {
                    // cout << dame1 << " " << dame2 << " " << dame3 << endl;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

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

  int x = 0, ret = -INF;
  REP(i, s.size()) {
    if(s[i] == 'I') x++;
    else x--;
    ret = max(ret, x);
  }
  if(ret == -1) ret = 0;
  cout << ret << endl;

  return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> L(N);
    
    for (int i=0;i < N; i++) cin >> L.at(i);
    sort(L.begin(),L.end());

    int ans = 0;

    for(int i=0;i < N-1;i++){
        for(int j = i+1; j < N;j++){
            int it = lower_bound(L.begin(),L.end(),L.at(i) + L.at(j)) - L.begin();
            int an = it - (j + 1);
            ans += max(it - (j + 1),0);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}


int main() {
    ll h,n;
    cin >> h >> n;
    ll total = 0;
    for(int i = 0; i<n;++i){
        ll z;
        cin >> z;
        total += z;
    }
    if(h <= total){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




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

void Main()
{
    int n, k;
    cin >> n >> k;
    vector<long> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(i >= k){
            if(a[i] > a[i-k]) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
   
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 4780
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  int n, m;
  cin >> n >> m;
  vll k(m);
  vector<vll> s(m);
  REP(i, 0, m) {
    cin >> k[i];
    REP(j, 0, k[i]) {
      ll a;
      cin >> a;
      s[i].emplace_back(a - 1);
    }
  }
  vll p(m);
  REP(i, 0, m) {
    cin >> p[i];
  }

  vll ok(11, 0);
  int ans = 0;
  REP(bit, 0, 1 << n) {
    REP(i, 0, n) {
      ok[i] = 0;
    }
    REP(i, 0, n) {
      if (bit & (1 << i)) {
        ok[i] = 1;
      }
    }
    bool all = true;
    REP(i, 0, m) {
      int cnt = 0;
      REP(j, 0, k[i]) {
        if (ok[s[i][j]]) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) {
        all = false;
      }
    }
    if (all) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long n = saori.saorihayami();
		long ans = 1;
		for(int i  = 1;i <= n;i++){
			ans = ans *(i%MOD)%MOD;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int val = 0;
	while(true){
		if(!val){
			c -= b;
		}else{
			a -= d;
		}
		val = 1 - val;
		if(c <= 0){printf("Yes\n"); return 0;}
		else if(a <= 0){printf("No\n"); return 0;}
	}
	
	return 0;
};

Measured memory_bytes: 3632
#include<stdio.h>
#define MAX 44

int fibonacci(int);

int f[MAX];

int main(){
  int n;

  scanf("%d", &n);

  fibonacci(n);

  printf("%d\n", f[n]);

  return 0;
}

int fibonacci(int n){
  //nが0,1のとき1を返す
  if(n == 0 || n == 1){
    f[n] = 1;
    return f[n];
  }

  //値がすでに入っているとき、その値を返す
  if(f[n] != 0) return f[n]; //f[n]に0が入っている = 値がない

  //それ以外の時、計算してメモして返す
  f[n] = fibonacci(n-2) + fibonacci(n-1);
  return f[n];
}



Measured memory_bytes: 2108
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, m, res; cin >> n >> m, n; cout << res << endl){
        res = 0;
        map<int, int> sh;

        vi w(m), h(n);
        rep(i, n) cin >> h[i];
        rep(i, m) cin >> w[i];

        rep(i, n){
            int sum = 0;
            range(j, i, n){
                sum += h[j];
                sh[sum]++;
            }
        }

        rep(i, m){
            int sum = 0;
            range(j, i, m){
                sum += w[j];
                res += sh[sum];
            }
        }
    }

	return 0;
}

Measured memory_bytes: 19044
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int a, b, c;
	cin >>a >> b >> c;
	if(a+b+c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	
}





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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char board[][] = new char[H][W];
        List<Data> list = new ArrayList<>();
        for(int i = 0; i < H; i++){
            String s = sc.next();
            for(int j = 0; j < s.length(); j++){
                board[i][j] = s.charAt(j);
                if(board[i][j] == '#'){
                    list.add(new Data(i, j));
                }
            }
        }
        
        int index = 0;
        int result = 0;
        while(true){
            int size = list.size();
            if(size == H * W){
                break;
            }
            for(int i = index; i < size; i++){
                Data d = list.get(i);
                if(d.x > 0){
                    if(board[d.x - 1][d.y] == '.'){
                        list.add(new Data(d.x - 1, d.y));
                        board[d.x - 1][d.y] = '#';
                    }
                }
                if(d.y > 0){
                    if(board[d.x][d.y - 1] == '.'){
                        list.add(new Data(d.x, d.y - 1));
                        board[d.x][d.y - 1] = '#';
                    }
                }
                if(d.x < H - 1){
                    if(board[d.x + 1][d.y] == '.'){
                        list.add(new Data(d.x + 1, d.y));
                        board[d.x + 1][d.y] = '#';
                    }
                }
                if(d.y < W - 1){
                    if(board[d.x][d.y + 1] == '.'){
                        list.add(new Data(d.x, d.y + 1));
                        board[d.x][d.y + 1] = '#';
                    }
                }
                index++;
            }
            result++;
        }
        
        System.out.println(result);
        
    }
    
    public static class Data{
        public int x;
        public int y;
        Data(int x, int y){
            this.x = x;
            this.y = y;
        }
    }
}


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

ll ans;
ll n,m;
ll p,q,r;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}


//ap+1=bq -> bq-ap=-1

int main(){
  ll x;
  cin>>x;
  if(x==1){
    cout<<1<<endl;
    return 0;
  }
  n=x;
  x*=2;
  m=x;
  map<ll,int> ma;
  vector<ll> vec;
  int t=0;
  if(x%2==0){
    t++;
    vec.push_back(2);
    while(x%2==0){
      ma[2]++;
      x/=2;
    }
  }
  for(ll i=3;i*i<=x;i+=2){
    if(x%i==0){
      t++;
      vec.push_back(i);
      while(x%i==0){
        ma[i]++;
        x/=i;
      }
    }
  }
  if(x!=1){
    vec.push_back(x);
    t++;
    ma[x]++;
  }
  for(int i=0;i<t;i++){
    //cout<<vec[i]<<" "<<ma[vec[i]]<<endl;
  }
  int bitb[t];
  ans=2*n;
  for(int bit=0;bit<(1<<t);bit++){
    for(int i=0;i<t;i++){
      if(bit&(1<<i)){
        bitb[i]=1;
      }
      else{
        bitb[i]=0;
      }
    }
    ll u=1;
    for(int i=0;i<t;i++){
      if(bitb[i]==1){
        u*=pow(vec[i],ma[vec[i]]);
      }
    }
    //cout<<u<<" "<<m/u<<" ";
    extGCD(-u,m/u,p,q);
    //cout<<p<<" "<<q<<endl;
    if(p*q==0){
      continue;
    }
    r=u*p;
    if(r>0){
      ans=min(ans,r);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4080
///age yekam bekeshi beham is no problem ._.
#include<bits/stdc++.h>
#define size(a) (int)a.size()
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
const int maxn=1e5+7,INF=3e18+9237,mod=1e9+7;
int a[maxn];

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;cin>>s;
	int n=size(s);
	for(int i=0;i<n;i++)a[s[i]]++;
	int res=n*(n-1)/2;
	for(int i='a';i<='z';i++)res-=a[i]*(a[i]-1)/2;
	cout<<res+1;
}


Measured memory_bytes: 720