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

void Main()
{
    long a, b, n;
    cin >> a >> b >> n;
    if(n < b){
        cout << (a*n)/b - a*(n/b) << endl;
    }else{
        cout << (a*(b-1))/b - a*((b-1)/b); 
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int p, q, r;
	cin >> p >> q >> r;
	cout << p + q + r - max({p, q, r}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

const int MAX_V = 50;
const int MAX_S = MAX_V*50+5;

struct Edge {
    int to, a, b;
    Edge(int to, int a, int b):to(to),a(a),b(b) {}
};

struct Data {
    int v, s;
    ll x;
    Data(int v, int s, ll x):v(v),s(s),x(x) {}
    bool operator<(const Data& a) const {
        return x > a.x;
    }
};

vector<Edge> g[MAX_V];
ll dp[MAX_V][MAX_S+5];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, s;
	cin >> n >> m >> s;
    rep(i,m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u; --v;
        g[u].emplace_back(v,a,b);
        g[v].emplace_back(u,a,b);
    }
    vector<int> c(n), d(n);
    rep(i,n) cin >> c[i] >> d[i];
    rep(i,n)rep(j,MAX_S+5) dp[i][j] = LINF;
    s = min(s, MAX_S);
    priority_queue<Data> q;
    auto push = [&](int v, int s, ll x) {
        if (s<0) return;
        if (dp[v][s]<=x) return;
        dp[v][s] = x;
        q.emplace(v,s,x);
    };
    push(0, s, 0);
    while (!q.empty()) {
        Data hoge = q.top(); q.pop();
        int v = hoge.v, s = hoge.s;
        ll x = hoge.x;
        if (dp[v][s] != x) continue;
        {
            int ns = min(s+c[v], MAX_S);
            push(v, ns, x+d[v]);
        }
        for (Edge e: g[v]) {
            push(e.to, s-e.a, x+e.b);
        }
    }
    for (int i = 1; i < n; i++) {
        ll ans = LINF;
        rep(j, MAX_S+5) {
            ans = min(ans, dp[i][j]);
        }
    	cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 6248
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
// #define endl '\n'

map<int,int> mem;

int q(int y){
  cout << y << endl;
  string s;
  cin >> s;
  int a = -1;
  if (s == "Male") return 1;
  else if (s == "Female") return 2;
  else {
    exit(0);
  }
}


void solve(){
  int n;
  cin >> n;
  
  int l = 0;
  int r = n-1;
  int a = q(0);
  while (l + 1 < r){
    int m = (l+r)/2;
    int c = q(m);
    int x = m - l;
    if (x%2 and (a==c) or x%2==0 and a!=c) {
      r = m;
    } else {
      l = m;
      a = c;
    }
  }
  q(r);
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

 */

Measured memory_bytes: 852
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())

	steps := make([]int, n+1)
	for i := range steps {
		steps[i] = 1
	}

	for i := 0; i < m; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		steps[a] = 0
	}

	for i := 2; i <= n; i++ {
		steps[i] *= (steps[i-1] + steps[i-2]) % 1000000007
	}

	fmt.Println(steps[n])
}


Measured memory_bytes: 1920
from collections import deque
h , w = map(int,input().split())
S = [input() for i in range(h)]
dxy = [(0,1),(1,0),(-1,0), (0,-1)]

ans = 0
for y in range(h):
    for x in range(w):
        if S[y][x] == '#': continue
        dist =[[0]*w for i in range(h)]
        visited = [[0]*w for i in range(h)]
        visited[y][x] = 1
        q = deque([(x,y)])
        while q:
            x,y = q.popleft()
            for dx, dy in dxy:
                nx, ny = x + dx, y+ dy
                if not 0 <= nx < w: continue
                if not 0 <= ny < h: continue 
                if visited[ny][nx]:continue
                if S[ny][nx] == '#':continue  
                visited[ny][nx] = 1
                dist[ny][nx] = dist[y][x] + 1
                q.append((nx,ny))
        ans = max(ans, max(max(row) for row in dist)) 
print(ans)    


Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#define SIZE 20

int main(void)
{
    char str[SIZE+1];
    int i;

    scanf("%s", str);
    i = strlen(str)-1;
    for (; i>=0; i--) {
        printf("%c", str[i]);
    }
    printf("\n");
    
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int a, b, h;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int cnt = Integer.parseInt(br.readLine());
		String[] str = new String[2];
		ArrayList<String> list = new ArrayList<String>();
		String dis;
		for(int n=0;n<4;n++){
			for(int m=1;m<=13;m++){
				switch(n){
				case 0:
					list.add("S "+ m);
					break;
				case 1:
					list.add("H "+ m);
					break;
				case 2:
					list.add("C "+ m);
					break;
				case 3:
					list.add("D "+ m);
					break;
				}
			}
		}
		for(int i=0; i<cnt; i++){
			str = br.readLine().split(" ");
			list.remove(list.indexOf(str[0] + " " + str[1]));
		}
		for(int i=0;i<list.size();i++){
			dis = list.get(i);
			System.out.println(dis);
		}
	}
}

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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int[] a = new int[6];
		for(int i = 0; i < 6; ++i)
			a[i] = sc.nextInt();
		Dice d = new Dice(a);
		int n = sc.nextInt();
		for(int i = 0; i < n; ++i){
			int ans = 0;
			int top = sc.nextInt();
			int fr = sc.nextInt();
			if(top == d.Front) d.turnN();
			else if(top == d.Right) d.turnW();
			else if(top == d.Left) d.turnE();
			else if(top == d.Back) d.turnS();
			else if(top == d.Bottom) {d.turnN(); d.turnN();}
			
			if(fr == d.Front) ans = d.Right;
			else if(fr == d.Right) ans = d.Back;
			else if(fr == d.Back) ans = d.Left;
			else if(fr == d.Left) ans = d.Front;
			System.out.println(ans);
		}
	}

}

