akhauriyash/Code-Regression huggingface dataset:
n, a, b = map(int, input().split())
mod = 10**9 + 7
 
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod
 
ans = pow(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)

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

int64_t cubic(const int64_t x) {
	return x*x*x;
}

void print(const int64_t x) {
	cout << x << endl;
}

int main() {
	int64_t x;
	cin >> x;
	
	//print x^3
	print(cubic(x));
	
	return 0;
}

Measured memory_bytes: 3076
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int s = in.nextInt();
		in.close();

		Map<Integer, Integer> map = new HashMap<>();
		map.put(s, 0);
		int result = 0;
		int prev = s;
		for (int i = 1; i <= 1000000; ++i) {
			int next = getNext(prev);
			if (map.containsKey(next)) {
				result = i;
				break;
			}
			map.put(next, i);
			prev = next;
		}
		System.out.println(result + 1);

	}

	private static int getNext(int prev) {
		if (prev % 2 == 0) {
			return prev / 2;
		} else {
			return 3 * prev + 1;
		}
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);


bool cmp(const PII& a, const PII& b){
    int af = a.first, as = a.second;
    int bf = b.first, bs = b.second;

    if(as > 0 and bs > 0){
        return af > bf;
    }else if(as > 0 and bs <= 0){
        return true;
    }else if(as <= 0 and bs > 0){
        return false;
    }else{
        int amin = min(af,as+bf);
        int bmin = min(bf, bs+af);
        return amin > bmin;
        //int da = -af - (-as);
        //int db = -bf - (-bs);
        //return da > db;
        //return af-as < bf-bs;
    }
    

    //if(as > 0 and bs <= 0) return true;
    //if(as <= 0 and bs > 0) return false;
    //if(as < 0) return af - as < bf - bs;
    //else return af > bf;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    vector<pair<int,int>> S;
    int sum = 0;
    REP(i,N){
        string s; cin >> s;
        int acc = 0;
        int tmin = 0;
        for(char c : s){
            if(c == '('){
                acc++;
            }else{
                acc--;
            }
            chmin(tmin,acc);
        }
        S.eb(tmin,acc);
        sum += acc;
    }
    if(sum != 0){
        cout << "No" << endl;
        return 0;
    }
    sort(S.begin(),S.end(),cmp);
    int now = 0;
    int tmin = 0;
    REP(i,N){
        int a,b;
        tie(a,b) = S[i];
        chmin(tmin,now+a);
        now += b;
    }
    if(tmin == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



}

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

l = []
for i in range(0,m):
    l.append(list(map(int,input().split())))

l2 = []
for i in range(0,n):
    l2.append(int(input()))


for i in range(0,m):
    sum = 0
    for j in range(0,n):
        sum += l[i][j] * l2[j]
    print (sum)


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

using ll=long long;

const int MAX = 2200000;
const long long MOD = 1000000007;
long long INF = 90000000001000;
int getgcd(int n, int m)
{
int r;
if (n > m) {
int t = m;
m = n;
n = t;
}
while ((r = m % n) != 0) {
m = n;
n = r;
}
return n;
}

int main() {

int k,mn,mx=1;cin >> k;
ll sum = 0;
for (int i = 1; i <=k ; ++i)
{
    for (int j = 1; j <=k ; ++j)
    {
        for (int l = 1; l <=k ; ++l)
        {
          sum += getgcd(getgcd(i, j), l);
          //cout << i << " " << j<<" " << getgcd(i, j)<<"\n";
          //cout <<  l<<" " << getgcd(i, j)<<"\n";
        }
    }
}

cout << sum << endl;

return 0;
}




Measured memory_bytes: 3632
while True:
    r_0,w_0,c,r = map(int,input().split())
    if r_0 == w_0 == c == r:
        break
    if c <= (r_0/w_0):
        print(0)
    else:
        num = 0
        while True:
            num += 1
            r_0 += r
            if c <= (r_0/w_0):
                print(num)
                break

Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll lg=31;
const ll N=1e5+5;
const ll INF=3e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define f first
#define s second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repp(i, a, b) for(int i = a; i > (b); --i)
#define sz(x) (int)(x).size()
#define pb push_back
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main() {
  FASTIO;
  bool n;
  cin >> n;
  cout << !n << endl;
  return 0;
}

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

const ll MOD=1e9+7;
ll dp[2005];
ll func(int n){
    if(n==0)    return 1;
    if(dp[n]!=-1)   return dp[n];
    ll ans=0;
    for(int k=3;k<=n;k++){
        ans+=func(n-k);
        ans%=MOD;
    }
    return dp[n]=ans;
}
main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    ll n;cin>>n;
    cout<<func(n)<<"\n";   
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N, K;
    string S;
    cin >> N >> S >> K;
    char X = S[K - 1];
    for(int i = 0; i < N; i++){
        if(S[i] != X){
            S[i] = '*';
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys

    H, W = map(int, sys.stdin.readline().split())
    A = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
    B = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
    X = [[0] * W for i in range(H)]
    for h in range(H):
        for w in range(W):
            X[h][w] = abs(A[h][w] - B[h][w])

    dp = [[set() for j in range(W)] for i in range(H)]
    dp[0][0].add(X[0][0])
    dp[0][0].add(-X[0][0])

    for h in range(H):
        for w in range(W):
            if h == 0 and w == 0:
                continue
            x = X[h][w]
            s = set()

            if h > 0:
                for d in dp[h - 1][w]:
                    s.add(d + x)
                    s.add(abs(d - x))

            if w > 0:
                for d in dp[h][w - 1]:
                    s.add(d + x)
                    s.add(abs(d - x))

            dp[h][w] = s

    ans = min([abs(s) for s in dp[H - 1][W - 1]])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 504476
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    string num = strin();
    if(num[0] == '7' or num[1] == '7' or num[2] == '7') puts("Yes");
    else puts("No");
}

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

int main(){
  vector<char> n(3);
  for(int i=0;i<3;i++){
    cin >> n.at(i);
  }
  
  for(int i=0;i<3;i++){
    if(n.at(i)=='1'){
      n.at(i)='9';
    }else if(n.at(i)=='9'){
      n.at(i)='1';
    }
  }
  for(int i=0;i<3;i++){
    cout << n.at(i) ;
  }
 }



Measured memory_bytes: 256
//#include <iostream>
#include <bits/stdc++.h>
using namespace std;
//char s[100001];
string s;
int main() {
  int n, q, k;
  cin >> n;
  cin >> s;
  cin >> q;
  while(q--) {
    long d=0, m=0, dm=0, dmc=0;
    cin >> k;
    for (int i=0; i<n; i++) {
      if (i>=k) {
        if (s[i-k] == 'D') {
          d--;
          dm -= m;
        } else if (s[i-k] == 'M')
          m--;
      }
      if (s[i] == 'D')
        d++;
      else if (s[i] == 'M') {
        m++;
        dm += d;
      } else if (s[i] == 'C')
        dmc += dm;
    }
    cout << dmc << "\n";
  }
}


Measured memory_bytes: 1412
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    println!("{}", 3 * n * n);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2108
S = input()
S = list(S)
ans = [int(0) for i in range(len(S))]
countRL = [0]
for i in range(len(S)-1):
  if S[i] == 'R' and S[i+1] == 'L' or S[i] == 'L' and S[i+1] == 'R':
    countRL.append(i+1)
countRL.append(len(S))
#print(countRL)
for i in range(len(countRL)-2):
  if i%2 == 0:
    j = countRL[i+2] - countRL[i]
    if j%2 == 0:
      ans[int(countRL[i+1])-1] = int(j/2)
      ans[int(countRL[i+1])]   = int(j/2)
    else:
      if (int(countRL[i+1]-1) - int(countRL[i]))%2 == 0:
        ans[int(countRL[i+1])-1] = int(j//2 + 1)
        ans[int(countRL[i+1])]   = int(j//2)
      else:
        ans[int(countRL[i+1])-1] = int(j//2)
        ans[int(countRL[i+1])]   = int(j//2 + 1)
for i in range(len(S)):
  print(ans[i],end = ' ')

Measured memory_bytes: 9376
N, K = map(int, input().split())
lis_p = map(int, input().split())
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp= sum(lis_exp[0:K])
cumKsum = sum(lis_exp[0:K])
for i in range(1, N-K+1):
    cumKsum = cumKsum - lis_exp[i-1] + lis_exp[i+K-1]
    dp = max(cumKsum, dp)
print(dp)

Measured memory_bytes: 23588
import java.util.*;

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

        int ans = (n - h + 1) * (n - w + 1);
        System.out.println(ans);
    } 
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
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; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;

ll floor_sum(ll n, ll m, ll a, ll b) {
  ll res = 0;
  if(a >= m) {
    res += n*(n - 1)*(a/m) / 2;
    a %= m;
  }
  if(b >= m) {
    res += n*(b/m);
    b %= m;
  }

  ll ymax = (a*n + b)/m, xmax = m*ymax - b;
  if(ymax == 0) return res;
  res += ymax*(n - (xmax + a - 1)/a);
  res += floor_sum(ymax, a, m, (a - xmax%a)%a);
  return res;
}

int main()
{
  int t; cin >> t;
  while(t-- > 0) {
    ll n,m,a,b; cin >> n >> m >> a >> b;
    cout << floor_sum(n,m,a,b) << "\n";
  }
  return 0;
}


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define delete

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    map<llong, llong> cnt;
    vector<llong> A;
    llong sum_of_A = 0;
    rep(i, n) {
        llong a;
        cin >> a;
        A.push_back(a);
        ++cnt[a];
        sum_of_A += a;
    }

    int q;
    cin >> q;
    rep(_, q) {
        llong b, c;
        cin >> b >> c;
        sum_of_A += (c- b)*cnt[b];
        int tmp = cnt[b];
        cnt[b] -= tmp;
        cnt[c] += tmp;
        
        cout << sum_of_A << endl;
    }

    return 0;
}

Measured memory_bytes: 10032
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin>>N;
  string s;
  cin>>s;

  int red = count(s.begin(), s.end(), 'R');
  int blue = count(s.begin(), s.end(), 'B');

  int ans = red > blue;
  cout<<(ans? "Yes":"No")<<endl;

  return 0;
}


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

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N; cin>>N; vector<int> A;
  while(N>0){
    A.push_back(N%10);
    N/=10;
  }
  int a=A.size()-1, ans=A[a];
  for(int i=a-1; i>=0; i--){
    if(A[i]!=9){
      ans=a*9+A[a]-1;
      break;
    }
    ans+=A[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n;
    IN(n);
    vector<int>a(n+1);
    for(int i=1;i<=n;i++){
        IN(a[i]);
    }
    vector<int>b(n+1);
    int cnt=0;
    for(int i=n;i>=1;i--){
        int sum=0;
        int j=2;
        while(i*j<=n){
            sum+=b[i*j];
            j++;
        }
        b[i]=(a[i]+sum)%2;
        if(b[i]==1)cnt++;
    }
    OUT(cnt);
    for(int i=1;i<=n;i++){
        if(b[i]==1)OUT(i);
    }
	return 0;
}

Measured memory_bytes: 2432
import collections

n, m = map(int, input().split())

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
                
UF = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    
    UF.union(a, b)

for i in range(n):
    _ = UF.find(i)

c = collections.Counter(UF.par)
print(len(c.keys()) - 1)

Measured memory_bytes: 16892
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main()
{
    int n,sum=0;
    cin>>n;
    int a[n];
    REP(i,n)cin>>a[i];
    bool flag=1;
    while(flag)
    {
        
        flag=0;
        for(int i=n-1;i>0;i--)
        {
            if(a[i]<a[i-1])
            {
                swap(a[i],a[i-1]);
                flag=1;
                sum++;
            }
        }
    }
    REP(i,n)
    {
        if(i!=0)cout<<" ";
        cout<<a[i];
    }cout<<endl;
    cout<<sum<<endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B;
  cin>>A>>B;
  
  int n=B-A-1;
  
  int sum=0;
  
  for(int i=1;i<=n;i++){
    sum+=i;
  }
  
  cout<<sum-A<<endl;
}

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

last_odd, last_even = m, m-1

if last_odd % 2 ==0:
    last_odd, last_even = last_even, last_odd
    

oddl = 1
oddr = oddl + last_odd

evenl = oddr + 1
evenr = evenl + last_even

while oddl < oddr:
    print(oddl, oddr)
    oddl += 1
    oddr -=1
while evenl < evenr:
    print(evenl, evenr)
    evenl += 1
    evenr -= 1 

Measured memory_bytes: 9292
import sys
input = sys.stdin.readline
from collections import Counter
M = 998244353
N = int(input())
D = list(map(int, input().split()))
counter = Counter(D)
ans = 1
pre_c = 1
if D[0] != 0 or counter[0] != 1:
    print(0)
else:
    for i, (k, c) in enumerate(sorted(counter.items(), key=lambda x: x[0])):
        if k == 0:
            continue
        elif i != k:
            ans = 0
            break
        ans *= pre_c ** c
        pre_c = c
    print(ans%M)

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

int max_common(long,long);

int main(void){
    long a, b,r,mod;
    cin >> a >> b;

    if(a>b)
        mod = max_common(a, b);
    else
        mod = max_common(b, a);

    
    cout<< a * b / mod << endl;

    return 0;
}

int max_common(long a, long b){
    long r = a % b;
    if (r == 1)
        return r;
    else if(r==0)
        return b;
        else
        return max_common(b, r);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int A, B, C;
  cin>>A>>B>>C;
  int ans[3] = {A,B,C};
  sort(ans, ans+3);
  cout<<ans[2]*10 + ans[1] + ans[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
def prime_factorize(n):
    limit = int(n ** 0.5) + 1
    yakusu = []
    i = 2
    while i <= limit:
        while n % i == 0:
            n //= i
            yakusu.append(i)
        i += 1
    if not n == 1: # 最後がiで割り切れた場合は1が残り、そうでない場合は残りも因数となる。これは必ず因数の中で最大になる。(そうでないなら最後に割ったiより先に因数になってる)
        yakusu.append(n)

    return yakusu


import itertools


N = int(input())
F = prime_factorize(N)
F = list(set(F))
l = len(F)

s = 0
t = [i for i in range(l)]
for i in range(l):
    for a in itertools.combinations(t, i + 1):
        x = 1
        for k in a:
            x *= F[k]
        if i % 2 == 0:
            s += N // x
        else:
            s -= N // x

print(N - s)



Measured memory_bytes: 5680
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    x = LI()

    ans = INF
    for i in range(N - K + 1):
        to_first_x = min([abs(x[i]), abs(x[i+K-1])])
        ans = min(to_first_x + x[i + K - 1] - x[i], ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 21460
#!/usr/bin/env python
import math
n = int(input()) 
a = list(map(int, input().split()))

mod = 10**9+7

def lcm(a, b): 
    return a*b//math.gcd(a, b)

l = a[0]
for i in range(n):
    l = lcm(l, a[i])
l %= mod 

ans = 0 
for i in range(n):
    inv = pow(a[i], mod-2, mod)
    ans += (l*inv)%mod

print(ans%mod)


Measured memory_bytes: 10184
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
 
public class Main {
    public static void main(String args[])throws Exception{
        /*
         * x - r が0 より小さい、または、x + r がW より大きいならばNoと判定。
         * x - r が0 以上、かつ、x + r がW 以下ならばYesと判定。
         */
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String line = br.readLine();
                //文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除きます。
                line = line.trim();
                //半角スペースを区切り文字として扱う
                String[] readLineArray = line.split("[\\s+]");
 
                int W,H,x,y,r;
                W = Integer.parseInt(readLineArray[0]);
                H = Integer.parseInt(readLineArray[1]);
                x = Integer.parseInt(readLineArray[2]);
                y = Integer.parseInt(readLineArray[3]);
                r = Integer.parseInt(readLineArray[4]);
 
                if( (x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H ){
                    System.out.println("Yes");
                }
                else{
                    System.out.println("No");
                }
    }
}

Measured memory_bytes: 17056
#include <bits/stdc++.h>
#include <string>
//#include <queue>
using namespace std;
#define ll long long
#define ld long double


int main()
{
    //ifstream fi;
    //ofstream fo;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char a,b,c,d;
    cin >>a>>b>>c>>d;
    if(a==b) cout << "Bad"; else
    if(b==c) cout << "Bad"; else
    if(c==d) cout << "Bad"; else cout << "Good";
    return(0);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
struct UnionFind {
  vector<int> parent, sz;
  UnionFind(int n) {
    parent.resize(n, -1);
    sz.resize(n, 1);
  }
  int root(int x) {
    if (parent[x] == -1)
      return x;
    return parent[x] = root(parent[x]);
  }
  void unite(int x, int y) {
    if (root(x) == root(y))
      return;
    x = root(x); y = root(y);
    parent[x] = y;
    sz[y] += sz[x];
    return;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
};

int main() {
  int n, q; cin >> n >> q;
  UnionFind T(n);
  while (q --) {
    int com, x, y; cin >> com >> x >> y;
    if (com == 0) {
      T.unite(x, y);
    } else if (com == 1)
      cout << T.same(x, y) << endl;
  }
  return 0;
}



Measured memory_bytes: 3184
#include<stdio.h>
#include<math.h>

int main (void)
{
	int input1,input2;
	int i,j;
	do
	{
		scanf("%d %d",&input1,&input2);
		if(input1 == 0 && input2 == 0)
		{
			break;
		}
		for(i = 0 ; i < input1 ; i++)
		{
			for(j = 0 ; j < input2 ; j++)
			{
				if(j == 0 || j == input2 - 1)
				{
					printf("#");
				}
				else if(i == 0 || i == input1 - 1)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}while(1);
	return 0;
}


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


int main(){
  int n;
  cin >> n;
  vector<int>x(n);
  rep(i,n)cin >> x[i];
  ll m=INF,tmp;
  rep(i,100){
    tmp=0;
    rep(j,n){
      tmp+=pow(x[j]-i-1,2);
    }
    m=min(tmp,m);
  }
  cout << m ;
}

    





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

int main(){
  int n;
  cin >> n;
  int amin,amax;
  int bmin,bmax;
  rep(i,n){
    int x,y;
    cin >> x >> y;
    if(i==0){amin=x+y;amax=x+y;bmin=y-x;bmax=y-x;}
    else{amin=min(amin,x+y);amax=max(amax,x+y);bmin=min(bmin,y-x);bmax=max(bmax,y-x);}
//    cout << amin << amax << bmin << bmax << "\n";
  }
  cout << max(amax-amin,bmax-bmin);
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)

const int maxn = 5e5 + 1, mod = 1e9 + 7;

using namespace std;

bool v[1000][1000];
int d[1000][1000];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, a, b, c, d; string s;
    cin >> n >> a >> b >> c >> d >> s;
    --a; --b;
    if (c < d) {
        for (int i = a + 1; i < d; i++) {
            if (s[i] == '#' && s[i - 1] == '#') {
                cout << "No"; return 0;
            }
        }
        cout << "Yes";
        return 0;
    }
    for (int i = a + 1; i < c; i++) {
        if (s[i] == '#' && s[i - 1] == '#') {
            cout << "No"; return 0;
        }
    }
    for (int i = b; i < d; i++) {
        if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
            cout << "Yes"; return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3728
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

N = int(input())
A = list(map(int, input().split()))

val = A[0]
cnt = 0
for a in A:
    if val < a:
        val = a
    else:
        cnt += val - a
print(cnt)



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

using namespace std;

double a,b,x;
const double pi = 3.141592653589793238;

int main()
{
    cin >> a >> b >> x;

    double y = (2*x)/(a*b);
    double h;
    if (y - a > 1e-9) {
        h = (2*x)/(a*a) - b;
        y = a;
    }
    double res = atan((b-h)/ y);
    if (res < 0) res += pi;
    cout << setprecision(10) << fixed << res / pi * 180;
    return 0;
}


Measured memory_bytes: 256
import itertools

n,m=map(int,input().split())
emp=[[] for i in range(n)]
count=0

for i in range(m):
    a,b=map(int,input().split())
    emp[a-1].append(b-1)
    emp[b-1].append(a-1)

nlis=[i for i in range(n)]
perm=list(itertools.permutations(nlis))

for one_case in perm:
    if one_case[0]==0:
        cou=0
        for i in range(n-1):
            if one_case[i+1] in emp[one_case[i]]:
                cou+=1
            
            if cou==n-1:
                count+=1
print(count)

Measured memory_bytes: 13904
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int n; ll A, B; 
vll h;

inline bool check(ll x){
    ll rest = x;
    for(ll e : h){
        e -= B * x;
        if(e <= 0) continue;
        rest -= (e + A - B - 1) / (A - B);
        if(rest < 0) return false;
    }
    return true;
}

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

    cin >> n >> A >> B;
    h = vll(n); for(auto& e : h) cin >> e;

    ll lb = 0, ub = (ll)1e9 + 1;
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;

        if(check(mid)){
            ub = mid;
        }
        else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int d[N];
    for(int i=0; i<N; i++){
        cin >> d[i];
    }

    int ans = 0;;

    sort(d, d+N);

    for(int i=d[0]; i<=d[N-1]; i++){
        auto it = lower_bound(d, d+N, i);
        int l = distance(d, it);
        if(l == N-l) ans++;
    }

    cout << ans;

    return 0;
}

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

 
int main(){
    int N;
    int A;
    int a[100100];
  
    cin >> N >> A;
    for (int i = 0; i < N; ++i) cin >> a[i];
    


    cout << N*N - A << endl;
   
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
ll const MOD=1e9+7;

int main(){
  int N;cin>>N;
  vi C;
  for (int i=0;i<N;++i){
    int c;cin>>c;C.push_back(c);
  }

  ll dp[200010];
  ll c_cum[200010];
  memset(c_cum, 0, sizeof(c_cum));
  dp[0]=1;c_cum[C[0]]=1;
  
  if(N!=1){
    for (int i=1;i<N;++i){
      if(C[i-1]!=C[i]) (c_cum[C[i]]+=dp[i-1])%=MOD;
      dp[i]=c_cum[C[i]];
    }
  }

  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 4340
/*================================================
# ~  file:A.cpp
# ~~ date:2020-03-14
# ~~~author: SoMnus_L
#        |everybody finds love,in the end|
#   人の運命か,人の希望は悲しみにつづられているね
=================================================*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N=1e6+10;
using namespace std;
typedef pair<int,int>PII;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
int main(){
 ios::sync_with_stdio(false);
  cin>>n;
  cout<<a[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=2e5+5;
int mark[maxm];
signed main(){
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int a=abs(i-j);//按原来的路走
            int b=abs(x-i)+abs(y-j)+1;//走x-y
            int d=min(a,b);
            mark[d]++;
        }
    }
    for(int i=1;i<=n-1;i++)cout<<mark[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.rbegin(), v.rend());
  long long res = v[0];
  for (int i = 2; i < N; i++) {
    res += v[i/2];
  }
  cout << res << endl;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    ll A, V, B, W, T; cin >> A >> V >> B >> W >> T;
    if (A == B) {
        cout << "YES" << endl;
    } else if (A < B) {
        if (A - B >= T * (W - V)) cout << "YES" << endl;
        else cout << "NO" << endl;
    } else {
        if (A - B <= T * (V - W)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ans=0;
	ans+=n/500*1000;
	n%=500;
	ans+=n/5*5;
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
l = list(map(int,input().split()))
combi = itertools.combinations(list(range(n)),3)
ans = 0

for i in combi:
    l_1 = [l[i[0]],l[i[1]],l[i[2]]]
    l_1.sort()
    flag_1 = l_1[0]+l_1[1]>l_1[2] and l_1[1]+l_1[2]>l_1[0] and l_1[0]+l_1[2]>l_1[1]
    flag_2 = l_1[0] != l_1[1] and l_1[1] != l_1[2] and l_1[0] != l_1[2]
    if flag_1 and flag_2:
        ans += 1

print(ans)

Measured memory_bytes: 9208
n = gets.chomp.to_i
a = []
(1..n).each do
    a.push(gets.chomp.to_i - 1) # 次のボタンのインデックス
end

btn = 0

(1..n).each do |cnt|
    if btn == 1
        puts "#{cnt-1}"
        break
    end
    if cnt == n
        puts -1
        break
    end
    btn = a[btn]
end

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

vector<pair<ll, ll> > prime_factorize(ll N){
    vector<pair<ll, ll> > res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0) continue;
        ll ex = 0;
        while(N % i == 0){
            ex++;
            N /= i;
        }
        // 素数と指数をpush
        res.push_back({i, ex});
    }
    if(N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll a, b; cin >> a >> b;

    ll g = gcd(a, b);
    V<P<ll, ll> > v = prime_factorize(g);

    cout << v.size() + 1 << endl;

    return 0;
}


Measured memory_bytes: 3624
from fractions import gcd
 
a, b, c, d = map(int, input().split())
a = a - 1
 
def main():
    cd = c * d // gcd(c, d)
    print(b - a - f(c) - f(d) + f(cd))
 
def f(x):
    return b // x - a // x
 
main()

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int no=a+b;
    int no1=a-b;
    int no2=a*b;
    cout<<max(no2,max(no1,no))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int n = 0 , c = 0, m;
    while (!isdigit(c)) m = c - 45 ? 1 : -1 , c = getchar();
    while (isdigit(c))  n = n * 10 + c - 48 , c = getchar();
    return m * n;
}
const int N = 1e6 + 1;

main()
{
    int n = read() , k = read();
    int ans = 1;
    while(n --){
        if(ans * 2 < ans + k)
            ans *= 2;
        else
            ans += k;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>

inline int read(void){
	int res = 0;
	char ch = std::getchar();
	while(ch < '0' || ch > '9')
		ch = std::getchar();
	while(ch >= '0' && ch <= '9')
		res = res * 10 + ch - 48, ch = std::getchar();
	return res;
}

int n, a;
int ans;

int main(){
	n = read();
	for(int i = 1; i <= n; ++i){
		a = read();
		if((i & 1) && (a & 1))
			++ans;
	}
	std::printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
          string s,t;
          cin>>s>>t;
          int a,b;
          cin>>a>>b;
          string u;
          cin>>u;
          if(s==u)cout<<a-1<<' '<<b;
          else cout<<a<<' '<<b-1;
           return 0;

        }


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int N=105;
const int inf=0x3f3f3f3f;
int n,m,S,T,cnt=1,ans,tmp;
int first[N*2],cur[N*2];
int dis[N*2],q[N*2];
char mp[N][N];
struct edge{int to,next,flow;}e[N*N*2];
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void ins(int u,int v,int f1,int f2)
{
	e[++cnt]=(edge){v,first[u],f1};first[u]=cnt;
	e[++cnt]=(edge){u,first[v],f2};first[v]=cnt;
}
bool bfs()
{
	memset(dis,-1,sizeof(dis));
	int head=0,tail=1;
	q[head]=S;dis[S]=0;
	while(head!=tail)
	{
		int u=q[head++];
		for(int i=first[u];i;i=e[i].next)
		{
			int v=e[i].to;
			if(dis[v]!=-1||!e[i].flow)continue;
			dis[v]=dis[u]+1;
			q[tail++]=v;
		}
	}
	return dis[T]!=-1;
}
int dfs(int u,int a)
{
	if(u==T||a==0)return a;
	int f,flow=0;
	for(int& i=cur[u];i;i=e[i].next)
	{
		int v=e[i].to;
		if(dis[v]==dis[u]+1&&(f=dfs(v,min(e[i].flow,a)))>0)
		{
			e[i].flow-=f;e[i^1].flow+=f;
			flow+=f;a-=f;if(a==0)break;
		}
	}
	return flow;
}
int main()
{
	n=read();m=read();S=0;T=n+m+1;
	for(int i=1;i<=n;i++)scanf("%s",mp[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(mp[i][j]=='.')continue;
			if(mp[i][j]=='S')
			{
				ins(S,i,inf,0);ins(S,n+j,inf,0);
				continue;
			}
			if(mp[i][j]=='T')
			{
				ins(i,T,inf,0);ins(n+j,T,inf,0);
				continue;
			}
			ins(i,j+n,1,1);
		}
	while(bfs())
	{
		for(int i=S;i<=T;i++)cur[i]=first[i];
		tmp=dfs(S,inf);
		if(tmp>=inf){printf("-1");return 0;}
		ans+=tmp;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Ford(i,a,b) for(int i=(a);i>=(b);--i)
#define fio(s) freopen(s".inp","r",stdin)
#define foo(s) freopen(s".out","w",stdout)
#define task "test"
using namespace std;
typedef long long LL;
const LL N=100009,OO=1e9+7;
LL n,W,f[109][N],w[N],v[N];
int main(){
    //fio(task); foo(task);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>W;
    For(i,1,n) cin>>w[i]>>v[i];
    For(i,1,n)
    For(j,1,W){
        if(w[i]>j) f[i][j]=f[i-1][j];
        else f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
    }
    cout<<f[n][W];
    return 0;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std ;
#define f(i,s,n) for(int i=s;i<n;i++)
const int MAXN = 2e5+5 ;
typedef long long ll ;
// ll arr[MAXN] ;
map<int,int> countz ;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) ;
    int n;cin>>n ;
    ll sum = 0 ;
    f(i,0,n)
    {
        int x;cin>>x ;
        sum+=x ;
        countz[x]++ ;
    }
    int q;cin>>q ;
    while(q--)
    {
        ll b,c;cin>>b>>c;
        sum-=countz[b]*b ;
        sum+=countz[b]*c ;
        countz[c]+=countz[b] ;
        countz[b] = 0 ;
        cout<<sum<<"\n" ;
    }
}

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

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define STR(s) string s;cin>>s

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  STR(s);
  int n = SZ(s), ans = 0;
  stack<char> st;
  REP(i, n){
    if(st.empty() || st.top() == s[i]){
      st.push(s[i]);
    } else {
      st.pop();
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int n;
string s,t;

int main() {
  cin >> s >> t;
  cout << t+s << endl;
}

Measured memory_bytes: 256
#include<iostream>
 
int main() {
  int N,K;
  int a[100000];
  std::cin>>N;
  std::cin>>K;
  int cnt = 0;
  for(int i=0;i<N;i++) {
    std::cin>>a[i];
    if(a[i]>=K) {
      cnt++;
    }
  }
    std::cout<<cnt<<std::endl;
  	return(0);
}


Measured memory_bytes: 640
S = str(input())
S1 = list(S)
S2 = (10*int(S[0])+int(S[1]),10*int(S[2])+int(S[3]))
if 0 < S2[0] <= 12:
    if 0 < S2[1] <= 12:
        print('AMBIGUOUS')
    elif S2[1] == 0 or S2[1] > 12:
        print('MMYY')
elif S2[0] == 0 or S2[0] > 12:
    if 0 < S2[1] <= 12:
        print('YYMM')
    elif S2[1] == 0 or S2[1] > 12:
        print('NA')

Measured memory_bytes: 3064
import sys


def resolve():
    readline = sys.stdin.readline    # 1行だけ文字列にする

    N = int(readline())
    ac, wa, tle, re = 0, 0, 0, 0
    for _ in range(N):
        judge = readline().strip()
        if judge == 'AC':
            ac += 1
        elif judge == 'WA':
            wa += 1
        elif judge == 'TLE':
            tle += 1
        elif judge == 'RE':
            re += 1
    print(f'AC x {ac}', f'WA x {wa}', f'TLE x {tle}', f'RE x {re}', sep='\n')


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9212
#include<cstdio>

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

using namespace std;

typedef long long ll;

const ll M=100000007;

int main(){
	int T[128]; // period
	T['1']=T['2']=T['3']=T['4']=T['5']=T['6']=T['7']=T['9']=5;
	T['8']=T['0']=3;

	static ll dp[6][100001];
	rep(k,2){
		int T=(k==0?5:3);
		rep(i,T+1) dp[T][i+1]=1<<i;
		for(int i=T+1;i<100000;i++) dp[T][i+1]=((2*dp[T][i]-dp[T][i-T])%M+M)%M;
	}

	for(char s[100001];scanf("%s",s),s[0]!='#';){
		ll ans=1;
		for(int i=1,p=0;s[i-1];i++) if(s[i-1]!=s[i]) {
			ans=(ans*dp[T[s[i-1]]][i-p])%M;
			p=i;
		}
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  int N;
  std::cin >> N;

  vector<double> head(N);

  for (auto& p : head)
  { 
    std::cin >> p;
  }

  vector<vector<double>> dp(head.size()+1, std::vector<double>(head.size()+1, 1.0));  

  for (size_t i = 0; i < head.size(); ++i)
  { 
    for (size_t j = 0; j < head.size(); ++j)
    { 
      if (i==0)
      { 
        dp[0][j] = head[0];
        if (j < N/2) dp[0][j] += (1.0 - head[i]);
        continue;
      }
      dp[i][j] = head[i] * dp[i-1][j];
      if (j < N/2)
      { 
        dp[i][j] += (1.0 - head[i]) * dp[i-1][j+1];
      }
    }
  } 

  std::cout << std::setprecision(10) << dp[N-1][0];

  return 0;
}

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

using namespace std;
using ll = long long;

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

	set<string> setNM;
	map<string, int> mapN;
	for (int i = 0; i < argN; ++i) {
		string temp;
		cin >> temp;

		setNM.insert(temp);
		if (mapN.find(temp) != mapN.end()) {
			mapN.at(temp)++;
		}
		else {
			mapN.emplace(temp, 1);
		}
	}

	int argM;
	cin >> argM;
	map<string, int> mapM;
	for (int i = 0; i < argM; ++i) {
		string temp;
		cin >> temp;

		setNM.insert(temp);
		if (mapM.find(temp) != mapM.end()) {
			mapM.at(temp)++;
		}
		else {
			mapM.emplace(temp, 1);
		}
	}

	int ret = 0;
	for (auto itr = setNM.begin(); itr != setNM.end(); ++itr){
		int countN = mapN.find(*itr) != mapN.end() ? mapN.at(*itr) : 0;
		int countM = mapM.find(*itr) != mapM.end() ? mapM.at(*itr) : 0;
		int tmpRet = countN - countM;
		ret = max(ret, tmpRet);
	}

	cout << ret << endl;
}

Measured memory_bytes: 256