akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
 
 typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define ll          long long
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
 
const int hell=1000000007;

int a[1000010]={0};

int power(int a,int b)
{
  if(b==0)return 1;
   int t=power(a,b/2);
   t*=t;
   t%=hell;
   if(b&1)t*=a;
   t%=hell;
   return t;
}

int inverse(int a)
{
  return power(a,hell-2);
}

void pri()
{
   a[0]=1;
   rep(i,1,1000010)
   {
    a[i]=(i*a[i-1])%hell;
   }
}


int solve()
{
  
int n;
cin>>n;
n--;
int ans=(n*(n+1))/2LL;
cout<<ans;

 return 0;

}
 

signed main()
{  int t=1;

pri();
  
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   cin.exceptions(cin.failbit);                                                                    
 
 
  /*  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);                                   
    #endif
  */
 
  clock_t time_req;
 
    // Without ung pow function
                                                                                                                   
// cin>>t;
 
    int k=1;
     
   while(t--)
     {
      // cout<<"Case #"<<k<<":"<<endl;k++;
     // cout<<endl;
      solve();
     }
        exit(0);
 
         time_req = clock() - time_req;
    cout <<endl<< "Processor time taken is "
      << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;
 
 
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000000
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
int getbit(int s, int i)
{ return (s >> i) & 1; }
int cntbit(int s)
{ return __builtin_popcountll(s); }
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}

int main()
{
     int n,a,b;
     cin>>n>>a>>b;
     cout<<min(a*n,b);



}


Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

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

int N;
vector<int> G[100005];

constexpr int DNE = -1;

int d_black[100005];
int d_white[100005];

void dfs_black(int v, int d)
{
    if(d_black[v] != DNE) return;

    d_black[v] = d;

    for(int dst : G[v]) {
        dfs_black(dst, d+1);
    }
}

void dfs_white(int v, int d)
{
    if(d_white[v] != DNE) return;

    d_white[v] = d;

    for(int dst : G[v]) {
        dfs_white(dst, d+1);
    }
}

int main()
{
    cin >> N;

    int a, b;
    while(cin >> a >> b) {
        G[a].push_back(b);
        G[b].push_back(a);
    }

    fill(begin(d_black), end(d_black), DNE);
    fill(begin(d_white), end(d_white), DNE);

    dfs_black(1, 0);
    dfs_white(N, 0);

    int n_black = 0;
    for(int i = 1; i < N+1; ++i) {
        if(d_black[i] <= d_white[i])
            ++n_black;
    }

    cout << (n_black > N/2 ? "Fennec" : "Snuke") << "\n";

    return 0;
}


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