class Dice{
	int Top, Front, Right, Left, Back, Bottom;
	Dice(int[] a){
		Top = a[0]; Front = a[1]; Right = a[2];
		Left = a[3]; Back = a[4]; Bottom = a[5];
	}
	void turnN(){
		int tmp = Top; Top = Front; Front = Bottom;
		Bottom = Back; Back = tmp;
	}
	void turnS(){
		int tmp = Top; Top = Back; Back = Bottom;
		Bottom = Front; Front = tmp;
	}
	void turnE(){
		int tmp = Top; Top = Left; Left = Bottom;
		Bottom = Right; Right = tmp;
	}
	void turnW(){
		int tmp = Top; Top = Right; Right = Bottom;
		Bottom = Left; Left = tmp;
	}
}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24260
a1,a2,a3=map(int,input().split())
a4,a5,a6=map(int,input().split())
a7,a8,a9=map(int,input().split())
a=[]
d=0
a+=[a1,a2,a3,a4,a5,a6,a7,a8,a9]
n=int(input())
b=[]
for i in range(n):
    c=int(input())
    b.append(c)
for i in a:
    if b.count(i)==1:
        a[d]=0
    d+=1
if a[0]==a[1]==a[2] or a[3]==a[4]==a[5] or a[6]==a[7]==a[8] or a[0]==a[3]==a[6] or a[1]==a[4]==a[7] or a[2]==a[5]==a[8] or a[0]==a[4]==a[8] or a[2]==a[4]==a[6]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e6 + 10;
char s[M];
int trie[M][3], vis[M], cnt[13], a[12], tag[M], ans[M], tot, n;
void insert(int a[], int rt, int id){
    for(int i = 0; i < n; i++){
        int x = a[i];
        if(!trie[rt][x]) trie[rt][x] = ++tot;
        rt = trie[rt][x];
    }
    vis[rt] = id;
}
void calc(int rt) {
    for(int i = 0; i < n; i++) {
        if(tag[rt]) {
            swap(trie[rt][1], trie[rt][2]);
            tag[rt] ^= 1; tag[trie[rt][0]] ^= 1; tag[trie[rt][1]] ^= 1; tag[trie[rt][2]] ^= 1;
        }
        int temp = trie[rt][2];
        trie[rt][2] = trie[rt][1];
        trie[rt][1] = trie[rt][0];
        trie[rt][0] = temp;
        rt = trie[rt][0];
    }
}
void print(int rt, int res, int h) {
    if(tag[rt]) {
        swap(trie[rt][1], trie[rt][2]);
        tag[rt] ^= 1; tag[trie[rt][0]] ^= 1; tag[trie[rt][1]] ^= 1; tag[trie[rt][2]] ^= 1;
    }
    for(int i = 0; i < 3; i++) {
        if(trie[rt][i]) print(trie[rt][i], res + i * cnt[h], h + 1);
        else {
            ans[vis[rt]] = res;
            return;
        }
    }
}
int main(){
    scanf("%d%s", &n, s);
    int len = strlen(s), rt = 0;
    cnt[0] = 1;
    for(int i = 1; i <= n; i++) cnt[i] = cnt[i - 1] * 3;
    for(int i = 0; i < cnt[n]; i++) {
        memset(a, 0, sizeof(a));
        for(int j = n - 1; j >= 0; j--) {
            a[j] = (i % cnt[j + 1]) / cnt[j];
        }
        insert(a, rt, i);
    }
    for(int i = 0; i < len; i++) {
        if(s[i] == 'S') tag[0] ^= 1;
        else calc(rt);
    }
    print(rt, 0, 0);
    for(int i = 0; i < cnt[n]; i++) printf("%d%c", ans[i], i == cnt[n] - 1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 21884
package main

import "fmt"

func main() {
	var n, d, x int
	fmt.Scan(&n, &d, &x)

	ans := x
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)

		for i := 1; i <= d; i += a {
			ans++
		}
	}
	fmt.Println(ans)
}


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

