akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if( !(A==1 || B==1) )
		System.out.println(1);
		else if( !(A==2 || B==2) )
			System.out.println(2);
		else if( !(A==3 || B==3) )
			System.out.println(3);


	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

vector<int> D,K;
int d,m,n,t;

int dist(int a,int b)
{
	return min(abs(((a+d)-b)%d),abs(((b+d)-a)%d));
}

int main(void)
{
	while(true)
	{
		D.clear();
		K.clear();
		cin >> d;
		if(d == 0)
			exit(0);
		cin >> n;
		cin >> m;
		D.push_back(0);
		for(int i = 0;i < n - 1;i++)
		{
			cin >> t;
			D.push_back(t);
		}
		for(int i = 0;i < m;i++)
		{
			cin >> t;
			K.push_back(t);
		}
		sort(D.begin(),D.end());
		sort(K.begin(),K.end());
		auto ptr = D.begin();
		int sum = 0;
		int mindist = dist(*(D.begin()),*(K.begin()));
		auto minitr = D.begin();
		for(auto itr = D.begin();itr < D.end();itr++)
		{
			if(mindist > dist(*itr,*(K.begin())))
			{
				minitr = itr;
				mindist = dist(*itr,*(K.begin()));
			}
		}
		ptr = minitr;
		for(auto itr = K.begin();itr < K.end();itr++)
		{
			if(ptr + 1 != D.end())
			{
				while(dist(*(ptr+1),*itr) < dist(*ptr,*itr))
				{
					*ptr++;
				}
			}
			else
			{
				if(dist(*(D.begin()),*itr) < dist(*ptr,*itr))
				{
					ptr = D.begin();
				}
			}
			t = dist(*ptr,*itr);
			sum = sum + t;
		}
		cout << sum << endl;
	}
}

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

int main()
{
	string s;
	cin >> s;
	int a[2]={};
	for(auto i:s)
	a[i-'0']++;
	cout<<min(a[0],a[1])*2<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;

string four[]={"aabc",
               "ddbc",
               "efgg",
               "efhh"};
string five[]={"aabbc",
               "dee.c",
               "d..fg",
               "h..fg",
               "hiijj"};

string three[]={"aa.",
                "..b",
                "..b"};

string seven[]={"aabbcc.",
                ".dd.eef",
                "g..h..f",
                "g..h..i",
                "j....ki",
                "j....kl",
                ".mmnn.l"};

int main(){
  cin>>N;

  if(N==2) cout<<-1<<endl;
  else if(N==3){
    rep(i,N) cout<<three[i]<<endl;
  }else if(N==6){
    rep(i,N){
      rep(j,N){
        if(i<=2&&j<=2) cout<<three[i][j];
        else if(i>2&&j>2) cout<<three[i-3][j-3];
        else cout<<'.';
      }
      cout<<endl;
    }
  }else if(N==7){
    rep(i,N) cout<<seven[i]<<endl;
  }else if(N==11){
    rep(i,N){
      rep(j,N){
        if(i<=3&&j<=3) cout<<four[i][j];
        else if(i>3&&j>3) cout<<seven[i-4][j-4];
        else cout<<'.';
      }
      cout<<endl;
    }
  }else{
    int num=0;
    rep(i,N){
      int rest=N-4*i;
      if(rest%5==0){
        num=i;
        break;
      }
    }

    rep(i,N){
      rep(j,N){
        if(i<4*num&&j<4*num&&i/4==j/4) cout<<four[i%4][j%4];
        else if(i>=4*num&&j>=4*num&&(i-4*num)/5==(j-4*num)/5){
          int si=i-4*num;
          int sj=j-4*num;
          cout<<five[si%5][sj%5];
        }else cout<<'.';
      }
      cout<<endl;
    }
  }


  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    if(n>=k){
        cout << min(n%k,abs(n%k-k));
    }
    else{
        cout << min(n,abs(n-k));
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(' ')))
mul = 1
zero = False
for i in a:
  if i == 0:
    zero = True
    break
if zero:
  print(0)
else:
  early = False
  for i in a:
    mul *= i
    if mul > int(1e18):
      print(-1)
      early = True
      break
  if not early:
    print(mul)

Measured memory_bytes: 21788
<?php
  fscanf(STDIN,"%s",$S);
  if (ctype_upper($S) == true && strlen($S) == 4 &&
     $S[0] == $S[1] && $S[2] == $S[3] && $S[0] != $S[2] || 
     $S[0] == $S[2] && $S[1] == $S[3] && $S[0] != $S[1] || 
     $S[0] == $S[3] && $S[1] == $S[2] && $S[0] != $S[1]){
    echo"Yes\n"; 
  } else {
    echo "No\n";
  }
?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n,m;cin>>n>>m;
    ll l=0;
    ll r=pow(10,13);
    ll mid;
    while(r-l>1){
        mid=(r+l)/2;
        if(m<2*mid){
            r=mid;
            continue;
        }
        if(n+(m-2*mid)/2<mid){
            r=mid;
        }else{
            l=mid;
        }
    }
    cout<<l<<endl;
    return 0;
}






Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18)*2;
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
V<P> a;
ll n,k;
bool C(ll m){
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(a[i].fi>m)continue;
        cnt+=(m-a[i].fi)/a[i].se+1;
        if(cnt>=k)return true;
    }
    return false;
}
int main(){
    cin>>n>>k;
    a.resize(n);
    for(int i=0;i<n;i++)cin>>a[i].fi>>a[i].se;
    ll l=0,r=inf;
    while(r-l>1){
        ll mid=(l+r)/2;
        if(C(mid))r=mid;
        else l=mid;
    }
    cout<<r<<endl;
}

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

