akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,m;cin>>n>>m;

    VVI s(m);
    REP(i,m){
        int k;cin>>k;
        s[i].resize(k);
        REP(j,k){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    VI p(m);
    REP(i,m){
        cin>>p[i];
    }

    int result = 0;
    REP(bit,(1<<n)){
    //for (int bit = 0; bit < (1<<n); ++bit){
        //dump(bit)
        int on = 0;
        REP(i,m){
            //dump(i)
            int count = 0;
            for(auto x : s[i]){
                if (bit & (1<<x)){
                    count++;
                } 
            }
            if(count%2 == p[i]){
                on++;
            }
            //dump(count)
        }
        if(on == m){
            result++;
        }
    }

    cout<<result<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
vector<int>a,b;
int f[maxn];
int d[maxn];
bool cmp(int x,int y){
	return f[x]>f[y];
}
bool cmp1(int x,int y){
	return d[x]>d[y];
}
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		if(i&1){
			if(!f[x]) a.push_back(x);
			f[x]++;
		}else{
			if(!d[x]) b.push_back(x);
			d[x]++;
		}
	}
	a.push_back(0);
	b.push_back(0);
	sort(a.begin(),a.end(),cmp);
	sort(b.begin(),b.end(),cmp1);
	int ans=0;
	if(a[0]==b[0]){
		ans=max(f[a[0]]+d[b[1]],f[a[1]]+d[b[0]]);
	}else{
		ans=f[a[0]]+d[b[0]];
	}
	cout<<n-ans;
	return 0;
}


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

using namespace std;

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

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

  for (int i=0; i<N-1; i++) {
    int x;
    cin >> x;
    A.at(x)++;
  }
  for (int i=1; i<=N; i++) {
    cout << A[i] << endl;
  }
  
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> flag(n);

    flag[0] = 1;

    for (auto i = 1; i < n; i++)
    {
        if(s[i] == s[i-1]){
            flag[i] = 0;
        }else{
            flag[i] = 1;
        }
    }
    


    cout << accumulate(flag.begin(), flag.end(), 0) << endl;
}

Measured memory_bytes: 896
N = int(input())
A = list(map(int, input().split()))

B = A.copy()

K = 0

for i in range (0, N):
	if A[i] < 0:
		B[i] = -1*B[i]
		K+=1

Tashita = sum(B)

if K%2 != 0:
	Tashita-=2*min(B)