using i64 = long long;

void die(int x = -1) {
    cout << x << '\n';
    exit(0); }

i64 mx(i64 a, i64 b, i64 c) {
    return max(a, max(b, c)); }

i64 mn(i64 a, i64 b, i64 c) {
    return min(a, min(b, c)); }

int main() {
    //freopen("dat.in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    i64 n, m, ant;

    cin >> n >> m;

    if (n % 3 == 0)
        die(0);
    if (m % 3 == 0)
        die(0);

    ant = min(n, m);
    for (i64 i = 1; i < n; ++i)
        ant = min(ant, mx(i * m, (n - i) * (m / 2LL), ((n - i) * ((m + 1LL) / 2LL))) - mn(i * m, (n - i) * (m / 2LL), ((n - i) * ((m + 1LL) / 2LL))));

    swap(n, m);
    for (i64 i = 1; i < n; ++i)
        ant = min(ant, mx(i * m, (n - i) * (m / 2LL), ((n - i) * ((m + 1LL) / 2LL))) - mn(i * m, (n - i) * (m / 2LL), ((n - i) * ((m + 1LL) / 2LL))));

    cout << ant << '\n';

    return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll,ll>> res;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0) continue;
    ll ex = 0;
    while (n % a == 0) { ++ex; n /= a; }
    res.push_back({a, ex});
  }
  if (n != 1) res.push_back({n, 1});
  return res;
}

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

int main() {
  IOS;
  ll k; cin >> k;
  if (k%2 == 0 || k%5 == 0) { COUT(-1); return 0; }

  int x = 7;
  for (int i = 1; i < INF; i++) {
    if(x % k == 0) {
      COUT(i);
      return 0;
    }
    x%=k;
    x = x*10+7;
  }

  COUT(-1);
  return 0;
}