int main()
{
  int n, ans = 0;
  cin >> n;

  for (int i = 1; i <= n; i += 2)
  {
    int cnt = 0;
    for (int j = 1; j <= n; j++)
    {
      if (i % j == 0)
      {
        cnt++;
      }
    }
    if (cnt == 8)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
s = input()[::-1]
n = len(s)
i = 0
ans = 'YES'
while i < n:
    if s[i] == 'm':
        if n - i < 5:
            ans = 'NO'
            break
        if s[i:i+5] == 'maerd':
            i += 5
            continue
        else:
            ans = 'NO'
            break
    elif s[i] == 'e':
        if n - i < 5:
            ans = 'NO'
            break
        if s[i:i+5] == 'esare':
            i += 5
            continue
        else:
            ans = 'NO'
            break
    elif s[i] == 'r':
        if n - i < 6:
            ans = 'NO'
            break
        if s[i:i+6] == 'resare':
            i += 6
            continue
        else:
            if n - i < 7:
                ans = 'NO'
                break
            if s[i:i+7] == 'remaerd':
                i += 7
                continue
            else:
                ans = 'NO'
                break
    else:
        ans = 'NO'
        break
print(ans)

Measured memory_bytes: 3316
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	int n;
	cin>>n;
	vi kaibun(10002);
	REP(i,10002){
		string s=toString(i);
		bool flag=true;
		REP(j,s.size()/2){
			if(s[j]!=s[s.size()-j-1]){
				flag=false;
				break;
			}
		}
		if(flag){
			kaibun[i]=1;
		}
	}
	int ans=0;
	REP(i,10002){
		if(n-i>=0&&kaibun[n-i]){
			ans=n-i;
			break;
		}
		if(n+i<10002&&kaibun[n+i]){
			ans=n+i;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[n-r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [a,b,c,d] = nexts(4);
  var dp = xArray(0,c+1,d+1);
  dp[a][b] = 1;
  for(var y = a; y <= c; y++){
    for(var x = b; x <= d; x++){
      dp[y][x] += dp[y-1][x] * x + dp[y][x-1] * y - mul(dp[y-1][x-1], y-1, x-1);
      dp[y][x] %= mod;
    }
  }
  return mput(dp[c][d]);
}

Measured memory_bytes: 205804
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let c: Vec<Vec<i64>> = (0..3).map(|_| (0..3).map(|_| input()).collect()).collect();

    let b1b2 = vec![c[0][0] - c[0][1], c[1][0] - c[1][1], c[2][0] - c[2][1]];
    let b2b3 = vec![c[0][1] - c[0][2], c[1][1] - c[1][2], c[2][1] - c[2][2]];
    let b3b1 = vec![c[0][2] - c[0][0], c[1][2] - c[1][0], c[2][2] - c[2][0]];
    let a1a2 = vec![c[0][0] - c[1][0], c[0][1] - c[1][1], c[0][2] - c[1][2]];
    let a2a3 = vec![c[1][0] - c[2][0], c[1][1] - c[2][1], c[1][2] - c[2][2]];
    let a3a1 = vec![c[2][0] - c[0][0], c[2][1] - c[0][1], c[2][2] - c[0][2]];

    let ok = if (b1b2[0] == b1b2[1] && b1b2[0] == b1b2[2])
        && (b2b3[0] == b2b3[1] && b2b3[0] == b2b3[2])
        && (b3b1[0] == b3b1[1] && b3b1[0] == b3b1[2])
        && (a1a2[0] == a1a2[1] && a1a2[0] == a1a2[2])
        && (a2a3[0] == a2a3[1] && a2a3[0] == a2a3[2])
        && (a3a1[0] == a3a1[1] && a3a1[0] == a3a1[2])
    {
        true
    } else {
        false
    };
    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;




int main(){
    int N;cin >> N;
    int h,m=0,ans=0;
    for (int i = 0; i < N; i++) {
        cin >> h;
        if(h>=m){
            ans++;
            m=h;
        }
    }
    cout << ans << endl;
    return 0;
}



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

ll lucas(int n){
  vector<ll> vec(n); //at(i)はi+1番目のLucas数
  rep(i,n){
    if (i == 0) vec.at(i) = 1;
    else if (i == 1) vec.at(i) = 3;
    else vec.at(i) = vec.at(i-1) + vec.at(i-2);
  }
  return vec.at(n-1);
}

int main() {
  int n;
  ll ans;
  cin >> n;
  cout << lucas(n) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * 復習
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

using P = pair<int, int>;
#define fi first
#define se second

P dif(P a, P b) {
    P ab = {a.fi - b.fi, a.se - b.se};
    P ba = {b.fi - a.fi, b.se - a.se};
    return max(ab, ba);
}

int main() {
    int n;
    cin >> n;
    P balls[n];
    for (auto &bi:balls) {
        cin >> bi.fi >> bi.se;
    }
    int ans = 0;
    map<P, int> cnt;
    for (int i=0; i<n; i++) {
        for (int j=0; j<i; j++) {
            P d = dif(balls[i], balls[j]);
            cnt[d]++;
            ans = max(ans, cnt[d]);
        }
    }
    cout << n - ans << '\n';
    return 0;
}

Measured memory_bytes: 3664
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 	first
#define s 	second
#define ll 	int
#define int 	long long
#define ld 	long double
#define pb 	push_back
#define eb 	emplace_back
#define mk 	make_pair
#define vi 	vector<int>
#define pii 	pair<int,int>
#define vpi 	vector<pii>
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
bool func(pii a,pii b)
{
    return a.s-a.f>b.s-b.f;
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n,k;
    cin>>n>>k;
    string p;
    cin>>p;

    vpi L,R;
    int trans=0;

    for(int i=0;i<n;i++)
    {   
        
        if(p[i]=='L')
        {
            int id=i;
            while(p[id]=='L'&&id<n)
            id++;

            L.pb(mk(i,id-1));
            i=id-1;

        }
    }
    for(int i=0;i<n;i++)
    {
        if(p[i]=='R')
        {
            int id=i;
            while(p[id]=='R'&&id<n)
            id++;

            R.pb(mk(i,id-1));
            i=id-1;

        }
    }

    for(int i=1;i<n-1;i++)
    {
        if(i>0&&i<n-1)
        {
            if(p[i-1]!=p[i]&&p[i]!=p[i+1])
            trans++;

            i++;
        }
    }

    sort(L.begin(),L.end(),func);
    /*for(auto it:L)
    {
        test2(it.f,it.s);
    }
    ctrl();*/
    sort(R.begin(),R.end(),func);
    /*for(auto it:R)
    {
        test2(it.f,it.s);
    }*/

    string l=p,r=p;

    for(int i=0;i<min((int)(L.size()),k);i++)
    {
        for(int j=L[i].f;j<=L[i].s;j++)
        l[j]='R';
    }
     for(int i=0;i<min((int)(R.size()),k);i++)
    {
        for(int j=R[i].f;j<=R[i].s;j++)
        r[j]='L';
    }

    /*cout<<l<<'\n';
    cout<<r<<'\n';*/
    
    int lx=0,rx=0;

    for(int i=0;i<n-1;i++)
    {
        if(l[i]==l[i+1])
        lx++;

        if(r[i]==r[i+1])
        rx++;
    }

    int g=L.size();
    g+=R.size();
    g=max(1LL,g-k-k);
    cout<<max(rx,max(lx,n-g));
    

return 0;
}

Measured memory_bytes: 2628
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,c,d=0;
    char par[200];
    char par2[200];
    scanf("%s",par);
    scanf("%s",par2);
    c=strlen(par);

  for(i=0,j=c-1;i<3;i++,j--){
    if(par[i]!=par2[j]){
            printf("NO\n");
        break;
    }
else{
d++;
}
  }
  if(d==3){
  printf("YES\n");
  }
   return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)

def resolve():
    N = int(input())
    hs = list(map(int, input().split(" ")))
    dps = [None] * N

    def rec(dest):
        if dest == 0:
            dps[dest] = 0
        if dest == 1:
            dps[dest] = abs(hs[1]-hs[0])

        if dps[dest] is None:
            dps[dest] = min(rec(dest-1)+abs(hs[dest]-hs[dest-1]), rec(dest-2)+abs(hs[dest]-hs[dest-2]))
        
        return dps[dest]

    print(rec(N-1))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 122744
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const int maxn = 100100;

int n, m;

vector<int> g[maxn];

int dp[maxn];

int ans;

int dfs(int v)
{
  if (dp[v])
    return dp[v];
  dp[v] = 1;
  for (int u: g[v])
    dp[v] = max(dp[v], dfs(u) + 1);
  ans = max(ans, dp[v]);
  return dp[v];
}

int32_t main()
{
  ios::sync_with_stdio(0); cin.tie(0);

  cin >> n >> m;

  for (int i = 0; i < m; i ++)
    {
      int v, u;
      cin >> v >> u;
      v --, u --;
      g[v].push_back(u);
    }

  for (int i = 0; i < n; i ++)
    if (!dp[i])
      dfs(i);

  cout << ans - 1 << endl;
  
  return 0;
}


Measured memory_bytes: 7552
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    //ここだけ見てね！
    public void calc()
    {
        int sx, sy, tx, ty;
        sx = cin.nextInt();
        sy = cin.nextInt();
        tx = cin.nextInt();
        ty = cin.nextInt();
        int w, h;
        w = tx - sx;
        h = ty - sy;
        string ans = "";
        ans += new string('R', w);
        ans += new string('U', h);
        ans += new string('L', w);
        ans += new string('D', h);

        ans += new string('D', 1);
        ans += new string('R', w + 1);
        ans += new string('U', h + 1);
        ans += new string('L', 1);
        ans += new string('U', 1);
        ans += new string('L', w + 1);
        ans += new string('D', h + 1);
        ans += new string('R', 1);
        Console.WriteLine(ans);
    }

    string makeString(char c, int num)
    {
        string ans = "";
        for (int i = 0; i < num; i++)
        {
            ans += c;
        }
        return ans;
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    ll n, k;
    cin>>n>>k;
    ll a[n];
    ll inv[n], less[n];
    f(i, n) cin>>a[i], inv[i] = 0ll, less[i] = 0ll;
    f(i, n) {
        for(int j = i + 1; j < n; j++) {
            if(a[i] > a[j]) inv[i]++;
        }
        f(j, n) {
            if(a[i] > a[j]) less[i]++;
        }
    }
    ll ans = 0;
    ll tt = (k * (k - 1) * 1ll)/2ll;
    tt %= mod;
    f(i, n){
        ll to = mul(k, inv[i]);
        to = add(to, mul(less[i], tt));
        ans = add(ans, to);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void change(int a,int b,int cup[3]){
    if(cup[a]==1){
        cup[a]=0;
        cup[b]=1;
    }
    else if(cup[b]==1){
        cup[b]=0;
        cup[a]=1;
    }
}


int main(int argc, const char * argv[]) {
    int cup[3]={1,0,0},i;
    char pos1,pos2;
    //printf("%d %d %d\n",cup[0],cup[1],cup[2]);
    while(scanf("%c,%c",&pos1,&pos2)!=EOF){
        if(pos1=='A'&&pos2=='B')
            change(0,1,cup);
        if(pos1=='A'&&pos2=='C')
            change(0,2,cup);
        if(pos1=='B'&&pos2=='A')
            change(1,0,cup);
        if(pos1=='B'&&pos2=='C')
            change(1,2,cup);
        if(pos1=='C'&&pos2=='B')
            change(2,1,cup);
        if(pos1=='C'&&pos2=='A')
            change(2,0,cup);
        //printf("%d %d %d\n",cup[0],cup[1],cup[2]);
    }
    for(i=0;i<3;i++){
        if(cup[i]==1){
            if(i==0)
                printf("A\n");
            if(i==1)
                printf("B\n");
            if(i==2)
                printf("C\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1752
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e3+5;
const int mod = 1e9+7;

int w;
int h;
char gr[N][N];
int dp1[2][N][N];
int dp2[2][N][N];

int main(){
    cin >> h >> w;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> gr[i][j];
        }
    }
    for(int i = h; i >= 1; i--){


        for(int j = w; j >= 1; j--){
            if(gr[i][j] == '.')
                dp1[0][i][j] = dp1[0][i][j + 1] + 1;
            else
                dp1[0][i][j] = 0;
        }
        for(int j = 1; j <= w; j++){
            if(gr[i][j] == '.')
                dp1[1][i][j] = dp1[1][i][j - 1] + 1;
            else
                dp1[1][i][j] = 0;
        }


    }
    for(int j = 1; j <= w; j++){
        for(int i = 1; i <= h; i++){
            if(gr[i][j] == '.')
                dp2[0][i][j] = dp2[0][i - 1][j] + 1;
            else
                dp2[0][i][j] = 0;
        }
        for(int i = h; i >= 1; i--){
            if(gr[i][j] == '.')
                dp2[1][i][j] = dp2[1][i + 1][j] + 1;
            else
                dp2[1][i][j] = 0;
        }
    }
    int best = 0;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int a = dp1[0][i][j] + dp1[1][i][j] - 1;
            int b = dp2[0][i][j] + dp2[1][i][j] - 2;
            best = max(best , a+b);
        }
    }
    cout << best << endl;
}


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

int main() {
  int n;
  cin >> n;
  int x[n], l[n];
  pair<int, int> p[n];
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> l[i];
    p[i].first = x[i]+l[i];
    p[i].second= x[i]-l[i];
  }
  sort(p, p+n);
  int cur = - 10e9;
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    if (cur <= p[i].second) {
      cur = p[i].first;
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
n = int(input())
ac=0
wa=0
tle=0
re=0

for i in range(n):
  s = input()
  if(s=="AC"):
    ac+=1
  elif(s=="WA"):
    wa+=1
  elif(s=="TLE"):
    tle+=1
  else:
    re+=1
    
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9212
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define Fi first
#define Se second
#define MK make_pair
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e5;
int R,C,n,Mpcnt,tot,top;
pii A[(N<<1)+10];
bool check(int x,int y){return x==0||x==R||y==0||y==C;}
int stack[(N<<1)+10];
int get(int x,int y){
	if (y==0)	return x;
	if (x==R)	return R+y;
	if (y==C)	return 2*R+C-x;
	if (x==0)	return 2*R+2*C-y;
	return 0;
}
int main(){
	R=read(),C=read(),n=read();
	for (int i=1;i<=n;i++){
		int x1=read(),y1=read(),x2=read(),y2=read();
		if (!check(x1,y1)||!check(x2,y2))	continue;
		int x=get(x1,y1),y=get(x2,y2);
		A[++tot]=MK(x,i);
		A[++tot]=MK(y,i);
	}
	sort(A+1,A+1+tot);
	for (int i=1;i<=tot;i++){
		stack[++top]=i;
		if (A[stack[top]].Se==A[stack[top-1]].Se)	top-=2;
	}
	printf(top?"NO\n":"YES\n");
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long W = Long.parseLong(sc.next());
        
        long[] w = new long[N+1]; 
        int[] v = new int[N+1]; 
         //i番目の品物までを使って合計の価値をjにするときの重さの最小値
        long[][] dp = new long[N+1][100001];
        for(int i = 0; i <= N; i++) {
            for(int j = 0; j <= 100000; j++) {
                dp[i][j] = W+1;
            }
        }
        
        dp[0][0] = 0;
        
        //A:0 B:1 C:2
        for(int i = 0; i < N; i++) {
            w[i+1] = Long.parseLong(sc.next());
            v[i+1] = Integer.parseInt(sc.next());
        }
        
        long ansj = v[1];
        dp[1][0] = 0;
        dp[1][v[1]] = w[1]; 
        
        for(int i = 2; i <= N; i++) {
            for(int j = 0; j <= 100000; j++) {
                if(j - v[i] < 0) {
                    dp[i][j] = dp[i-1][j];
                    continue;
                }
                if(j == v[i] && w[i] < dp[i-1][j]) {
                    dp[i][j] = w[i];
                    if(ansj < j) {
                        ansj = j;
                    }
                }else if(dp[i-1][j-v[i]] + w[i] <= W && dp[i-1][j-v[i]] + w[i] < dp[i-1][j]) {
                    dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
                    if(ansj < j) {
                        ansj = j;
                    }
                }else  {
                    dp[i][j] = dp[i-1][j];
                }
            }
            
        }

        System.out.println(ansj);
        
    }
    
    public static long max(long a, long b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static int max(int a, int b) {
        if(a >= b) {
            return a;
        }else {
            return b;
        }
    }
    
    public static long min(long a, long b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
    
    public static int min(int a, int b) {
        if(a >= b) {
            return b;
        }else {
            return a;
        }
    }
}

Measured memory_bytes: 127968
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <cmath>
using namespace std;
int main(void) {
	int  table[6][2] = { {2,380},{3,550},{5,850 },{10,1520},{12,1870},{15,2244} };
	int dp[53],buf;
	fill(dp, dp+53, 0xfffffff);
	dp[0] = 0;
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 51; j++) {
			if (j >= table[i][0]) {
				dp[j] = min(dp[j], dp[j - table[i][0]] + table[i][1]);
			}
		}
	}
	for (;;) {
		cin >> buf;
		if (buf == 0)return 0;
		cout << dp[buf/100] << endl;

	}
	
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;
class Program{

}
class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String ip[];
        int i,no,N = in.nextInt(); int M = in.nextInt();
        boolean K[][]= new boolean[N][M];
        for(int n = 0;n<N;n++){
            no = in.nextInt();
            while(no-->0){
                K[n][in.nextInt()-1] = true;
            }
        }
        //for(boolean[] var: K) System.out.println(Arrays.toString(var));
        int count = 0,local=0;
        for(i =0;i<M;i++){
            local = 0;
            for(int j=0;j<N;j++){
                if (!K[j][i]){
                    break;
                }
                local++; 
            }
            if (local==N) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23596
#include<stdio.h>
const int sz=200000;
inline long long IN(void)
{
  long long x=0,f=1;char c=getchar();
  while(c<'0'||c>'9'&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(c>='0'&&c<='9')x=x*10+c-48,c=getchar();
  return f*x;
}
void OUT(int x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  int N,i,j,x,A[sz]={0},here[sz]={0},town[sz]={0};
  long long K;
  N=IN(),K=IN();
  for(i=0;i<N;i++)A[i]=IN(),here[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return OUT(town[K]+1),0;
}

Measured memory_bytes: 3876
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
vc = 0

for j in range(N):
  if V[j] - C[j] > 0:
    vc = vc +( V[j] - C[j] )

print(vc)

Measured memory_bytes: 9036
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <cstring>

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

using namespace std;
typedef long long ll;


int main(){
    
    int N,X,T;
    
    cin>>N>>X>>T;
    
    if(N%X==0){
        cout<<(N/X)*T<<endl;
    }else{
        cout<<(N/X+1)*T<<endl;
    }
    

}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	string s;
	cin >> s;
	int cnt = 0;
	for(auto x:s)cnt += x-'0';
	if(cnt%9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://abc174.contest.atcoder.jp/tasks/abc174_b
// rm -r -f test;oj d https://atcoder.jp/contests/abc176/tasks/abc176_a

Measured memory_bytes: 3724
N = int(input())
n = [input() for i in range(N)]
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for i in n:
    if i == 'AC':
        count_AC += 1
    elif i == 'WA':
        count_WA += 1
    elif i == 'TLE':
        count_TLE += 1
    elif i == 'RE':
        count_RE += 1
print('AC x {0}\nWA x {1}\nTLE x {2}\nRE x {3}'.format(count_AC, count_WA, count_TLE, count_RE))

Measured memory_bytes: 16200
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int N,M;
bool match(int a, int b, int p){
	int flag=0;
	for(int i=pow(2,N);i>0;i/=2){
		if(a>=i && b>=i)flag++;
		a = a%i;
		b = b%i;
	}
	return p == flag%2;
}

int main(void){
	int s[10],p[10];
	cin>>N>>M;
	rep(i,M){
		int tmp;
		cin>>tmp;
		s[i] = 0;
		rep(j,tmp){
			int tmp2;
			cin>>tmp2;
			s[i]+=pow(2,tmp2-1);
		}
	}

	rep(i,M)cin>>p[i];
	int ans=0;
	rep(i,pow(2,N)){
		rep(j,M){
			if(!match(s[j],i,p[j]))break;
			if(j==M-1)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    d = list(map(int, input().split()))

    result = 0
    for i in range(n):
        if i == n - 1:
            break
        for j in range(i + 1, n):
            result += d[i] * d[j]

    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
        cout << "a > b" << endl;
    else if (a < b)
        cout << "a < b" << endl;
    else 
        cout << "a == b" << endl;

 

}



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

int main(){
    int n,sum=0;cin>>n;int b[n-1];
    for(int i=0;i<n-1;i++) cin>>b[i];
    sum+=b[0];
    for(int i=0;i<n-2;i++) sum+=min(b[i],b[i+1]);
    sum+=b[n-2];
    cout<<sum<<endl;
}

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

int main()
{
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
ans = 0
for i in range(n):
    a.append(tuple(map(int,input().split())))
for i in range(n-1):
    for j in range(i+1,n):
        ans += ((a[i][0] - a[j][0])**2 + (a[i][1] - a[j][1])**2)**0.5
print(ans*2/n)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n;
    cin >> n;
    ll e=pow(2,n);
    int ans=0;
    vector<vector<pp>> a(n,vector<pp>(0));
    rep(i,n){
        int f;
        cin >> f;
        rep(j,f){
            int g,h;
            cin >> g >> h;
            a[i].push_back(mk(g-1,h));
        }
    }
    rep(i,e){
        bool u=true;
        int c=0;
        ll w=i;
        vector<int> t(n,0);
        rep(j,n){
            if ((w&1)==1){
                c++;
                if (t[j]==-1){
                    u=false;
                    break;
                }
                t[j]=1;
                rep(k,a[j].size()){
                    if (a[j][k].second==1) {
                        if (t[a[j][k].first]==-1) u=false;
                        t[a[j][k].first]=1;
                    }
                    else {
                        if (t[a[j][k].first]==1) u=false;
                        t[a[j][k].first]=-1;
                    }
                }
            }
            else {
                if (t[j]==1){
                u=false;
                break;
            }
            t[j]=-1;
        }
        w/=2;
        }
        if (u) ans=max(ans,c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
	long long a,b,c,m,n,ans=0;

int main() {
	cin>>a>>b>>c;
	if(a==0){	
		ans=1;
		a = 1;
	}
	n=b/c;
	m=(a-1)/c;
	ans+=n-m;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() 
{
	long long N,X,T;cin>>N>>X>>T;
	int sum_X=0;
	int sum_T=0;
	while(sum_X<N){
		sum_X+=X;
		sum_T+=T;
	}
	
	cout<<sum_T;
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
    using namespace std;
    int main(){
      string str[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
      string str1;
      cin>>str1;
      for(int i=0;i<7;i++)
        if(str[i]==str1){
          cout<<7-i<<endl;
          break;
        }
      return 0;   
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int const MOD = 1000000007;

Int dp[100001][13];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    string s; cin>>s; int n=s.size();
    dp[0][0]=1;
    int md[100001]; md[0]=1;
    for (int i = 1; i < 100001; i++){
        md[i]=md[i-1]*10%13;
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < 13; j++){
            if(s[n-i-1]=='?'){
                for (int k = 0; k < 10; k++){
                    dp[i+1][(md[i]*k+j)%13]=(dp[i][j]+dp[i+1][(md[i]*k+j)%13])%MOD;
                }
            }else dp[i+1][(md[i]*(s[n-i-1]-'0')+j)%13]=(dp[i][j]+dp[i+1][(md[i]*(s[n-i-1]-'0')+j)%13])%MOD;
        }
    }
    cout<<dp[n][5]<<'\n';
}

Measured memory_bytes: 11088
n = int(input())

def prime_fact(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a  

ps = prime_fact(n)
current = 0
num = 0
tmp_c = 0
cnt = 0
if ps:
  for i in range(len(ps)):
    if ps[i] != current:
      num = 2
      tmp_c = 0
      cnt += 1
      current = ps[i]
    else:
      tmp_c += 1
      if tmp_c == num:
        cnt += 1
        tmp_c = 0
        num += 1
  print(cnt)
else:
  print(0)

Measured memory_bytes: 9264
# coding: utf-8
# Your code here!
from collections import deque

N = int(input())
a = deque(list(map(int, input().split())))
tmp_a = []
tmp_c = 0
tmp_n = 0
ctr = 0

for i in range(N):
    tmp_n = a.popleft()
    if tmp_a == [] or tmp_a[-1] == tmp_n:
        tmp_c += 1
    else:
        ctr += tmp_c // 2
        tmp_c = 1
        tmp_a.clear()
    tmp_a.append(tmp_n)
    if a == deque([]) and tmp_a[-1] == tmp_n:
        ctr += tmp_c // 2
print(ctr)

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

int main(){
    int x, y, z, k;
    scanf("%d %d %d %d", &x, &y, &z, &k);
    long long xv[x];
    long long yv[y];
    long long zv[z];
    for(int i = 0; i < x; i++){
        scanf("%lld", &xv[i]);
    }
    sort(xv, xv+x);
    for(int i = 0; i < y; i++){
        scanf("%lld", &yv[i]);
    }
    sort(yv, yv+y);
    for(int i = 0; i < z; i++){
        scanf("%lld", &zv[i]);
    }
    sort(zv, zv+z);
    priority_queue<pair<pair<long long, int>, pair<int, int> > > pq;
    int worstx[y][z]; //worst x that has been served for this y-z combo
    for(int i = 0; i < y; i++){
        for(int j = 0; j < z; j++){
            worstx[i][j] = x;
        }
    }
    pq.push(make_pair(make_pair(xv[x-1]+yv[y-1]+zv[z-1], x-1), make_pair(y-1, z-1)));
    for(int i = 0; i < k; i++){
        long long v = pq.top().first.first;
        int px = pq.top().first.second;
        int py = pq.top().second.first;
        int pz = pq.top().second.second;
        pq.pop();
        //printf("::%lld\n", v);
        if(worstx[py][pz] <= px){
            i--;
            continue;
        }
        printf("%lld\n", v);
        worstx[py][pz] = px;
        if(px!=0)pq.push(make_pair(make_pair(xv[px-1]+yv[py]+zv[pz], px-1), make_pair(py, pz)));
        if(py!=0)pq.push(make_pair(make_pair(xv[px]+yv[py-1]+zv[pz], px), make_pair(py-1, pz)));
        if(pz!=0)pq.push(make_pair(make_pair(xv[px]+yv[py]+zv[pz-1], px), make_pair(py, pz-1)));
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define show2(x,y) cout<<#x" = "<<x<<" "<<#y<<" = "<<y<<endl;
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a,b,u;
    unsigned ac,bc;
    cin>>a>>b;
    cin>>ac>>bc;
    cin>>u;
    ac-=(u==a);
    bc-=(u==b);
    cout<<ac<<" "<<bc;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

A = []
B = []
for n in range(N):
    A.append(str(input()))
for m in range(M):
    B.append(str(input()))

count = 0
for i in range(len(B)):
    if B[i] in A[i]:
        count += 1
    else:
        count += 0

if count == len(B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(x,l,r) for(int x=l,x##_=r;x<=x##_;x++)
#define FR(x,l,r) for(int x=l,x##_=r;x<x##_;x++)
#define DOR(x,r,l) for(int x=r,x##_=l;x>=x##_;x--)
using namespace std;
const int N=100005;
const LL P=1e9+7;
char str[N];
int cnt[30],len;
int main() {
	scanf("%d",&len);
	scanf("%s",str+1);
	FOR(i,1,len)cnt[str[i]-'a'+1]++;
	LL ans=1;
	FOR(i,1,26)(ans*=cnt[i]+1)%=P;;
	printf("%lld\n",ans-1);
	return 0;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout <<Z << " " << X << " " << Y<< endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main() {

	string s;
	cin >> s;

	for (int i = 0; i < s.length() - 1; i++) {
		for (int j = i+1; j < s.length(); j++) {
			if (s[i] == s[j]) {
				cout << "no" << Endl;
				return 0;
			}
		}
	}
	cout << "yes" << Endl;

	return 0;
}

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


using namespace std;

int main(void) {
    
    
    //A^5 - B^5　と　(-B)^5 - (-A)^5　は等しい
    //つまり、(A,B)=(3,4),(-4,-3)は答えが等しくなるので、どちらかを考えれば良い
    //つまりA>0で固定できる
    
    //cout << "test" << endl;
    
    
    long int A; //A>0
    long int B;
    long int a;
    long int b;
    
    long int x;
    cin >> x;
    
    
    for (A = 0; A < 1000; A++) {
        for (B = 0; B < 1000; B++) {
            
            a = A*A*A*A*A;
            b = B*B*B*B*B;
            
            if (x == (a-b) ) {
                
                cout << A << " " << B << endl;
                //cout << a << " " << b << endl;
                return 0;
                
            } else if ( x == (a+b) ){
                
                cout << A << " " << -B << endl;
                //cout << a << " " << -b << endl;
                return 0;
                
            }
                       
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
const int N=110;
int n,a[N],c[N],ans,g,de[N];
inline void dfs(int x,int sum,int g){
	if (g+sum<=ans) return;
	if (x==n+1) {ans=sum;return;}
	if (de[x]) {dfs(x+1,sum,g);return;}
	if (x+x>n) {dfs(x+1,sum+c[x],g-c[x]);return;}
	dfs(x+1,sum+a[x],g-c[x]);
	for (int i=x;i<=n;i+=x) if (!de[i]++) g-=c[i]; 
	dfs(x+1,sum,g);	
	for (int i=x;i<=n;i+=x) --de[i];	
}
main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]),g+=c[i]=max(a[i],0ll);
	dfs(1,0,g);
	printf("%lld",ans);
	return 0;
}

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

const int mask = (1<<25) - 1;
unordered_map<int,int> memo;

int n;
int trnas[1<<25];

inline bool isInfected(int y, int x, const vector<string> &g){
  int cnt = 0;
  rep(i,3)rep(j,3){
    int ny = y+i-1, nx = x+j-1;
    if(i==1 && j==1)continue;
    if(!range(ny,0,n) || !range(nx,0,n))continue;
    if(g[ny][nx] == '#')cnt++;
  }

  if(cnt == 3)return true;
  if(g[y][x] == '#' && cnt==2)return true;
  return false;
}

inline int encode(int y, int x, const vector<string> &g){
  int res = 0;
  rep(i,n)rep(j,n){
    if(g[i][j] == '#')res |= 1<<(i*n+j);
  }
  res |= (y*n+x)<<25;
  return res;
}

inline void decode(int c, vector<string> &g){
  rep(i,n)rep(j,n){
    if( (c>>(i*n+j))&1 )g[i][j] = '#';
    else g[i][j] = '.';
  }
}

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

  while(cin >> n, n){
    vector<string> a(n);
    int y = 0,x = 0;
    rep(i,n){
      cin >> a[i];
      rep(j,n){
	if(a[i][j] == '@'){
	  y = i; x = j; a[i][j] = '.';
	}
      }
    }

    int cur = encode(y,x,a);
    memo.clear();
    memo[cur] = 0;
    queue<int> q;
    q.push(cur);

    int ans = -1;
    while(q.size()){
      cur = q.front(); q.pop();
      if( (cur & mask) == 0){
	ans = memo[cur]; break;
      }

      decode(cur,a);
      y = (cur>>25)/n, x = (cur>>25)%n;

      rep(ii,3)rep(jj,3){
	int ny = y + ii-1, nx = x + jj-1;
	if(ii==1 && jj==1)continue;
	if(!range(ny,0,n) || !range(nx,0,n))continue;
	if(a[ny][nx] == '#')continue;

	a[ny][nx] = '#';

	int nxt = (ny*n+nx) << 25;
	rep(i,n)rep(j,n){
	  if(isInfected(i,j,a) && (ny!=i||nx!=j))nxt |= 1<<(i*n+j);
	}
	if(memo.count(nxt)==0){
	  memo[nxt] = memo[cur]+1;
	  q.push(nxt);
	}

	a[ny][nx] = '.';
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 2060