print(Tashita)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<ll> a(n);
    vector<ll> cnt((int) 1e5 + 10);
    ll res = 0;
    for (ll &x : a) {
        cin >> x;
        cnt[x]++;
        res += x;
    }
    int q; cin >> q;
    while (q--) {
        ll b, c; cin >> b >> c;
        res -= cnt[b] * b;
        res += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << res << "\n";
    }
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
  } else {
    bool flag = true;
    REP(i, n / 2) {
      if (s[i] != s[i + n / 2]) {
        flag = false;
        break;
      }
    }
    if (flag) cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

int main() {
 int N;
  cin>>N;
  vector<int> a(N+1);
  for (int &x: a) cin>>x;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A=0,B=0;
  for(int i=0;i<N;i+=2) A+=a[i],B+=a[i+1];
  cout<<A-B<<endl;
}
  




Measured memory_bytes: 256
def update_vrs(vrs, idx, s):
    if idx == 0:
        vrs[s[0]] += 1
        vrs[s[1]] -= 1
    elif idx == 1:
        vrs[s[0]] -= 1
        vrs[s[1]] += 1
    else:
        raise ValueError()


def process1(vrs, lst_s):
    selects = []
    for s in lst_s:
        if vrs[s[0]] == 0 and vrs[s[1]] == 0:
            return False, None
        elif vrs[s[0]] == 0:
            selects.append(s[0])
            update_vrs(vrs, 0, s)
        else:  # when vrs[s[1]] == 1:
            selects.append(s[1])
            update_vrs(vrs, 1, s)
    return True, selects


def process2(vrs, lst_s):
    selects = []
    for i, s in enumerate(lst_s):
        if vrs[s[0]] == 0 and vrs[s[1]] == 0:
            return False, None
        elif vrs[s[0]] == 0:
            selects.append(s[0])
            update_vrs(vrs, 0, s)
        elif vrs[s[1]] == 0:
            selects.append(s[1])
            update_vrs(vrs, 1, s)
        else:
            if i == len(lst_s) - 1:
                selects.append(s[0])
            else:
                next_s = lst_s[i + 1]
                if s[0] in next_s:
                    selects.append(s[0])
                    update_vrs(vrs, 0, s)
                else:
                    selects.append(s[1])
                    update_vrs(vrs, 1, s)
    return True, selects


def main():
    vrs = {}
    n, vrs['A'], vrs['B'], vrs['C'] = [int(v) for v in input().split(' ')]
    lst_s = []
    for _ in range(n):
        lst_s.append(input().strip())

    sum_abc = vrs['A'] + vrs['B'] + vrs['C']

    if sum_abc == 0:
        ans = False
    elif sum_abc == 1:
        ans, selects = process1(vrs, lst_s)
    else:
        ans, selects = process2(vrs, lst_s)

    if ans is True:
        print('Yes')
        for s in selects:
            print(s)
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 17076
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef long long ll;

int calcDigits(ll n){
    int i = 0;
    while(n/10 > 0){
        i++;
        n/=10;
    }
    return ++i;
}

int main(){
    ll N;
    cin >> N;
    int res;
    for (ll i=1;i<=sqrt(N);i++){
        if(N%i == 0){
            res = max(calcDigits(i), calcDigits(N/i));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> hs(n); cin >> hs;
    int ans = 0, cnt = 0;
    for(int i = 1; i < n; i++){
        if(hs[i - 1] >= hs[i]){
            cnt++;
        }else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << '\n';
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int MAXN = 3e5 + 10;

struct Lik {
  int id, val;
  int x, y, z;

  Lik() {}
  Lik(int _x, int _y, int _z) {
    x = _x;
    y = _y;
    z = _z;
  }

  friend bool operator < (const Lik &A, const Lik &B) {
    if (A.val == B.val)
      return A.id < B.id;
    return A.val > B.val;
  }
};

bool minA, minB;
bool used[MAXN];

int A, B, C, N;

vector <Lik> L;
set <Lik> S_up, S_down;

inline bool cmpyz(const Lik &A, const Lik &B) {
  return A.x - A.y > B.x - B.y;
}

int main(void) {
  scanf("%d%d%d", &A, &B, &C);
  N = A + B + C;

  if (A <= B && A <= C) {
    minA = true;
    swap(A, C);
  }

  if (!minA && B <= A && B <= C) {
    minB = true;
    swap(B, C);
  }

  for (int i = 0; i < N; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (minA) swap(x, z);
    if (minB) swap(y, z);
    L.emplace_back(x, y, z);
  }

  sort(L.begin(), L.end(), cmpyz);
  for (int i = 0; i < N; ++i) {
    L[i].id = i;
    if (i < A) {
      L[i].val = L[i].z - L[i].x;
      S_up.insert(L[i]);
    } else {
      L[i].val = L[i].z - L[i].y;
      S_down.insert(L[i]);
    }
  }

  int border = A, best_border = A;
  llint sol = 0;

  int cnt = 0;
  for (auto &it : S_down) {
    if (cnt < C) {
      sol += (llint) it.val;
    } else {
      S_down.erase(S_down.find(it), S_down.end());
      break;
    }
    ++cnt;
  }

  llint sum_down = sol, sum_up = 0, rest = 0;

  for (int i = 0; i < N; ++i)
    if (i < border)
      rest += (llint) L[i].x;
    else
      rest += (llint) L[i].y;

  sol += rest;

  for (int i = 1; i <= C; ++i) { // fix za gornji dom
    auto it = S_down.find(L[border]);
    if (it != S_down.end()) {
      sum_down -= (llint) it->val;
      S_down.erase(it);
    } else {
       auto it = S_down.end();
       it--;
       sum_down -= (llint) it->val;
       S_down.erase(it);
    }
    sum_up += (llint) S_up.begin()->val;
    S_up.erase(S_up.begin());
    rest -= (llint) L[border].y;
    rest += (llint) L[border].x;
    if (sum_down + sum_up + rest > sol) {
      sol = sum_down + sum_up + rest;
      best_border = border + 1;
    }
    L[border].val = L[border].z - L[border].x;
    S_up.insert(L[border]);
    ++border;
  }

  printf("%lld\n", sol);

  return 0;
}


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

int main(){
    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout.precision(12);
    
    int n, m;
    vector<int> edges[600];
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int s, t;
        cin >> s >> t;
        edges[s-1].push_back(t-1);
    }

    double p[600], e[600];
    for(int i=0;i<n;++i) p[i] = e[i] = 0.0;
    p[0] = 1.0;
    for(int i=0;i+1<n;++i){
        for(auto to: edges[i]){
            p[to] += p[i] / edges[i].size();
        }
    }
    e[n-1] = 0.0;
    for(int i=n-2;i>=0;--i){
        for(auto to: edges[i]){
            e[i] += (1.0 + e[to]) / edges[i].size();
        }
    }

    double sum[600];
    for(int i=0;i+1<n;++i){
        sum[i] = 0.0;
        for(auto to: edges[i]){
            sum[i] += e[to] + 1.0;
        }
    }

    double best_diff = 0.0;
    for(int i=0;i+1<n;++i){
        if(edges[i].size() <= 1) continue;
        for(auto to: edges[i]){
            best_diff = min(best_diff,
                p[i]/edges[i].size() * ((sum[i]-e[to]-1.0)/(edges[i].size()-1) - (e[to]+1.0))
            );
        }
    }

    cout << e[0] + best_diff << endl;
    return 0;
}

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

int N, K; string S;

int main() {
	cin >> N >> S >> K; K--;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != S[K]) S[i] = '*';
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = (a); i <= (b); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

string s;
int pal (int i, int j) {
	while (i < j) {
		if (s[i] != s[j]) return 0;
		i++, j--;
	}
	return 1;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	if (pal(0, s.size() - 1) && pal(0, (s.size() - 1) / 2 - 1) && pal((s.size() + 3) / 2 - 1, s.size() - 1))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int hantei(int);

main(){
  int data[12];
  int y1, m1, d1, y2, m2, d2, i, j, k, f, ans, c, p;

  for(i=0;i<12;i++){
    if(i==0 || i==2 || i==4 || i==6 || i==7 || i==9 || i==11) data[i]=31;
    else if(i==1) data[i]=28;
    else data[i]=30;
  }

  while(1){
    scanf("%d %d %d %d %d %d", &y1, &m1, &d1, &y2, &m2, &d2);
    if(y1==-1 && m1==-1 && d1==-1 && y2==-1 && m2==-1 && d2==-1) break;

    ans=0;

    for(i=1;i<=12;i++){
      if(i>m1) break;
      for(j=1;j<=31;j++){
	if(hantei(y1)==1){
	    if(i==2){
	      if(data[i-1]+1<j) break;
	    }
	    else if(data[i-1]<j){
	      break;
	    }
	  }
	else if(data[i-1]<j) break;
	if(j==d1 && i==m1) break;
	ans--;
      }
    }
    
    for(i=1;i<=12;i++){
      if(i>m2) break;
      for(j=1;j<=31;j++){
	if(hantei(y2)==1){
	    if(i==2){
	      if(data[i-1]+1<j) break;
	    }
	    else if(data[i-1]<j){
	      break;
	    }
	  }
	  else if(data[i-1]<j) break;
	  if(j==d2 && i==m2) break;
	  ans++;
	}
    }

    for(i=y1;i<y2;i++){
      if(hantei(i)==1) ans+=366;
      else ans+=365;
    }

    printf("%d\n", ans);
  }
  return 0;
}

int hantei(int x){
  if(x%4==0){
    if(x%100==0){
      if(x%400==0) return 1;
      return 0;
    }
    return 1;
  }
  return 0;
}

Measured memory_bytes: 0
#pragma warning(disable:4996)


#include<stdio.h>
#include<string.h>

int main(void) {
	char  a[256], b[256], c[256];
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	memset(c, 0, sizeof(c));
	int count = 0;
	scanf("%c%c%c", a, b, c);
	if (strcmp(a , "R")==0&&strcmp(b , "R")==0&&strcmp(c , "R")==0) {
		count = count + 3;;
	}
	else if (strcmp(a, "R") == 0 && strcmp(b, "R")==0) {
		count = count + 2;
	}
	else if (strcmp(a, "R") == 0 && strcmp(c, "R") == 0) {
		count++;
	}
	else if (strcmp(b, "R") == 0 && strcmp(c, "R") == 0) {
		count = count + 2;
	}
	else if (strcmp(a, "R") == 0 || strcmp(b, "R") == 0 || strcmp(c, "R") == 0) {
		count++;
	}

	printf("%d", count);

	return 0;
}

Measured memory_bytes: 1668
use std::io::BufRead;
use std::io::BufReader;

fn main() {
    let mut buf = BufReader::new(std::io::stdin());

    let mut n = String::new();
    let mut s = String::new();
    buf.read_line(&mut n).unwrap();
    buf.read_line(&mut s).unwrap();
    let n = n.trim().parse::<u8>().unwrap();

    let a = 0x41;
    let z = 0x5a;

    let ans: String = s.trim().chars().map(|ch| {
        let ascii = ch as u8;
        if ascii + n > z {
            (ascii + n - z + a - 1) as char
        } else {
            (ascii + n) as char
        }
    }).collect();

    println!("{}", ans);
}


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

public class Main {
  private static int score(int x) {
    switch(x) {
      case 1:
        return 300000;
      case 2:
        return 200000;
      case 3:
        return 100000;
      default:
        return 0;
    }
  }
  
  private static int solve(int x, int y) {
    if (x == 1 && y == 1) {
      return 1_000_000;
    }
    return score(x) + score(y);
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x = reader.nextInt();
    int y = reader.nextInt();
    out.println(solve(x, y));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 24788
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, d;
int t[100010], x[100010], y[100010];
long long abs(long long a){
	if(a>=0) return a;
	else return -a;
}

int main(){
	cin>>n;
	d=1;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(i=1;i<=n;i++){
		cin>>t[i]>>x[i]>>y[i];
		m=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		k=t[i]-t[i-1]-m;
		if(k>=0&&k%2==0);
		else d=0;
	}
	if(d) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int pc[500010],FULL;
LL C[55][55],ans;
int n,K,S,T,m,a[500010];
int main(){
	pc[0]=0;
	FOR(i,1,500000) pc[i]=pc[i>>1]+(i&1);
	C[0][0]=1;
	FOR(i,1,50){
		C[i][0]=1;
		FOR(j,1,i) C[i][j]=(C[i-1][j]+C[i-1][j-1]);
	}
	FOR(i,0,50)
		FOR(j,1,50) C[i][j]+=C[i][j-1];
	cin>>n>>K>>S>>T;
	if ((S&T)!=S) return puts("0"),0;
	FOR(i,1,n){
		int x;
		scanf("%d",&x);
		if ((S&x)!=S) continue;
		if ((x&T)!=x) continue;
		a[++m]=x;
	}
	n=m;
	FULL=(1<<18)-1;
	FOR(i,1,n){
		int nd=S^T;
		FOR(j,0,FULL) if ((j&nd)==j){
			int t=0;
			FOR(k,i+1,n) if ( ( j & (a[k]^a[i])) == 0 ) ++t;
			if (pc[j]&1) (ans-=C[t][K-1]);
			else (ans+=C[t][K-1]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5692
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int64_t A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    int64_t D = abs(A - B);

    if (V > W && (V - W) * T >= D)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
}


Measured memory_bytes: 3640
import sys

n, y = [int(m) for m in input().split(" ")]

for i in range(n+1):
	bill_10000 = 10000 * i
	for j in range(n-i+1):
		bill_5000 = 5000 * j
		k = n-i-j
		bill_1000 = 1000 * k
		
		sum_price = bill_10000 + bill_5000 + bill_1000
		# print(sum_price)
		# print(i, j, k, sum((i, j, k)))
		if y == sum_price:
			print(i, j, k)
			sys.exit()

print(-1, -1, -1)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < b){
			System.out.println("a < b");
		}
		else if(a > b){
			System.out.println("a > b");
		}
		else
			System.out.println("a == b");
		sc.close();
		}
	}


Measured memory_bytes: 26236
#include <iostream>
#include <string>
 
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
 
int mainC()
{
	string str;
	cin >> str;
	int n = stoi(str);
	map<string, long long> strMap;
  	map<string, int> strMap2;
	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		sort(str.begin(), str.end());
		strMap[str]++;
      	strMap2[str]++;
	}
 
	long long m = 0;
	for (const auto& x : strMap)
	{
		auto k = x.second;
      	auto k2 = strMap2.find(x.first)->second;
      	if(k != k2)
          return 0;
		if(k > 1)
			m += (k - 1) * k;
	}
	m /= 2;
	cout << m << endl;
	return 0;
 
}
 
int main()
{
	return mainC();
}


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

int main()
{
    int N;
    cin >> N;
    int a[N], aSorted[N];
    for(int i = 0; i < N; i++)
    {
        cin >> a[i];
        aSorted[i] = a[i];
    }
    sort(aSorted, aSorted+N);

    map<int, int> iMap;
    for(int i = 0; i < N; i++)
        iMap[aSorted[i]] = i;

    for(int i = 0; i < N; i++)
        a[i] = iMap[a[i]];
    
    int ans = 0;
    for(int i = 0; i < N; i+=2)
        if (a[i] % 2 == 1)
            ans++;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);

	private void doit(){
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0)break;
			int [][] data = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					data[i][j] = sc.nextInt();
				}
			}
			int [][] pic = new int[m][m];
			for(int i = 0; i < m; i++){
				for(int j = 0; j < m; j++){
					pic[i][j] = sc.nextInt();
				}
			}
			
			int [][][] pics = rotate(pic);
			
			int x = 1 << 24, y = 1 << 24;
			for(int i = 0; i < n - m + 1; i++){
				for(int j = 0; j < n - m + 1; j++){
					for(int dir = 0; dir < 4; dir++){
						if(check(data, pics[dir], i, j)){
							int [] res = find(pics[dir]);
							res[0] += j;
							res[1] += i;
							
							if(res[1] < y){
								y = res[1];
								x = res[0];
							}
							else if(res[1] == y && res[0] < x){
								y = res[1];
								x = res[0];
							}
						}
					}
				}
			}
			if(x == 1 << 24){
				System.out.println("NA");
			}
			else{
				System.out.println(x + " " + y);
			}
		}
	}
	
	private int[] find(int[][] pic) {
		int m = pic.length;
		int [] res = new int[2];
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				if(pic[i][j] != -1){
					res[0] = j + 1;
					res[1] = i + 1;
					return res;
				}
			}
		}
		return null;
	}

	private boolean check(int[][] data, int[][] pic, int y, int x) {
		int m = pic.length;
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				if(pic[i][j] == -1) continue;
				if(pic[i][j] != data[i + y][j + x]){
					return false;
				}
			}
		}
		return true;
	}
	
	private int[][][] rotate(int [][] data){
		int n = data.length;
		int [][][] mlist = new int[4][n][n];
		for(int i = 0 ; i < n; i++){
			for(int j = 0 ; j < n; j++){
				mlist[0][i][j] = data[i][j];
			}
		}
		for(int  i = 1 ; i < 4; i++){
			for(int y = 0 ; y < n; y++){
				for(int x = 0; x < n; x++){
					mlist[i][x][n- y - 1] = mlist[i-1][y][x];
				}
			}
		}
		return mlist;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 73072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    stack<ll> st;
    vector<pair<ll, ll>> puddle;
    REP(i, s.size()){
        const char c = s.at(i);
        if(c == '_'){
            // nothing to do
        }else if(c == '\\'){
            st.push(i);
        }else if(st.size()){
            assert(c == '/');
            const ll left = st.top(); st.pop();
            ll area = i - left;
            while(!puddle.empty() && puddle.back().first > left){
                area += puddle.back().second;
                puddle.pop_back();
            }
            puddle.emplace_back(left, area);
        }
    }

    ll total = 0;
    for(auto p : puddle){
        total += p.second;
    }
    cout << total << endl;
    cout << puddle.size();
    for(auto p : puddle){
        cout << " " << p.second;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3260
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

s = input()
if s in ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]:
    print('a')
else:
    print('A')

Measured memory_bytes: 72600
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 101000
using namespace std;
int ans=0,n,k,a[N],nxt[N],last[N],to[N],deep[N],tot=0;
void putin(int x,int y)
{
	if(y==1) return;
	nxt[++tot]=last[x];last[x]=tot;to[tot]=y;
}
void dg(int x)
{
	deep[x]=1;
	for(int i=last[x];i;i=nxt[i])
	{
		int y=to[i];
		dg(y);deep[x]=max(deep[x],deep[y]+1);
	}
	if(deep[x]>=k&&a[x]!=1)
	{
		deep[x]=0;ans++;
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	fo(i,1,n) scanf("%d",&a[i]),putin(a[i],i);
	if(a[1]!=1) a[1]=1,ans=1;
	dg(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 5248
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Tue Jun 26 02:14:38 2018
//
package main

import (
	"fmt"
	"strconv"
)

var N string

func main() {
	fmt.Scan(&N)

	s := 0
	for i := range N {
		s += int(N[i] - '0')
	}
	n, _ := strconv.Atoi(N)
	if n%s == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
<?PHP
$n = fgets(STDIN);
$array = array_map('intval', explode(' ', trim(fgets(STDIN))));
if (in_array('0', $array)){
  echo 0;
  return;
}
$sum = $array[0];
for($i = 1; $i < $n; $i++){
  $sum = $sum * $array[$i];
  if($sum > 1000000000000000000){
   echo -1;
   return;
  }
}
 
 echo $sum;

Measured memory_bytes: 28608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace P0003_Is_it_a_Right_Triangle
{
    class Program
    {
        static void Main(string[] args)
        {

            List<string> lines = new List<string>();

            int cntLine = int.Parse(Console.ReadLine());

            for(int i = 1; i <= cntLine; i++)
            {
                lines.Add(Console.ReadLine());
            }          

            foreach (string line in lines)
            {
                List<string> sidesStr = line.Split(' ').ToList<string>();
                List<int> sides = new List<int>();

                foreach (string sideStr in sidesStr)
                {
                    sides.Add(int.Parse(sideStr));
                }

                sides.Sort();

                if (Math.Pow(sides[2], 2) == Math.Pow(sides[0], 2) + Math.Pow(sides[1], 2))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }

            }


        }
    }
}

Measured memory_bytes: 5980
#include<iostream>
#include<algorithm>
using namespace std;
int n,a,b;
int t[100000];
int main(){

  while(cin>>n>>a>>b,n||a||b){
  for(int i=0;i<n;i++)cin>>t[i];
  int ans=0;
    sort(t,t+n);
    reverse(t,t+n);
    //cout<<t[0]:
    int ans2=0;
    for(int i=a-1;i<b;i++){
      //cout<<t[i]-t[i+1]<<endl;
      if(ans<=t[i]-t[i+1]){
        ans=t[i]-t[i+1];
        ans2=i+1;
      }
    }
    cout<<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  Graph G(n, vi(2));
  rep(i,n) rep(j,2) cin >> G[i][j];

  sort(all(G));

  int a = 0, b = -1;
  int a_end;
  bool zero = false;

  for (int i=1; i<n; ++i) {
    if (b == -1) {
      if (G[i][0] > G[a][1]) {
        b = i;
        a_end = i - 1;
      }
      else if (G[i][1] <= G[a][1]) {
        a = i;
      }
    }

    else {
      if (G[i][0] > G[b][1]) {
        zero = true;
        break;
      }
      else if (G[i][1] <= G[b][1]) {
        b = i;
      }
    }
  }

  if (zero) {
    int ans = 0;
    rep(i,n) ans = max(ans, G[i][1] - G[i][0] + 1);
    cout << ans << endl;
    return 0;
  }

  if (a == n-1) {
    int ans = G[n-1][1] - G[n-1][0] + 1;
    int tmp = 0;
    rep(i,n) tmp = max(tmp, G[i][1] - G[i][0] + 1);
    cout << ans + tmp << endl;
    return 0;
  }

  Graph rest;
  rest.push_back(G[a]);
  int last = b == -1 ? n-1 : a_end;
  int r = b == -1 ? n-1 : b;
  for (int i=a+1; i<=last; ++i) {
    if (b != -1 && G[i][1] < G[r][0]) rest.clear();
    if (G[i][1] <= G[r][1]) rest.push_back(G[i]);
  }

  Graph right(rest.size(), vi(2));
  rep(i,rest.size()) {
    right[i][0] = rest[i][1];
    right[i][1] = i;
  }
  sort(all(right));

  int ans = 0;
  if (b == -1) {
    ans = (G[a][1] - G[n-1][0] + 1) * 2 + max(G[n-1][0] - G[a][0], G[n-1][1] - G[a][1]);
    int tmp = 0;
    rep(i,n) tmp = max(tmp, G[i][1] - G[i][0] + 1);
    ans = max(ans, (G[a][1] - G[n-1][0] + 1) + tmp);
  }

  else {
    rep(i,n) ans = max(ans, G[i][1] - G[i][0] + 1);
  }

  int k = 0;
  rep(i,rest.size()-1) {
    while (right[k][1] <= i) ++k;
    ans = max(ans, (G[a][1] - rest[i][0] + 1) + (right[k][0] - G[n-1][0] + 1));
  }

  if (rest.size() == 1) {
    ans = max(ans, (G[a][1] - rest[0][0] + 1) + (G[b][1] - G[n-1][0] + 1));
  }

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


Measured memory_bytes: 17328
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

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

    // calc
    bool ans = false;
    for( int i=0; i<3; i++ ){
        int d = N % 10;
        N /= 10;
        if( d==7 ) ans = true;
    }

    // out
    printf( ans ? "Yes" : "No" );
} 

Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
using namespace std;

int main(){
  int N; 
  cin>>N;
  vector<int>T(N+1);
  for(int i=1;i<=N;i++){
      cin>>T[i];
  }
  int M;
  cin>>M;
  vector<int>P(M+1),X(M+1);
  for(int i=1;i<=M;i++){
      cin>>P[i]>>X[i];
  }
  long long sum=0;
  for(int i=1;i<=N;i++){
      sum+=T[i];
  }
  for(int i=1;i<=M;i++){
      cout<<sum-T[P[i]]+X[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

int main()
{
    IOS;
    ll n, i, j, k;
    vector<ll> a(1e6), dp(1e6, INT_MAX);
    cin >> n >> k;
    for (i = 0; i < n; i++)
        cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for (i = 2; i < n; i++)
        for (j = 1; i - j >= 0 and j <= k; j++)
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    // for(i=0;i<n;i++)
    //     cout<<dp[i]<<" \n"[i==n-1];
    cout << dp[n - 1] << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1000000],n;
int main ()
{
  cin>>n;
  for(int i = 0 ;i<n;i++)
     scanf("%d",&a[i]);
  int q,k,sum = 0;
  scanf("%d",&q);
  for(int i = 0;i<q;i++)
     {
       scanf("%d",&k);
       if(*lower_bound(a,a+n,k)  == k)  sum++;
     }
     cout<<sum<<endl;
   return 0;
}



Measured memory_bytes: 3512
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int[][] a = new int[3][3];
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                a[i][j] = Integer.parseInt(sc.next());
            }
        }
        int n = Integer.parseInt(sc.next());
        for(int i = 0; i < n; ++i) {
            int b = Integer.parseInt(sc.next());
            for(int j = 0; j < 3; ++j) {
                for(int k = 0; k < 3; ++k) {
                    if(a[j][k] == b) {
                        a[j][k] = -1;
                        j = 5;
                        break;
                    }
                }
            }
        }

        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(a[j][i] != -1) {
                    break;
                }

                if(j == 2) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(a[i][j] != -1) {
                    break;
                }

                if(j == 2) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        for(int i = 0; i < 3; ++i) {
            if(a[i][i] != -1) {
                break;
            }

            if(i == 2) {
                System.out.println("Yes");
                return;
            }
        }

        for(int i = 1; i < 3; ++i) {
            if(a[i][2 - i] != -1) {
                break;
            }

            if(i == 2) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
    }
}

Measured memory_bytes: 23508
N, M, Q = map(int,input().split())
Mlist = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    Mlist.append(array)
Qlist = []
for i in range(Q):
    array = list(map(int, input().strip().split()))
    Qlist.append(array)
p = [[0 for i in range(N)] for j in range(N)]
q = 0
r = [[0 for i in range(N)] for j in range(N)]
def count(k,l):
    s = k
    j = l
    p[s-1][j-1] = p[s-1][j-1] + 1
for i in range(len(Mlist)):
    count(Mlist[i][0],Mlist[i][1])
for i in range(N):
    for j in range(N):
        if i == 0:
            r[i][j] = p[i][j] + r[i][j-1]      
        elif j == 0:
            r[i][j] = p[i][j] +r[i-1][j]
        else:
            r[i][j] = r[i-1][j] + r[i][j-1] - r[i-1][j-1] + p[i][j]
for i in range(len(Qlist)):
    q = 0
    if Qlist[i][0] == 1:
        b = r[Qlist[i][1]-1][Qlist[i][1]-1]
    else:
        b = r[Qlist[i][1]-1][Qlist[i][1]-1] - r[Qlist[i][0]-2][Qlist[i][1]-1]
    print(b)



Measured memory_bytes: 79340
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;

int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;

    modint f[201010];
    f[0] = 1;
    rep(i, 200050){
        f[i+1] = f[i]*(i+1);
    }
    modint ans = 0;
    modint fa[101010], fb[101010];
    fa[0] = 1;
    fb[0] = 1;
    rep(i, n){
        fa[i+1] = fa[i] * a;
        fa[i+1] /= a+b;
    }
    rep(i, n){
        fb[i+1] = fb[i] * b;
        fb[i+1] /= a+b;
    }
    rep(i, n){
        modint tmp = 1;
        tmp *= fa[n];
        tmp *= fb[i];
        tmp *= f[n-1+i];
        tmp /= f[n-1];
        tmp /= f[i];
        tmp *= (n+i);
        ans += tmp;
    }
    rep(i, n){
        modint tmp = 1;
        tmp *= fa[i];
        tmp *= fb[n];
        tmp *= f[n-1+i];
        tmp /= f[n-1];
        tmp /= f[i];
        tmp *= (n+i);
        ans += tmp;
    }
    ans *= 100;
    ans /= (a+b);
    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>

using namespace std;
using lint = long long;
using pii = pair<int, int>;
using vec = vector<int>;
using pq = priority_queue<int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define mp(x, y) make_pair((x), (y))
#define space " "

constexpr lint MOD = 1e9 + 7;
// int A, B, C, F, H, I, J, K, L, M, N, P, Q, S, T, U, W, X, Y;
lint A, B, F, H, I, J, K, L, M, N, P, Q, S, T, U, W, X, Y;
lint ans = 1;
// string ans;
vector<lint> t;

lint gcd(lint a, lint b) {
    if (max(a,b) % min(a,b) == 0) {
        return min(a,b);
    } else {
        return gcd(min(a,b), max(a,b) % min(a,b));
    }
}

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

	cin >> N;
    t.resize(N);
	rep(i, N) {
        cin >> t[i];
	}
	
	rep(i, N) {
        ans = (ans / gcd(ans, t[i]) * t[i]);
    }

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 0
while True:
    for i in range(n):
        flag = True
        if a[i] % 2 != 0:
            flag = False
            break
        else:
            a[i] /= 2

    if flag:
        ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 2940
n=int(input())
result=[]

while n!=0:
    data=list(map(int,input().split()))
    data=sorted(data)
    answer=1000000

    for i in range(0,n-1):
        d=data[i+1]-data[i]
    
        if d<answer:
            answer=d
        
    result.append(answer)
    
    n=int(input())

for i in range(0,len(result)):
    print(result[i])


Measured memory_bytes: 5652
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Abs(a int) int {
  if a < 0 { a *= -1 }
  return a
}

func main() {
  HW := NextIntVec()
  H, W := HW[0], HW[1]
  A := make([][]int, H)
  for i := range A {
    A[i] = NextIntVec()
  }
  B := make([][]int, H)
  for i := range B {
    B[i] = NextIntVec()
  }
  C := make([][]int, H)
  D := 0
  for i := range C {
    C[i] = make([]int, W)
    for j := range C[i] {
      C[i][j] = Abs(A[i][j] - B[i][j])
      if D < C[i][j] { D = C[i][j] }
    }
  }
  DP := make([][][]bool, H + 1)
  for i := range DP {
    DP[i] = make([][]bool, W + 1)
    for j := range DP[i] {
      DP[i][j] = make([]bool, (H + W + 1) * D + 1)
    }
  }
  DP[1][0][0] = true
  for i := 0; i < H; i++ {
    for j := 0; j < W; j++ {
      for k := 0; k < (H + W) * D; k++ {
        DP[i + 1][j + 1][k] = DP[i][j + 1][Abs(k - C[i][j])] || DP[i][j + 1][Abs(k + C[i][j])] || DP[i + 1][j][Abs(k - C[i][j])] || DP[i + 1][j][Abs(k + C[i][j])]
      }
    }
  }
  ans := 0
  for i, b := range DP[H][W] {
    if b {
      ans = i
      break
    }
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 90112
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
int   main()
{
	int n;
	char s[20];
	cin>>n>>s;
	if(n<3200)
		printf("red\n");
	else
		printf("%s\n",s);
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 1010;
const int MW = 10010;
const ll inf = -1e18;

int N;
ll dp[MN][MW];

int main() {
    cin >> N;
    using T = pair<pii, int>;

    vector<pair<int, T>> vec;

    rep(i, N) {
        int w, s, v;
        cin >> w >> s >> v;
        vec.eb(w + s, mp(mp(w,s),v));
    }
    sort(ALL(vec));

    rep(i, MN) {
        rep(j, MW) {
            dp[i][j] = inf;
        }
    }

    dp[0][0] = 0;

    ll ans = 0;
    rep(i, N) {
        int w = vec[i].se.fi.fi;
        int s = vec[i].se.fi.se;
        ll v = vec[i].se.se;

        rep(j, MW) {
            dp[i + 1][j] = dp[i][j];
        }

        //use
        for (int j = 0; j <= s; ++j) if (dp[i][j] != inf) {
            ans = max(ans, dp[i][j] + v);
            if (j + w < MW) {
                dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v);
            }
        }
    }

    cout << ans << endl;

	return 0;
}

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

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int g = t / a;
  int ans = g * b;
  cout << ans << endl;
	
  return 0;
}


Measured memory_bytes: 256