Measured memory_bytes: 3652
n = int(input())
data = []
for i in range(n) :
    s, p = input().split()
    data.append([s, int(p), i+1])

data.sort(key = lambda x:x[1], reverse=True)
data.sort(key = lambda x:x[0])

for num in data:
    print(num[2])


Measured memory_bytes: 9092
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char S[2000020];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(S, 1, 2000020, stdin);

	char* c = S, ct;
	int N = 0;
	
	while ((ct = *c++) >= '0') N = N * 10 + ct - '0';

	int L = 0, R = 2000001;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (*(c + M) >= ' ') L = M;
		else R = M;
	}

	if (*c == '0') {
		printf("0\n");
		return 0;
	}

	int zero = 0;
	int n = R / 8 + 1;
	for (char* d = c; d < c + R - 8; d += 7) {
		ll tmp = *(ll*)(d);
		tmp += 0x1010101010101010;
		tmp ^= 0xcfcfcfcfcfcfcfcf;

		ll tmp2 = tmp + 0x0001000100010001;
		if ((tmp2 << 1 ^ tmp2) & 0x2000200020002000) {
			printf("0\n");
			return 0;
		}
		tmp2 = tmp + 0x0000010001000100;
		if ((tmp2 << 1 ^ tmp2) & 0x0020002000200000) {
			printf("0\n");
			return 0;
		}
	}

	for (char* d = c + min(0, R - 10); d < c + R; d++) {
		if (*d == ' ' && *(d + 1) == '0') {
			printf("0\n");
			return 0;
		}
	}

	if (R >= N * 2 + 18) {
		printf("-1\n");
		return 0;
	}

	ll kotae = 1;
	auto owa = c + R;
	while (c < owa) {
		ll tmp = *(ll*)(c);
		if (tmp != 0x2031203120312031) {
			ll k = 0;
			while ((ct = *c++) >= '0') k = k * 10 + ct - '0';
			if (ll(1e18) / kotae < k) {
				printf("-1\n");
				return 0;
			}
			else kotae *= k;
		}
		else c += 8;
	}

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

	Would you please return 0;
}

Measured memory_bytes: 4804
#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;cin>>n;
    string a,b,c;cin>>a>>b>>c;

    int result=0;
    REP(i,n){
        if(a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]){
            result += 2;
        }
        else if(a[i]==b[i] && a[i]==c[i]){
            
        }
        else if(a[i]==b[i] || a[i]==c[i] || b[i]==c[i]){
            result += 1;
        }

    }
    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 <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1LL)
#define bitset(a,b)      ( a |= (1LL << b))
#define bitunset(a,b)    (a &= ~(1LL << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

pii Dir[8] = {
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


pii operator+(pii obj, pii obj2) {
	return MP(obj.first + obj2.first, obj.second + obj2.second);
}
pii operator-(pii obj, pii obj2) {
	return MP(obj.first - obj2.first, obj.second - obj2.second);
}

struct Edge {
	int from, to, weight;
};

typedef vector<vector<Edge>> Graph;


int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) % INT_MAX;
}