//m日目から見ていき、現在選べるものの中で報酬が最大のものを選び、それを加算するその後それを消去する

int main()
{
    int n,m;
    std::cin >> n >> m;
    std::vector<std::pair<int,int>> w(n); // 日付 / 報酬
    for(int i = 0; i < n; i++)std::cin >> w[i].first >> w[i].second;
    std::sort(w.begin(), w.end(),std::greater<std::pair<int,int>>());
    std::priority_queue<std::pair<int,int>> que; // 報酬 / 日付
    long long res = 0;
    for(int i = m -1; i >= 0; i--){
        int limit = m - i; // この日付がこれ以下だと取れる
        while(w.back().first <= limit && w.size()){
            que.push({w.back().second,w.back().second});
            w.pop_back();
        }
        if(!que.size())continue;
        res += que.top().first;
        que.pop();
    }
    std::cout << res << std::endl;
}

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

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

using namespace std;

int main(){
  string s;cin>>s;
  ll x,y;cin>>x>>y;
  vector<ll> moves, uds, lrs;
  ll ff=0;
  if(s[0]=='F')rep(i,s.size()){
    if(s[i]=='F')ff++;
    else break;
  }

  ll fcount=0;
  rep(i, s.size()-ff){
    int ci=i+ff;
    if(s[ci]=='F')fcount++;
    if(s[ci]=='T'){
      moves.push_back(fcount);
      fcount=0;
    }
  }
  if(fcount!=0)moves.push_back(fcount);

  rep(i,moves.size()){
    if(i%2==0) lrs.push_back(moves[i]);
    else uds.push_back(moves[i]);
  }

  set<ll> udset;
  udset.insert(0);
  rep(i,uds.size()){
    set<ll> tmpset;
    for(auto p : udset){
      tmpset.insert(p+uds[i]);
      tmpset.insert(p-uds[i]);
    }
    udset = tmpset;
  }

  set<ll>lrset;
  lrset.insert(ff);
  rep(i,lrs.size()){
    set<ll> tmpset;
    for(auto t : lrset){
      tmpset.insert(t+lrs[i]);
      tmpset.insert(t-lrs[i]);
    }
    lrset = tmpset;
  }

  if( udset.find(y)!=udset.end() && lrset.find(x)!=lrset.end() ){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;

cout<<endl;
for(auto p : udset)cout<<p<<' ';cout<<endl;
for(auto p : lrset)cout<<p<<' ';cout<<endl;

cout<<ff<<endl;
//rep(i,moves.size())cout<<moves[i]<<' ';cout<<endl;
rep(i,lrs.size())cout<<lrs[i]<<' ';cout<<endl;
rep(i,uds.size())cout<<uds[i]<<' ';cout<<endl;

  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<P> ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = P(a, b);
    }
    sort(ab.begin(), ab.end());
    ll ans = 0;
    for (auto p : ab) {
        if (m <= 0) break;
        ans += (ll)p.first * min((ll)m, (ll)p.second);
        m -= min(m, p.second);
    }
    cout << ans << endl;

}

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

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

    while (n--)
    {
        int x;
        cin >> x;

        if (!(x % 2))
        {
            if (x % 3 && x % 5)
            {
                cout << "DENIED\n";
                return 0;
            }
        }
    }

    cout << "APPROVED\n";
}

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

using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e5 + 10;
const double eps = 1e-9;

int main() {
    ll d, n;
    cin >> d >> n;
    ll ans = 1;
    while (d--)
        ans *= 100;

    cout << (n < 100 ? ans * n : ans * (n + 1)) << endl;
}