int main() {
	string str;
	cin >> str;
	int a = str[0] - '0', b = str[1] - '0', c = str[2] - '0', d = str[3] - '0';

	REP(i, 2) {
		REP(j, 2) {
			REP(k, 2) {
				if (a + (i * 2 - 1)*b + (j * 2 - 1)*c + (k * 2 - 1)*d == 7) {
					cout << a << (i ? '+' : '-') << b << (j ? '+' : '-') << c << (k ? '+' : '-' )<< d << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

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

int main(){
    int x;
    cin >> x;
    cout << (x==1? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, m;
  string s;
  cin >> n >> m >> s;

  vi ans;
  int ne = n;
  for (int i = n; i != 0; ) {
    for (int j = 1; j <= m; j++) {
      if (i-j < 0) {
        break;
      }
      if (s[i-j] == '0') {
        ne = i-j;
      }
    }
    if (ne == i) {
      cout << -1 << endl;
      return 0;
    } else {
      ans.push_back(i-ne);
      i = ne;
    }
  }

  reverse(all(ans));
  for (auto&& i : ans) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1096
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let v: Vec<usize> = parse_line().unwrap();
    let mut vc = v.clone();
    vc.sort();
    let a: usize = vc[n/2 - 1];
    let b: usize = vc[n/2];

    for e in v.iter() {
        if e <= &a {
            println!("{}", b)
        } else {
            println!("{}", a)
        }
    }
}


Measured memory_bytes: 6108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define debug(x) #x << "=" << (x)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc045/tasks/arc061_a

int main() {
    string S; cin >> S;
    int len = S.length();

    ll ans = 0;
    for (int msk = 0; msk < 1 << (len - 1); msk++) {
        ll sum = S[0] - '0';

        REP(i, len-1) {
            if (msk & 1 << i) {
                ans += sum;
                sum = 0;
            }
            sum = sum * 10 + S[i+1] - '0';
        }

        ans += sum;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, M;
	cin >> N >> M;
	vector<vector<char>>A(N, vector<char>(N)), B(M, vector<char>(M));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A.at(i).at(j);
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			cin >> B.at(i).at(j);
		}
	}
	int L = N - M + 1;
	for (int i = 0; i < L; i++) {
		for (int j = 0; j < L; j++) {
			int num = 0;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (A.at(i + k).at(j + l) != B.at(k).at(l)) num++;
				}
			}
			if (num == 0) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAIN 100010
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        string ans[110];
        cout<<"100 100"<<endl;
        for(int i=0; i<100; i++)
        {
            for(int j=0; j<50; j++) ans[i]+="#";
            for(int j=0; j<50 ;j++) ans[i]+=".";
        }
        int x1=0,y1=0;
        for(int i=1; i<a; i++)
        {
            ans[x1][y1]='.';
            x1+=2;
            if(x1>99)
            {
                y1+=2;
                x1=0;
            }
        }
        int x2=99,y2=99;
        for(int i=1; i<b; i++)
        {
            ans[x2][y2]='#';
            x2-=2;
            if(x2<0)
            {
                y2-=2;
                x2=99;
            }
        }
        for(int i=0; i<100; i++)
            //cout<<ans[i].length()<<endl;
            cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define pp pair<ll,ll>
#define mp make_pair
#define PI acos(-1.0)
#define all(v) v.begin(),v.end()
#define pb push_back
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FREV(i,a,b) for(i=a;i>=b;i--)
#define FORI(a) for(auto it=a.begin();it!=a.end();it++)
#define READ(a,i,n) FOR(i,0,n) { sll(a[i]);}
#define DEBUG(x) cerr<<"In file "<< __FILE__ <<" at line "<< __LINE__ <<" :: "<< #x <<" = "<<x<<endl
#define sll(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define INF 1e18
#define MOD 1000000007

using namespace std;
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

        ll n,i,sum=0;
        cin>>n;
        ll a[n];

        FOR(i,0,n)
        {
            cin>>a[i];
        }
        ll cuurh=a[0];
        FOR(i,1,n)
        {
            if(a[i]<cuurh)
            {
                sum+=cuurh-a[i];
                a[i]=cuurh;
            }
            else if(a[i]>cuurh)
                 cuurh=a[i];
        }
        cout<<sum<<"\n";

    return 0;
}


Measured memory_bytes: 5212
# 桁DP 最適化もうむり

MOD = 10 ** 9 + 7
s = gets.chomp.split("")
question = s.map { |c| c == "?" }
length = s.length
# dp[上から i 桁まで][13 で割ったあまり]の出現回数
# 桁の自由度(smaller)は本問では不要
dp = (length + 1).times.map { Array.new(13, 0) }
# 初期化
# dp[0 桁目まで][13 で割ったあまりが 0]の出現回数は 1
dp[0][0] = 1
# （右から見た）桁数 % 6
mod_memo = [4, 1, 10, 9, 12, 3]
all_nums = (0..9).to_a

# 桁数分ループする（i は遷移元の桁）
length.times do |i|
  # 13 で割ったあまりの増加分を求める
  addition = mod_memo[(length - i) % 6]
  # 桁の数字が "?" の場合は 10 回ループ、それ以外の場合はその数字のみ
  nums = question[i] ? all_nums : [s[i].to_i]
  current_counts = dp[i]
  # 最適化のため、事前に 1 行分だけ浅いコピーをする
  # dp_next と dp[i + 1] の object_id は同じ
  dp_next = dp[i + 1]
  # 13 で割ったあまりごとに確認する
  13.times do |mod|
    current_count = current_counts[mod] % MOD
    nums.each do |d|
      # 次の桁に遷移する
      dp_next[(mod + addition * d) % 13] += current_count
    end
  end
end

puts dp[length][5] %= MOD


Measured memory_bytes: 26748
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $max = 0;
  for($i=0; $i<strlen($s); $i++){
    if($s[$i]=='A' || $s[$i]=='T' || $s[$i]=='C' || $s[$i]=='G'){
      $len++;
      $max = max($max, $len);
    }
    else{
      $len = 0;
    }
  }

 echo $max;

Measured memory_bytes: 16056
n,m = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for i in range(n)]

s=[]
for t in e:
  b_list=0
  for x in t[1:]:
    b_list = b_list | pow(2,x-1)
  s.append(b_list)
result=pow(2,30)-1
for i in s:
   result = result & i
cnt=0
for i in range(30):
  if result & pow(2,i):
    cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 400020
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}
int q[N];
int main(int argc, char const *argv[]) {
	int n = read(), l = 200001, r = 200000;
	for (int i = 1; i <= n; i++)
		if (i & 1) q[++r] = read();
		else q[--l] = read();
	if (~ n & 1) for (int i = l; i <= r; i++) printf("%d ", q[i]);
	else for (int i = r; i >= l; i --) printf("%d ", q[i]);
	return 0;
}


Measured memory_bytes: 2944
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""
import sys

sys.setrecursionlimit(int(1e6))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def graph_dfs(u, low, disc, stack_member, st):
    global Time
    # Initialize discovery time and low value
    disc[u] = Time
    low[u] = Time
    Time += 1
    stack_member[u] = True
    st.append(u)
    scc_set = set()

    # Go through all vertices adjacent to this
    for v in adj_table[u]:

        # If v is not visited yet, then recur for it
        if disc[v] == -1:

            graph_dfs(v, low, disc, stack_member, st)

            # Check if the subtree rooted with v has a connection to
            # one of the ancestors of u
            # Case 1 (per above discussion on Disc and Low value)
            low[u] = min(low[u], low[v])

        elif stack_member[v]:

            '''Update low value of 'u' only if 'v' is still in stack
            (i.e. it's a back edge, not cross edge).
            Case 2 (per above discussion on Disc and Low value) '''
            low[u] = min(low[u], disc[v])

    # head node found, pop the stack and print an SCC
    w = -1  # To store stack extracted vertices
    if low[u] == disc[u]:
        while w != u:
            w = st.pop()
            scc_set.add(w)
            stack_member[w] = False
        ans.append(scc_set)

    return None


def scc():
    # Mark all the vertices as not visited
    # and Initialize parent and visited,
    # and ap(articulation point) arrays
    disc = [-1] * vertices
    low = [-1] * vertices
    stack_member = [False] * vertices
    st = []

    # Call the recursive helper function
    # to find articulation points
    # in DFS tree rooted with vertex 'i'
    for v in range(vertices):
        if disc[v] == -1:
            graph_dfs(v, low, disc, stack_member, st)

    return ans


def solve():
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in scc_sets:
            if (ele1 in each) and (ele2 in each):
                flag = True
        if flag:
            print('1')
        else:
            print('0')
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    Time = 0
    ans = []
    scc_sets = scc()
    solve()

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<int> p(M);
    vector<vector<int>> s(M);
    for(int i=0; i<M; ++i){
        cin >> k[i];
        s[i] = vector<int>(k[i]);
        for(int j=0; j<k[i]; ++j){
            cin >> s[i][j];
        }
    }
    for(int i=0; i<M; ++i){
        cin >> p[i];
    }
    long long count = 0;
    for(int i=0; i<(1<<N); ++i){
        bool valid = true;
        for(int j=0; j<M; ++j){
            int sum = 0;
            for(int l=0; l<k[j]; ++l){
                sum += (i>>(s[j][l]-1)) & 1;
            }
            if(sum%2!=p[j]){
                valid = false;
                break;
            }
        }
        if(valid) ++count;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<char,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    ll N;
    cin >> N;
    ll sr;
    cin >> sr;sr--;
    ll sc;
    cin >> sc;sc--;
    string S;
    cin >> S;
    string T;
    cin >> T;
    ll sr1=sr,sr2=sr,sr3=sr;
    ll sc1=sc,sc2=sc,sc3=sc;

    for(ll i=0;i<N;i++){
        if(S[i]=='U')sr--;
        if(sr<0){cout<<"NO"<<endl;return 0;}
        if(T[i]=='D'&&sr<H-1)sr++;
    ;}
    for(ll i=0;i<N;i++){
        if(S[i]=='D')sr1++;
        if(sr1>=H){cout<<"NO"<<endl;return 0;}
        if(T[i]=='U'&&sr1>0)sr1--;
    ;}
    for(ll i=0;i<N;i++){
        if(S[i]=='L')sc2--;
        if(sc2<0){cout<<"NO"<<endl;return 0;}
        if(T[i]=='R'&&sc2<W-1)sc2++;
    ;}
    for(ll i=0;i<N;i++){
        if(S[i]=='R')sc3++;
        if(sc3>=W){cout<<"NO"<<endl;return 0;}
        if(T[i]=='L'&&sc3>0)sc3--;
    ;}
    cout<<"YES"<<endl;




    return 0;
}


Measured memory_bytes: 776
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N, W = map(int, input().split())
    w = [None] * N
    v = [None] * N

    for i in range(N):
        w[i], v[i] = map(int, input().split())
    
    dp = [[0]*(N+1) for _ in range(W+1)]
    for i in range(1,W+1):
        for j in range(N):
            if i - w[j] < 0:
                dp[i][j+1] = dp[i][j]
            else:
                dp[i][j+1] = max(dp[i][j], dp[i-w[j]][j]+v[j])
    print(dp[W][N])    

if __name__ == "__main__":
    main()

Measured memory_bytes: 163144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  long long ans = 1;
  for(int i = 0; i < n; i++){
    if(i == 0){
      ans *= k;
    }
    else{
      ans *= k - 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD ll(1e9+7)
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

template< int mod >
struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t 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;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

void solve() {
    using modint = ModInt<MOD>;
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    sort(ALL(A));
    reverse(ALL(A));

    // 全要素が負の場合
    if (A[0] <= 0) {
        // 偶数を選ぶ場合は絶対値が最大になる様に再度reverse
        if(K%2==0) reverse(ALL(A));
        modint ans(1);
        REP(i,K) ans*=(modint(A[i]));
        cout << ans << endl;
        return;
    }

    modint now(1);

    int il = 0, ir = N-2;

    if(K%2==1) {
        now *= modint (A[0]);
        K--;
        il++;
    }

    // ここでAは偶数になる。
    REP (i,K/2) {
        ll a = ll(A[il])*ll(A[il+1]);
        ll b = ll(A[ir])*ll(A[ir+1]);
        now *= modint(max(a,b)%MOD);
        if(max(a,b) == a) il+=2;
        else ir-=2;
    }

    cout << now << endl;
}

int main() {
    solve();
    return 0;
}

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

int gcd(int a, int b);

main(){
  int a,b,ans;
  scanf("%d%d",&a,&b);
  ans = gcd(a,b);
  printf("%d\n",ans);
  return 0;
}

int gcd(int a,int b)
{
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}



Measured memory_bytes: 2736
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	int n;
public:
	A()
	{
		cin >> n;
	}
	void solve()
	{
		if (n / 100 == n % 10)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);

        var x = n;
        while (true) {
            if (a <= x && x <= b) return "OK";
            if (x > b) return "NG";

            x += n;
        }
    }
}


Measured memory_bytes: 27392
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;
vector<int> adj[200005];
long long val[200005];
long long ans[200005];

void dfs(int u, int p) {
    ans[u] = val[u];
    for (auto v:adj[u]) {
        if (v == p) continue;
        val[v] += val[u];
        dfs(v, u);
    }
}

int main() {
    //freope    n("in.txt", "rt", stdin);
    int n, q;
    scanf("%d %d", &n, &q);
    int a, b;
    for (int i = 1; i < n; ++i) {
        scanf("%d %d", &a, &b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    while (q--) {
        scanf("%d %d", &a, &b);
        val[a] += b;
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
}

Measured memory_bytes: 25856
#include<bits/stdc++.h>
#define int long long
using namespace std;
// KnapSack
int max_value(int N, int W, int*w , int* v)
{
    int dp[N+1][W+1];
    memset(dp,0,sizeof(dp));
    for(int i= 0 ;i<N ; ++i)
    {
        for(int j = 0 ;j<=W ; ++j)
        {
            dp[i+1][j] = max(dp[i+1][j] , dp[i][j]);
            if(j >= w[i])
                dp[i+1][j]  = max(dp[i+1][j] ,
                                dp[i][j-w[i]] + v[i]);
        }
    }
    return dp[N][W];
} 

int32_t main()
{
    int N,W;
    cin>>N>>W;
    int w[N],v[N];
    for(int i = 0 ;i<N ;++i)
        cin>>w[i]>>v[i];

    cout << max_value(N,W,w,v) <<endl;
    return 0;
}

Measured memory_bytes: 79104
N = gets.to_i

uf = Array.new(N,&:itself)
class << uf
  def _root(i); self[i] = (self[i] == i ? i : _root(self[i])); end
  def same?(i,j); _root(i) == _root(j); end
  def union(i,j)
    i_ = _root(i)
    j_ = _root(j)
    if i_ < j_
      self[j_] = i_
    else
      self[i_] = j_
    end
  end
end

V = N.times.map{gets.split.map(&:to_i)}
Ex = N.times.sort_by{|i| V[i][0] }.each_cons(2).map{|a,b| [V[b][0] - V[a][0], a, b] }
Ey = N.times.sort_by{|i| V[i][1] }.each_cons(2).map{|a,b| [V[b][1] - V[a][1], a, b] }

E = Ex + Ey
E.sort_by!(&:first)

ans = E.inject(0) do |total, (cost, u, v)|
  unless uf.same?(u,v)
    uf.union(u, v)
    total + cost
  else
    total
  end
end
puts ans

Measured memory_bytes: 28940
#include<stdio.h>
int main(void)
{

	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(0<=a&&0<=b&&0<=c&&a<=100&&b<=100&&c<=100){
		if(a<b&&b<c)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
		printf("No\n");
		
return 0;
}



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

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            long ans = 0;
            int p = 0;
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) == 'W') {
                    ans += i - p;
                    p++;
                }
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 27348
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, W;
    for(;;) {
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  REP(i,n){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans=0;
  REP(i,k){
    ans += l[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256