Measured memory_bytes: 3596
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder res = new StringBuilder();
        String line = br.readLine();
        int len = line.length();
        for(int i=0; i<len; i++) {
            char ch = line.charAt(i);
            if(Character.isLowerCase(ch)) res.append(Character.toUpperCase(ch));
            else if(Character.isUpperCase(ch)) res.append(Character.toLowerCase(ch));
            else res.append(ch);
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 16868
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
#define MX 5003
using namespace std;

int main() 
{
	IOS;
	lli n;
	cin>>n;
	lli a[n];
	for(lli i = 0; i<n; i++)
	cin>>a[i];
	map<lli, lli> cnt;
	for(lli i = 0; i<n; i++)
	cnt[a[i]]++;
	lli ans = 0;
	for(auto i : cnt)
	{
		lli k = i.second;
		lli one = (k*(k-1))/2;
		ans += one;
	}
	for(lli i = 0; i<n; i++)
	{
		lli k = cnt[a[i]];
		lli one = (k*(k-1))/2;
		lli two = ((k-1)*(k-2))/2;
		ans -= one;
		ans += two;
		cout<<ans<<endl;
		ans -= two;
		ans += one;
	}
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;
    REP(i, N) {
        cout << S.at(i) << T.at(i);
    }
    cout << endl;
    return 0;
}

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

int main()
{
    int a,b,c;
    cin>>c>>a>>b;
    int n=min(a,b);
    n+=c;
    int m=max(a,b);
    if(n<m){
        cout<<m-n<<endl;
    }
    else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005,M=6000;
int n,P;
int f[N*3][3][N*6];
int main()
{
	scanf("%d%d",&n,&P);
	n*=3;
	f[1][0][0+M]=1;
	for(int i=1;i<n;i++)
		for(int j=0;j<=2;j++)
			for(int k=-i;k<=i;k++)
			{
				if(j<=1) f[i+1][j+1][k+M]=(f[i+1][j+1][k+M]+1LL*f[i][j][k+M]*i%P)%P;
				if(j==0) f[i+1][0][k+1+M]=(f[i+1][0][k+1+M]+f[i][j][k+M])%P;
				else if(j==1) f[i+1][0][k-1+M]=(f[i+1][0][k-1+M]+f[i][j][k+M])%P;
				else if(j==2) f[i+1][0][k+M]=(f[i+1][0][k+M]+f[i][j][k+M])%P;
			}
	int ans=0;
	for(int k=0;k<=n;k+=3)
		ans=(ans+((long long)f[n][0][k-1+M]+f[n][1][k+1+M]+f[n][2][k+M])%P)%P;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 494588
#include <stdio.h>
#include <string.h>

int main(void){
    char a[100],b[100];
    int a_len,b_len;
    int i;
    scanf("%s",a);
    scanf("%s",b);

    a_len = strlen(a);
    b_len = strlen(b);

    if (a_len > b_len)
    {
        printf("GREATER");
        return 0;
    }
    else if (a_len < b_len)
    {
        printf("LESS");
        return 0;
    }

    for (i = 0; a[i] != '\0'; i++)
    {
        if (a[i] > b[i])
        {
            printf("GREATER");
            return 0;
        }
        else if (a[i] < b[i])
        {
            printf("LESS");
            return 0;
        }
    }
    printf("EQUAL");
    return 0;
}

Measured memory_bytes: 128
# AOJ 0017 Caesar Cipher
# Python3 2018.6.21 bal4u

ch = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"

while 1:
	try: s = list(input())
	except: break
	n = len(s)
	for i in range(26):
		t = ['']*n
		for j in range(n):
			if s[j] >= 'a' and s[j] <= 'z':
				t[j] = ch[ord(s[j])-ord('a')+i]
			else: t[j] = s[j]
		tt = ''.join(t)
		t = list(tt.split());
		if ("the" in t) or ("this" in t) or ("that" in t):
			print(tt)
			break



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

l = [i for i in range(1, N+1)]
l1 = l.copy()
c = [0]*N

while True:
    exist_even = False
    for i in range(N):
        if l[i] % 2 == 0:
            exist_even = True
    if not exist_even:
        break

    for i in range(N):
        if l[i] % 2 == 0:
            l[i] = l[i] // 2
            c[i] += 1

idx = c.index(max(c))
print(l1[idx])

Measured memory_bytes: 3064
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int a, b;

signed main()
{
	cin >> a >> b;

	int cnt = 0;
	int now = 1;
	REP(i, 20){
		if (b <= now) break;
		now += (a-1);
		DEBUG(now);
		cnt++;
	}

	cout << cnt << endl;
	return 0;
}



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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;



int main() {
	string s;
	int n, i, j, k;
	vi a, b;

	cin >> n;
	cin >> s;

	SIZE(a, n + 1);
	a[0] = 0;
	repj(i, 1, n+1) {
		if (s[i-1] == '#')a[i] = a[i - 1] + 1;
		else a[i] = a[i - 1];
	}
	SIZE(b, n + 1);
	b[0] = 0;
	repj(i, 1, n+1) {
		if (s[n - i] == '.')b[i] = b[i - 1] + 1;
		else b[i] = b[i - 1];
	}

	k = n + 2;
	rep(i, n + 1) {
		k = min(a[i] + b[n-i], k);
	}
	cout << k;

	return 0;
}


Measured memory_bytes: 2180
#include <cstdio>
#include <set>
using namespace std;

typedef long long LL;
set<LL> ans;

int main()
{
    LL n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    if(n == 1){
        if(a == b)
            printf("1");
        else
            printf("0");
        return 0;
    }
    else if(b >= a){
        printf("%lld", (n - 1) * b + a + 1 - ((n - 1) * a + b));
    }
    else
        printf("0");
//    printf("%d", ans.size());

    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt(), k = sc.nextInt();
		int[] array = new int[n];
		for(int i=0;i<n;i++) array[i]=sc.nextInt();
		Arrays.sort(array);
		for(int i=n-1;i>=n-k;i--) {
			if(i>=0) array[i]=0;
			else break;
		}
		long sum=0;
		for(int i=0;i<n;i++) sum+=array[i];
		System.out.println(sum);
	}
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int h,w;
  cin >> h >> w;
  
  vector<string> grid(h, "");
  int whiteCount = 0;
  for(int i=0;i<h;i++){
    cin >> grid[i];
    for(auto c:grid[i]){
      if(c=='.')whiteCount++;
    }
  }
  
  queue<tuple<int,int,int>> q;
  q.emplace(0,0,0);
  grid[0][0] = 'x';
  while(!q.empty()){
    auto pos = q.front();q.pop();
    if(get<0>(pos)==h-1&&get<1>(pos)==w-1){
      cout << whiteCount-1-get<2>(pos) << endl;     
      return 0;
    }
    if(get<0>(pos)>0 && grid[get<0>(pos)-1][get<1>(pos)]=='.'){
      q.emplace(get<0>(pos)-1,get<1>(pos),get<2>(pos)+1);
      grid[get<0>(pos)-1][get<1>(pos)] = 'x';
    }
    if(get<0>(pos)<h-1 && grid[get<0>(pos)+1][get<1>(pos)]=='.'){
      q.emplace(get<0>(pos)+1,get<1>(pos),get<2>(pos)+1);
      grid[get<0>(pos)+1][get<1>(pos)] = 'x';
    }
    if(get<1>(pos)>0 && grid[get<0>(pos)][get<1>(pos)-1]=='.'){
      q.emplace(get<0>(pos),get<1>(pos)-1,get<2>(pos)+1);
      grid[get<0>(pos)][get<1>(pos)-1] = 'x';
    }
    if(get<1>(pos)<w-1 && grid[get<0>(pos)][get<1>(pos)+1]=='.'){
      q.emplace(get<0>(pos),get<1>(pos)+1,get<2>(pos)+1);
      grid[get<0>(pos)][get<1>(pos)+1] = 'x';
    }
  }
  cout << "-1" << endl;
  return 0;
}



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

using namespace std;

int main ()
{
	int a, b;
	cin >> a >> b;
	if (a >= 1 && a <= 9 && b >=1 && b <= 9){
		cout << a*b << endl;
	}
	else {
		cout << "-1" << endl;
	}
}

Measured memory_bytes: 256
import sys
n = input()
data = map(int, raw_input().split())
for i in range(1,n):
	for k in range(0,n-1):
		sys.stdout.write(str(data[k])+" ")
	sys.stdout.write(str(data[n-1]))
	print
	temp = data[i]
	j = i-1
	while j >= 0 and data[j] > temp:
		data[j+1] = data[j]
		j = j - 1
		data[j+1] = temp
for k in range(0,n-1):
	sys.stdout.write(str(data[k])+" ")
sys.stdout.write(str(data[n-1]))
print


Measured memory_bytes: 4664
number = []
answer = 0
while 1:
    try:
        x, y = map(float, input().split(","))
        number.append((x, y))
    except:
        number.append(number[0])
        for i in range(len(number)-1):
            answer += (number[i][0] - number[i + 1][0]) * (number[i][1] + number[i+1][1])
        if answer < 0:
            answer = answer * (-1)
        print("{:.6f}".format(answer / 2))
        break



Measured memory_bytes: 5584
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void vecscl(double c, const double v0[2], double v1[2])
{
    v1[0] = v0[0] * c;
    v1[1] = v0[1] * c;
}

void vecadd(const double v0[2], const double v1[2], double v2[2])
{
    v2[0] = v0[0] + v1[0];
    v2[1] = v0[1] + v1[1];
}

void vecsub(const double v0[2], const double v1[2], double v2[2])
{
    v2[0] = v0[0] - v1[0];
    v2[1] = v0[1] - v1[1];
}

double vecsum(const double v0[2], const double v1[2])
{
    return v0[0] * v1[0] + v0[1] * v1[1];
}

double veclen(const double v[2])
{
    return sqrt(v[0] * v[0] + v[1] * v[1]);
}

bool vecnrm(double eps, const double v0[2], double v1[2])
{
    double len = veclen(v0);
    if (len < eps) {
        return false;
    }
    vecscl(1 / len, v0, v1);
    return true;
}

const double eps = 1e-12;

void solve()
{
    int x0, y0, x1, y1;
    scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
    double p0[2] = { (double)x0, (double)y0 };
    double v0[2] = { (double)x1 - x0, (double)y1 - y0 };
    bool ok = vecnrm(eps, v0, v0);
    assert(ok);

    int Q;
    scanf("%d", &Q);
    int t;
    for (t = 0; t < Q; t++) {
        int x, y;
        scanf("%d%d", &x, &y);
        double v[2] = { (double)x, (double)y };
        double vtmp[2], vtmp2[2], vtmp3[2], vtmp4[2], vtmp5[2];
        vecsub(v, p0, vtmp);
        double val = vecsum(v0, vtmp);
        vecscl(val, v0, vtmp2);
        vecadd(p0, vtmp2, vtmp3);
        vecsub(vtmp3, v, vtmp4);
        vecadd(vtmp3, vtmp4, vtmp5);
        printf("%.10lf %.10lf\n", vtmp5[0], vtmp5[1]);
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 2760
#include <iostream>

int main() {
    int R;
    std::cin >> R;
    
    if (R < 1200) {
        std::cout << "ABC" << std::endl;
    } else if (R < 2800) {
        std::cout << "ARC" << std::endl;
    } else {
        std::cout << "AGC" << std::endl;
    }
}

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

#define loop(i,n) for(int i=0;i<n;i++)
int d[11];
set<int> s;

int main(){
  int n,k;
  while(cin>>n>>k,n){
    loop(i,n)cin>>d[i];
    s.clear();
    sort(d,d+n);
    do{
      int t=0;
      loop(i,k){
        if(d[i]<10)t=t*10+d[i];
        else t=t*100+d[i];
      }
      s.insert(t);
    }while(next_permutation(d,d+n));
    cout<<s.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

// {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
//}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x, n;
	cin >> x >> n;
	set<int> ejects;
	for(int i=0; i<n; ++i){
		int e;
		cin >> e;
		ejects.insert(e);
	}
	for(int diff=0; ; ++diff){
		if( ejects.find(x-diff) == ejects.end() ){
			cout << x-diff << endl;
			return 0;
		}
		if( ejects.find(x+diff) == ejects.end() ){
			cout << x+diff << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    R = [0] * N
    G = [0] * N
    B = [0] * N
    for i, s in enumerate(S):
        if s == 'R':
            if i == 0:
                R[i] += 1
            else:
                R[i] += R[i-1] + 1
        else:
            if i == 0:
                R[i] == 0
            else:
                R[i] += R[i-1]
        if s == 'G':
            if i == 0:
                G[i] += 1
            else:
                G[i] += G[i-1] + 1
        else:
            if i == 0:
                G[i] == 0
            else:
                G[i] += G[i-1]
        if s == 'B':
            if i == 0:
                B[i] += 1
            else:
                B[i] += B[i-1] + 1
        else:
            if i == 0:
                B[i] == 0
            else:
                B[i] += B[i-1]
    counter = 0
    d = {'R': R, 'G': G, "B": B}
    for i in range(N):
        for j in range(N-1, i+1, -1):
            if S[i] == S[j]:
                continue
            l = ['R', 'G', 'B']
            l.remove(S[i])
            l.remove(S[j])
            L = d[l[0]]
            counter += L[j] - L[i]
            if (j-i) % 2 == 0 and S[(j+i)//2] == l[0]:
                counter -= 1
    print(counter)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68556
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean followRulesFlg = true;
		ArrayList<String> stringsA = new ArrayList<>();
			
		for(int a = 0; a<N; a++){
			stringsA.add(sc.next());
		}
		sc.close();
		
		@SuppressWarnings("unchecked")
		ArrayList<String> stringsB = (ArrayList<String>)stringsA.clone();
		Collections.sort(stringsB);
		
		for(int a = 0; a<stringsA.size()-1; a++){
			int b = a+1;
			if(stringsA.get(a).charAt(stringsA.get(a).length()-1)!=stringsA.get(b).charAt(0)){
				followRulesFlg=false;
				break;
			}
			if(stringsB.get(a).equals(stringsB.get(b))){
				followRulesFlg=false;
				break;
			}
		}
		System.out.println(followRulesFlg? "Yes" : "No");
	}
}

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

using ll = long long;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        A[i]--;  // 0-indexed に変更
    }

    set<int> used;     // 探索済みの町を保存
    vector<int> path;  // 探索の順番を格納
    int now = 0;
    while (used.count(now) == 0) {  // 探索済みの町に到達するまで
        path.push_back(now);
        used.insert(now);
        now = A[now];
    }

    int s = find(path.begin(), path.end(), now) - path.begin();  // s: ループする最初の部分に到達するまで
    int r = (int)path.size() - s;                                // 周期

    if (K < s) {  // ループ部分に到達しない時
        cout << path[K] + 1 << endl;
        return 0;
    } else {  // ループ部分に到達する時
        cout << path[(K - s) % r + s] + 1 << endl;
        return 0;
    }
}


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

using namespace std;
typedef long long ll;

ll MOD = 1000000007;

ll exp(ll a, ll b){
    if(b==0)
        return 1;
    else if (b%2==0){
        ll y = exp(a,b/2);
        return (y*y)%MOD;
    }
    return (a*exp(a,b-1))%MOD;
}

ll prod[1000005];

int main()
{
    ll N;
    cin>>N;
    prod[0] = 1;
    for(ll i=1; i<1000005; i++){
        prod[i] = (prod[i-1]*i)%MOD;
    }


    ll ans = 0;
    if(N==2){
        cout<<1<<endl;
        return 0;
    }
    if(N==3){
        cout<<4<<endl;
        return 0;
    }
    else{
        ans = (prod[N-1]*(N-1))%MOD;
        ll prev = 0;
        for(ll i=(N-2)/2; i>=1; i--){
            ll carry = prod[N-2-i];
            carry = (carry*exp(prod[N-2-2*i],MOD-2))%MOD;
            carry = (carry*exp(prod[i],MOD-2))%MOD;
            carry = (carry*prod[N-1-i])%MOD;
            carry = (carry*prod[i])%MOD;
            ll ct = carry;
            carry = (carry-prev)%MOD;
            prev = ct;
            carry = (carry*i)%MOD;
            ans = (ans + MOD - carry)%MOD;
        }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int N,Q;
string S;
vector<int> accum;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> Q;
  cin >> S;
  accum.resize(N);
  fill(accum.begin(),accum.end(),0);
  for(int i = 0; i < N-1; i++){
    if(S[i] == 'A' && S[i+1] == 'C'){
      accum[i + 1] = accum[i] + 1;
    }
    else{
      accum[i + 1] = accum[i];
    }
  }
  for(int i = 0; i < Q; i++){
    int l,r;
    cin >> l >> r;
    l--;r--;
    cout << accum[r] - accum[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 1600
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

ll n, k;

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin >> n >> k;
	if (n % k)
		cout << 1;
	else
		cout << 0;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX_E 10000
long long int i;
using namespace std;
 
//vector<int> G[MAX_E];
string n,m;
using namespace std;
 
int main(){
  cin>>n;
  for(i=0;i<n.size();i++){
    //cout<<m<<endl;
    if(n[i]=='B'&&m.size()>0){
      m.pop_back();
    } else if(n[i]=='0'||n[i]=='1'){ 
      m+=n[i];
    }
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define f(i,a,n) for(ll i=a;i<n;i++)
#define w(_t) ll _t;cin>>_t;while(_t--)

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;
    cin>>n;
    ll arr[n];
    f(i,0,n) cin>>arr[i];
    sort(arr,arr+n);
    ll ans=0;
    f(i,0,n-2){
        f(j,i+1,n-1){
            if(arr[i]==arr[j]) continue;
            f(k,j+1,n){
                if(arr[j]==arr[k]) continue;
                if(arr[i]+arr[j]>arr[k]) ans++;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
    char serve[101];
    int tern;
    int point_a, point_b;
    int turn;
    int game;
    int i;
    
    while (1){
        turn = 0;
        for (game = 0; game < 3; game++){
            scanf("%s", serve);
            if (serve[0] == '0'){
                goto end;
            }
            point_a = point_b = 0;
            i = 0;
            while (serve[i] != '\0'){
                if (serve[i] == 'A'){
                    point_a++;
                }
                else {
                    point_b++;
                }
                i++;
            }
            if (turn == 0){
                point_a--;
            }
            else {
                point_b--;
            }
            if (point_a > point_b){
                point_a++;
                turn = 0;
            }
            else {
                point_b++;
                turn = 1;
            }
            printf("%d %d\n", point_a, point_b);
        }
    }
end:;
    return (0);
}

Measured memory_bytes: 0
#
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
#print(s)

a = []
x = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
else:
    a.append(x)
#print(a)

y = 0
for j in a:
    y += j*(j-1)/2

print(int(y))


Measured memory_bytes: 11408
//   https://atcoder.jp/contests/abc077/tasks/abc077_b


#include<stdio.h>    //AA06( 31/ 07/ 20) If u see my code, Have a Good Day! (^_^)
#include<math.h>

int main()
{
    int N, X;

    scanf("%d", &N);

    X = (int) sqrt(N);

    printf("%d\n", X * X);

    return 0;
}


Measured memory_bytes: 2120
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int c = 0;
    boolean flag = true;
    if(s.charAt(0)!='A'){
      flag = false;
    }
    for(int i=2;i<s.length()-1;i++){
      if(s.charAt(i) == 'C'){
        c++;
      }else if(Character.isUpperCase(s.charAt(i))){
        flag = false;
        break;
      }
    }
    if(Character.isUpperCase(s.charAt(1))){
      flag = false;
    }
    if(Character.isUpperCase(s.charAt(s.length()-1))){
      flag = false;
    }
    if(flag && c==1){
      System.out.println("AC");
    }else{
      System.out.println("WA");
    }
  }
}


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

typedef long long ll;

int main() {
	 int n;
	 cin >> n;
	 vector<int> v(n);
	 for (int i = 0; i < n; ++i) cin >> v[i];
	 sort(v.begin(),v.end());
	 cout << v[n - 1] - v[0];
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<fstream>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
string s;
char fz,fz1;
int sum;
int main()
{
	cin>>s;
	 fz=s[0];
	 int len=s.size();
	 fz1=s[len-1];
	
	for(int i=1;i<=s.size()-2;i++) sum++;
	
	cout<<fz<<sum<<fz1;
	
	
	
	return 0;
}

Measured memory_bytes: 256
s,t=input(),input()
ls,lt=len(s),len(t)
dp=[[0 for _ in range(lt+1)] for _ in range(ls+1)]
for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j],dp[i+1][j+1])
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j+1])
#print(dp[ls][lt])

res =''
i,j =ls,lt
while(i>0and j>0):
    # case:(i - 1, j) -> (i, j)
    if dp[i][j] == dp[i-1][j]:
        i -=1
    # case:(i,j-1) -> (i,j)
    elif dp[i][j] == dp[i][j-1]:
        j -=1
    # case:(i-1,j-1) ->(i,j)
    else:
        res = s[i-1]+res
        i -=1
        j -=1
print(res)

Measured memory_bytes: 121308
s = input()
N = len(s)
value = []
for i in range(2**(N - 1)):
    x = []
    so = s
    cnt = 1
    for j in range(N - 1):
        if (i >> j) &  1:
            x.append(j)
    if len(x) > 0:
        val = 0 
        ind = 0
        for k in (x):
            val += int(s[ind:k+1])
            ind = k+1
        val += int(s[k+1:])
        value.append(val)
    else:
        value.append(int(s))
print(sum(value))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,cnt2=0,cnt5=0;
    cin>>n;
    if(n%2) cout<<0<<endl;
    else{
        for(ll i=2;i<=n;i*=2) cnt2+=n/i;
        for(ll i=10;i<=n;i*=5) cnt5+=n/i;
        cout<<min(cnt2,cnt5)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
int b1,b2,b3;
cin >> b1 >> b2 >> b3;

if(b1==1&&b2==0&&b3==0)
cout << "Close" << endl;

else if  (b1==0&&b2==1&&b3==0)
cout << "Close" << endl;

else if  (b1==1&&b2==1&&b3==0)
cout << "Open" << endl;

else if  (b1==0&&b2==0&&b3==1)
cout << "Open" << endl;

else if  (b1==0&&b2==0&&b3==0)
cout << "Close" << endl;

else
cout<<endl;
}


Measured memory_bytes: 3096
S = gets.chomp.split("").map(&:to_i)
list = []
['','+'].repeated_permutation(S.length-1) do |a|
  list << a
end
total = 0
list.each do |al|
  moji = []
  S.each_with_index do |sa, i|
    moji << sa
    moji << al[i] if i < al.length
  end
total += eval(moji.join)
end
puts total


Measured memory_bytes: 2300
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a1, a2, a3 := nextInt(), nextInt(), nextInt()
	sum := a1 + a2 + a3
	if sum >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win ")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int n;
    cin >> n;
    
    int low = 0, sol = 0;
    
    for(int i = 0; i < n; ++i){
    	int a;
    	cin >> a;
    	
    	if(i == 0){
    		low = a;
    		sol++;
		}
    	else if(a <= low){
    		sol++;
    		low = a;
		}
	}
	
	cout << sol;

	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll arr[4];
    arr[0]=a*c;
    arr[1]=a*d;
    arr[2]=b*c;
    arr[3]=b*d;
    cout<<max(arr[0],max(arr[1],max(arr[2],arr[3])))<<endl;
    return 0;
}


Measured memory_bytes: 3628
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (300)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 998244353LL;

// ***************************** CODE ***************************** //

LL dp[maxn][maxn * maxn * 2];
LL dp2[maxn][maxn * maxn * 2];

int main()
{
	_upgrade
  int n;
  cin>>n;
  LL res = 1LL;
  for(int i = 0;i < n;i++)
    res = (res * 3LL) % mod;
  dp[0][300 * 300] = 1;
  dp2[0][300 * 300] = 1;
  for(int i = 1;i <= n;i++)
  {
    int a;
    cin>>a;
    for(int val = 0;val < maxn * maxn * 2;val++)
    {
      if(val + a < maxn * maxn * 2)
      {
        dp[i][val + a] += dp[i - 1][val];
        dp[i][val + a] %= mod;
        dp2[i][val + a] += dp2[i - 1][val];
        dp2[i][val + a] %= mod;
      }
      if(val - a >= 0)
      {
        dp[i][val - a] += dp[i - 1][val] * 2LL;
        dp[i][val - a] %= mod;
        dp2[i][val - a] += dp2[i - 1][val];
        dp2[i][val - a] %= mod;
      }
    }
    // for(int j = 300 * 300 - 5;j <= 300 * 300 + 5;j++)
    //   dbg(i, j - 300 * 300, dp[i][j]);
  }
  for(int i = 300 * 300;i < maxn * maxn * 2;i++)
  {
    res -= 3LL * dp[n][i];
    res %= mod;
  }
  res += 3LL * dp2[n][300 * 300];
  // res -= dp[n][300 * 300] * 2LL;
  res %= mod;
  res += mod;
  res %= mod;
  cout<<res;

	return 0;
}


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

const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  //頂点の番号を０からにする
  --x; --y;
  vector<int> ans(n,0);
  for(int sv = 0; sv < n;sv++){
    vector<int> dist(n,INF);
    queue<int> q;
    auto push = [&](int v, int d){
      if(dist[v] != INF)return;
      dist[v] = d;
      q.push(v);
    };
    push(sv,0);
    while(!q.empty()){
      int v = q.front();q.pop();
      int d = dist[v];
      if(v-1 >= 0) push(v-1,d+1);
      if(v+1 < n) push(v+1,d+1);
      if(v == x)push(y,d+1);
      if(v == y)push(x,d+1);
    }
    for(int i = 0; i < n; i++){
      ans[dist[i]]++;
    }
  }
  for(int i = 1;i < n;i++){
    cout << ans [i] /2 << endl;
  }
  return 0;
}

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

typedef long long ll;
using namespace std;

int main()
{
    int N, max = -1;
    string S;

    cin >> N >> S;

    for (int i = 0; i < N; i++) {
        int count = 0;
        int a[26] = {0};
        int b[26] = {0};
        for (int j = 0; j < i; j++) {
            a[int(S[j] - 'a')]++;
        }
        for (int k = i; k < N; k++) {
            b[int(S[k] - 'a')]++;
        }

        for (int l = 0; l < 26; l++) {
            if(a[l] * b[l] > 0) count++;
        }
        if (max <= count) max = count;
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    int N;
    double d, x, D, X, sol = 0.0;
    cin >> N >> d >> x;
    for (int n = N;n >= 2;n--) {
        D = (2 * (n + 1) * d + 5 * x) / 2 / n;
        X = (n + 2) * x / n;
        sol += d + x * (2 * n - 1) / 2;
        d = D;
        x = X;
    }
    sol += d + x / 2;
    cout.precision(20);
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 256