akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			SortedMap<Integer, Integer> map = new TreeMap<>();
			IntStream.range(0, n).forEach(i -> {
				int a = scanner.nextInt();
				map.put(a, map.getOrDefault(a, 0) + 1);
			});
			IntStream.range(0, m).forEach(i -> {
				int b = scanner.nextInt(), c = scanner.nextInt();
				int count = 0;
				while ((b > 0) && (map.firstKey() < c)) {
					int exists = map.get(map.firstKey());
					if (exists > b) {
						count += b;
						map.put(map.firstKey(), exists - b);
						map.put(c, map.getOrDefault(c, 0) + b);
						b = 0;
					} else {
						count += exists;
						map.put(c, map.getOrDefault(c, 0) + exists);
						map.remove(map.firstKey());
						b -= exists;
					}
				}
			});
			System.out.println(
					map.entrySet().stream().mapToLong(entry -> entry.getKey() * (long) entry.getValue()).sum());
		}
	}
}


Measured memory_bytes: 72228
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
int n=ir.nextInt();
int ans=n;
for(int i=2;i<=n;i++){
 if(n%i==0){
  ans=ans-ans/i;
  while(n%i==0) n/=i;
 }
}
out.println(ans);
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 24960
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, d;
int main() {
	cin >> n >> d;
	LL now = 0, ans = 0;
	while (now < n) {
		++ans;
		now += 2 * d + 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A_odd = list(filter(lambda x: x%2==0, A))

if (len(list(filter(lambda x: (x%3==0)or(x%5==0) ,A_odd))) == len(A_odd)):
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

using ll = long long;
const int MAX = 1e5 + 10;
using edge = struct {int to; ll cost;};
vector<edge> tree[MAX];
ll depth[MAX];

void dfs(int v, int p, ll d) {
  depth[v] = d;
  for (int i = 0; i < tree[v].size(); i++) {
    edge e = tree[v][i];
    if (e.to == p) continue;
    dfs(e.to, v, d + e.cost);
  }
  // for (auto &e : tree[v]) {
  //   if (e.to == p) continue;
  //   dfs(e.to, v, d + e.cost);
  // }
}

int main() {
  int N;
  cin >> N;
  int a, b;
  ll c;
  for (int i = 0; i < N - 1; i++) {
    scanf("%d %d %lld", &a, &b, &c);
    a--; b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }

  int Q, K;
  cin >> Q >> K;
  K--;
  dfs(K, -1, 0);
  for (int i = 0; i < Q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--; y--;
    printf("%lld\n", depth[x] + depth[y]);
  }

  return 0;
}


Measured memory_bytes: 15872
// sketchy code

#include <stdio.h>
#include <vector>

int t1,t2;

int n;

std::vector<int> g[100005];
bool vis[100005];
int nimsum[100005];

void dfs(int u)
{
    vis[u]=1;
    for (int v:g[u]) {
        if (vis[v]) continue;
        dfs(v);
        nimsum[u]^=nimsum[v]+1;
    }
    //printf("%d val %d\n",u,nimsum[u]);
}

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&n);
    for (int i=1; i<n; i++) {
        scanf("%d%d",&t1,&t2);
        g[t1].push_back(t2);
        g[t2].push_back(t1);
    }
    dfs(1);
    printf(nimsum[1]?"Alice":"Bob");
}


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

int df[] = { 1, 0 };
int dc[] = { 0, 1 };

int m, n;
vector<vector<int>> grid; // 0->white, 1->black
vector<vector<int>> dp;

bool inRange(int i, int j) {
	return i < m && j < n;
}

int rec(int i, int j) {
	if (!inRange(i, j)) return 1e9;
	if (i == m - 1 && j == n - 1) return 0;
	if (dp[i][j] != -1) return dp[i][j];
	int mini = 1e9;
	for (int dir = 0; dir < 2; dir++) {
		int ni = i + df[dir], nj = j + dc[dir];
		if (!inRange(ni, nj)) continue;
		if (grid[ni][nj] != grid[i][j] && grid[i][j] == 0)
			mini = min(mini, 1 + rec(ni, nj));
		else mini = min(mini, rec(ni, nj));
	}
	return dp[i][j] = mini;
}

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	cin >> m >> n;
	vector<string> str(m);
	for (int i = 0; i < m; ++i) cin >> str[i];
	grid = vector<vector<int>>(m, vector<int>(n, 0));
	for (int i = 0; i < m; ++i)
		for (int j = 0; j < n; ++j)
			if (str[i][j] == '#') grid[i][j] = 1;
	dp = vector<vector<int>> (m, vector<int>(n, -1));
	if (grid[0][0]) cout << 1 + rec(0, 0) << endl;
	else cout << rec(0, 0) << endl;
	return 0;
}

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

int main() {
  int W, H, N;
  scanf("%d%d%d", &W, &H, &N);
  vector<vector<int>> coordinate(H, vector<int>(W, 0));

  for (int num = 0; num < N; num++) {
    int x = 0;
    int y = 0;
    int a = 0;
    scanf("%d%d%d", &x, &y, &a);

    switch (a) {
      case 1:
        for (int i = 0; i < H; i++) {
          for (int j = 0; j < x; j++) {
            coordinate.at(i).at(j)++;
          }
        }
        break;
      case 2:
        for (int i = 0; i < H; i++) {
          for (int j = x; j < W; j++) {
            coordinate.at(i).at(j)++;
          }
        }
        break;
      case 3:
        for (int i = 0; i < y; i++) {
          for (int j = 0; j < W; j++) {
            coordinate.at(i).at(j)++;
          }
        }
        break;
      case 4:
        for (int i = y; i < H; i++) {
          for (int j = 0; j < W; j++) {
            coordinate.at(i).at(j)++;
          }
        }
        break;
      default:
        break;
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (coordinate.at(i).at(j) == 0){
        ans++;
      }
    }
  }

  printf("%d", ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <algorithm>
using namespace std;

const int N = 123;

char a[N], b[N], c[N];

int calc(int idx) {
  map<char,int> mp;
  mp[a[idx]]++;
  mp[b[idx]]++;
  mp[c[idx]]++;
  int mx = -1;
  for (map<char,int>::iterator it = mp.begin(); it != mp.end(); it++) {
    mx = max(mx, it->second);
  }
  return 3 - mx;
}

int main() {
  int n;
  scanf("%d", &n);
  scanf("%s %s %s", a, b, c);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += calc(i);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,q;
    cin >> a >> b >> q;
    VLL s(a), t(b), x(q);
    REP(i,0,a) cin >> s[i];
    REP(i,0,b) cin >> t[i];
    REP(i,0,q) cin >> x[i];
    sort(all(s));
    sort(all(t));
    REP(i,0,q) {
        auto ua = upper_bound(all(s), x[i]);
        auto ub = upper_bound(all(t), x[i]);
        LL lowa,lowb,upa,upb;
        lowa = lowb = upa = upb = 1LL << 60;
        //dump(distance(s.begin(), ua));
        //dump(distance(t.begin(), ub));
        if (ua != s.end()) {
            //dump(*ua - x[i]);
            upa = min(upa, *ua - x[i]);
        }
        if (ua != s.begin()) {
            //dump(x[i] - *(ua - 1));
            lowa = min(lowa, x[i] - *(ua - 1));
        }
        if (ub != t.end()) {
            //dump(*ub - x[i]);
            upb = min(upb, *ub - x[i]);
        }
        if (ub != t.begin()) {
            //dump(x[i] - *(ub - 1));
            lowb = min(lowb, x[i] - *(ub - 1));
        }
        //dump(lowa);
        //dump(lowb);
        //dump(upa);
        //dump(upb);
        LL ans = 1LL << 60;
        ans = min(ans, max(lowa, lowb));
        ans = min(ans, max(upa, upb));
        ans = min(ans, lowa + upb + min(lowa, upb));
        ans = min(ans, lowb + upa + min(lowb, upa));
        cout << ans << endl;
    }
}

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

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

acs = [0] * N
was = [0] * N 

for i in range(M):
    p, s = input().split()
    j = int(p) - 1
    if s == 'AC':
        acs[j] = 1
    elif s == 'WA':
        if acs[j] == 0:
            was[j] += 1

ac, wa = 0, 0
for i in range(N):
    ac += acs[i]
    if acs[i]:
        wa += was[i]

print(ac, wa)


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1e9+7;
const int INF=1001001001;

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

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

pi divv(int a, int b) {
    int res1 = a/b;
    int res2 = a%b;
    if (res2 < 0) {
        res2 += b;
        if (b > 0) res1--;
        else res1++;
    }
    return pi(res1,res2);
}

int main() {
    int n = ri();
    if (!n) {
        cout << "0" << endl;
        return 0;
    }
    string res;
    while(n) {
        auto i = divv(n, -2);
        n = i.fi;
        int nn = i.se;
        if (nn) res = "1"+res;
        else res = "0"+res;
    }
    
    cout << res << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

double dp[30][1<<8];

struct edge{ int to,cost; };
typedef vector<edge> ve;

int main(void) {
    int n,m,p,a,b;
    while(cin >> n >> m >> p >> a >> b, n){
        a--,b--;

        vi t(n);
        rep(i,n) cin >> t[i];

        vector<ve> v(m);

        rep(i,p){
            int x,y,z;
            cin >> x >> y >> z;
            x--;y--;
            struct edge e;
            e.to = y;
            e.cost = z;
            v[x].push_back(e);
            e.to = x;
            v[y].push_back(e);
        }

        rep(i,m)rep(j,1<<n) dp[i][j] = INF;
        dp[a][0] = 0;

        queue<pii> q;
        q.push(pii(a,0));//現在地、使った馬車券

        while(q.size()){
            int now = q.front().first;
            int s = q.front().second;
            q.pop();
            //cout << now << " " << s << endl;
            rep(i,v[now].size()){
                int next = v[now][i].to;
                int c = v[now][i].cost;

                rep(j,n)if((s & (1<<j)) == 0){//馬車券 t[j] を使える
                    double x = 1.0 * c / t[j]; //かかる時間
                    int ns = s | (1 << j); //行き先
                    if(dp[next][ns] > dp[now][s] + x){
                        dp[next][ns] = dp[now][s] + x;
                        q.push(pii(next, ns));
                    }
                }

            }
        }

        double ans = INF;
        rep(j,1<<n) ans = min(ans,dp[b][j]);

        if(abs(ans - INF) < EPS){
            cout << "Impossible" << endl;
        }else{
            cout << shosu(5) << ans << endl;
        }
    }
}




Measured memory_bytes: 3396
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)
using namespace std;

int main(){
	int n = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int count = 0, year = 0, month = 0, day = 0;
		cin >> year >> month >> day;
		for(int j = year; j < 1000; j++){
			if(j % 3 == 0){
				count += 20 - day + 1 + 20 * (10 - month);
				day = 1;
			}
			else{
				for(int k = month; k <= 10; k++){
					if(k % 2 == 0){
						count += 19 - day + 1;
					}
					else{
						count += 20 - day + 1;
					}
					day = 1;
				}
			}
			month = 1;
		}
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e3 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, v, u, timer, V, U, p[N][N], d[N][N];
queue < int > q;
vi g[N];


main () {
	cin >> n >> m;
	while (m--) {
		cin >> v >> u;
		g[v].pb(u);
	}
	
	forn (i, 1, n) {
		memset(p[i], -1, sizeof(p[i]));
		p[i][i] = 0;
		q.push(i);

		while (sz(q)) {
			v = q.front();
			q.pop();

			for (auto to : g[v]) 
				if (p[i][to] == -1) {
					p[i][to] = v;				
					d[i][to] = d[i][v] + 1;
					q.push(to);
				}
		}
	}

	int ii = 0, jj = 0;
	forn (i, 1, n)
		forn (j, i + 1, n)
			if (p[i][j] > -1 && p[j][i] > -1 && (!ii || d[i][j] + d[j][i] < d[ii][jj] + d[jj][ii]))  {
				ii = i;
				jj = j;				
			}

	if (!ii) {
		cout << -1;
		return 0;
	}
		

	int i = ii, j = jj;
	set < int > ans;

	ii = i, jj = j;
	while (jj != ii) {
		ans.insert(jj);
		jj = p[ii][jj];
	}
	ii = i, jj = j;
	while (ii != jj) {
		ans.insert(ii);
		ii = p[jj][ii];
	}

	cout << sz(ans) << endl;
	for (auto x : ans)
		cout << x << endl;
}

    

Measured memory_bytes: 16256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define P(p) cout<<(p)<<endl;
using namespace std;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ll gcd(ll a, ll b){
	if (b > a)swap(a, b); if (b == 0)return a; else{ return gcd(b, a%b); }
}


void solve() {
	int n, w;
	cin >> n >> w;
	int dp[20000];
	fill(dp, dp + w, 0);
	int value[101], weight[101];
	rep(i, n){
		cin >> value[i] >> weight[i];
	}
	for (int i = 0; i < n; i++){
		for (int j = weight[i]; j <= w; j++){
			dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
		}
	}
	int maxi = -1;
	rep(i, w + 1){
		maxi = max(maxi, dp[i]);
	}
	P(maxi);
}

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

Measured memory_bytes: 1212
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    int A, B;
    cin >> A >> B;

    if (B % A == 0) {
        printf("%d\n", A + B);
    } else {
        printf("%d\n", B - A);
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n;
	int k;
	int sum=0;
	scanf("%d%d",&n,&k);
	int p[n];
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	int min=1000;
	int key;
	for(int j=0;j<k;j++){
		min=1000;
		for(int i=0;i<n;i++){
			if(min>=p[i]){
				min = p[i];
				key=i;
			}
		}
		p[key]=1001;
		/*for(int t=0;t<n;t++){
			printf("p[%d]:%d",t,p[t]);
		}printf("\n");*/
		sum+=min;
		//printf("%d\n",sum);
	}
	printf("%d",sum);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int a, b; cin >> a >> b;
   int ans;
   if (a >= 13) {
      ans = b;
   } else if (a >= 6) {
      ans = b/2;
   } else {
      ans = 0;
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std ;
const int N = 1e7 + 4;
void FastInputOutput()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline ll LLD()
{
    ll ret;
    scanf("%lld", &ret);
    return ret;
}
inline int D()
{
    int ret;
    scanf("%d", &ret);
    return ret;
}
void bin( int x )
{
    if(!x)
        return;
    bin( x / 2 );
    cout << x % 2 ;
}
bool checkPrimeNumber(int n)
{
    bool flag = true;
    for(int j = 2 ; j <= n ; ++j)
    {
        if (n % j == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}
bool cmp(string last, string first)
{
    if(last.size() < first.size())
        return 1;
    return 0;
}
int calculateDigit(int n)
{
    double temp = (double)(n);
    double a = 0.39908-(0.434294 * n);
    double b = log10( n ) ;
    double c = ( n + 0.5 ) * b ;
    double ans = c - abs( a ) ;
    return ceil(ans) ;
}
int findDigits(int n)
{
    double E = 2.71828182845904523536;
    double PI = 3.141592654;

    if (n < 0)
        return 0;
    if (n <= 1)
        return 1;

    double x = ((n * log10(n / E) +
                 log10(2.0 * PI * n) /
                 2.0));

    return floor(x) + 1;
}
ll fact(ll n)
{
    ll ans = 1 ;
    for(ll i = 1 ; i <= n ; ++i)
        ans *= i ;
    return ans ;
}
unsigned long long Factorial(int n)
{
    const unsigned int M = 1000000007;
    unsigned long long f = 1;
    for (int i = 1; i <= n; i++)
        f = (f*i) % M;

    return f;
}
int a[ N ], b[ N ];
int arr[ N ] , cm[ N ] ;
int n, k ;
int ansL, ansR ;
bool can(int x)
{
    for(int i = 1, j = x ; j <= n ; ++j, ++i)
    {
        if(cm[ j ] - cm[i - 1] + k >= x)
        {
            ansL = i, ansR = j ;
            return true ;
        }
    }
    return false ;
}
int BS(int n)
{
    int low = 0, high = n ;
    while(low < high)
    {
        int mid = (low + high + 1) >> 1 ;
        if(can(mid))
            low = mid ;
        else
            high = mid - 1 ;
    }
    return low ;
}
int main()
{
    FastInputOutput() ;
    ll n , a ;
    cin >> n >> a ;
    if(a >= n % 500)
        cout << "Yes" << endl ;
    else
        cout << "No" << endl ;
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define MAX_SIZE 100000

int main(){

    int i,j;

	char* str;
    int cnt_zero_start,cnt_nonzero_start;

    cnt_zero_start = 0;    //010101...
    cnt_nonzero_start = 0; //101010...

    str = (char*)malloc(sizeof(char *) * 10);

    scanf("%s",str);

    for(i = 0; str[i] != '\0' ; i++){
        if(i%2){//even
            if(str[i] == '0'){//0
                cnt_zero_start++;
            }else{//1
                cnt_nonzero_start++;
            }
        }else{//odd
            if(str[i] == '0'){//0
                cnt_nonzero_start++;
            }else{//1
                cnt_zero_start++;
            }
        }
    }

    if(cnt_zero_start<cnt_nonzero_start)
        printf("%d\n",cnt_zero_start);
    else
        printf("%d\n",cnt_nonzero_start);    

	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a
from collections import Counter
n, p = map(int, input().split())

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

primes = prime_factorize(p)
c = Counter(primes)
ans = 1
for k, v in c.items():
    if v >= n:
        ans *= k ** (v // n)
print(ans)

# 素因数分解して、各数の個数をカウントする。個数がn以上のものの中で、最大値を探す。
# 複数ある場合は、それらをかけ算したものになる。

Measured memory_bytes: 65652
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=1000005;

int f[N+1];int present[N+1];

void solve()
{
    int n;
    cin>>n;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        f[x]++;
        present[x]=1;
    }
    
    for(int i=N;i>=1;i--)
    {
        for(int j=2*i;j<=N;j+=i)
            f[j]+=f[i];
    }
    int ans=0;
    for(int i=1;i<=N;i++)
        if(f[i]==1&&present[i])
        {
            ans++;
        }
    cout<<ans<<endl;
    
    
   
    
    
}



int32_t main()
{
    IOS;
    
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int ans = H * W;
    ans -= h * W;
    ans -= w * H;
    ans += h * w;
    cout << ans << endl;
}

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

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

  int a[n];
  int b[n];
  int c[n-1];

  rep(i, n) {
    cin >> a[i];
  }

  rep(i, n) {
    cin >> b[i];
  }

  rep(i, n-1) {
    cin >> c[i];
  }

  ans = 0;
  rep(i, n) {
    int index = a[i] - 1;
    ans += b[index];
    if (a[i] + 1 == a[i + 1]) ans += c[index];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

#define INF 1e+9
#define MAX_V 200000

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;

        for(int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int M;
    cin >> V >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back({b, 1});
        G[b].push_back({a, 1});
    }
    dijkstra(0);
    if(d[V - 1] <= 2)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 15080
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n;
    while(cin >> n) {
        if(!n) break;
        vector<int> v(n);
        rep(i,0,n) cin >> v[i];
        sort(v.begin(), v.end());

        int mi = INF;
        rep(i,1,n) {
            int temp = v[i] - v[i-1];
            mi = min(mi, temp);
        }
        cout << mi << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	int vs[500][500];
	LL sum=0;
	LL u=1e9;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			int v=0;
			if(i%h==h-1&&j%w==w-1){
				v=-u;
			}
			else if(i%h==0&&j%w==0){
				v=u-1;
			}
			vs[i][j]=v;
			sum+=v;
		}
	}
	if(sum>0){
		cout << "Yes" << endl;
		for(int i=0;i<H;i++){
			auto sp="";
			for(int j=0;j<W;j++){
				cout << sp << vs[i][j];
				sp=" ";
			}
			cout <<endl;
		}
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[200002];
int N;
int main(){
  int i, j=0;
  long long res=0;
  N = rd(S);
  for(i=N-1;i>=0;i--){
    if(S[i]=='W'){
      j++;
    }
    else{
      res += j;
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int N;
// char S[200002];
// {
//   int i, j = 0;
//   ll res = 0;
//   rd(S@N);
//   for(i=N-1;i>=0;i--){
//     if(S[i]=='W') j++; else res += j;
//   }
//   wt(res);
// }


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	int s=n*a;
	if(s>=b)
	{
		cout<<b<<endl;
		return 0;
	}
	if(s<b)
	{
		cout<<s<<endl;
		return 0;
	}
}

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

using namespace std;

static const int NMAX = 2*1e5+5;
static const int MOD = 2019;

int dp[2][MOD];
int rest[NMAX];

typedef long long ll;

int main()
{
    string s;
    cin >> s;

    dp[0][s[0]-'0'] = 1;

    for(int i = 1; i< 1e5; ++i)
    {
        rest[i] = i % 2019;
    }
    ll ans = 0;

    int n = (int)s.length();
    for(int i = 1; i< n; ++i)
    {
        for(int j = 0 ; j< 2019; ++j)
        {
            int nxt = rest[j * 10+ (s[i]-'0')];
            dp[1][nxt]+= dp[0][j];
        }
		ans += dp[1][0];

		memcpy(dp[0],dp[1],sizeof(dp[1]));
		dp[0][s[i] - '0']++;
		memset(dp[1],0,sizeof(dp[1]));
    }
	cout << ans;
    return 0;
}


Measured memory_bytes: 4172
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
int x[100];

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> x[i];

    int ans = INT_MAX;
    forn1(p, 100) {
        int temp = 0;
        forn(i, n) {
            temp += (x[i] - p) * (x[i] - p);
        }
        chmin(ans, temp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll a[4];
ll n,m;
 
int main(){
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	ll kotae=INF,ans=0;
	for(i=-5;i<=55;i++){
		for(j=0;j<=2;j++){
			if(i<a[j])ans+=(a[j]-i);
			else if(a[j]<i){
				if((i-a[j])%2==0){
					ans+=(i-a[j])/2;
				}else{
					ans=INF;
				}
			}
		}
		kotae=min(ans,kotae);
		ans=0;
	}
	cout<<kotae<<endl;
	return 0;
}

Measured memory_bytes: 4992
N, K = map(int, input().split())
x = 10
y = 10 + N

ans = 0
a = x
b = y
for i in range(1, N + 2):
    if i >= K:
        ans += b - a + 1
    a += (x + i)
    b += (y - i)

print(ans % (10 ** 9 + 7))


Measured memory_bytes: 9060
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), ansA = 0, ansB = 0;
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a, Comparator.reverseOrder());

		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				ansA += a[i];
			} else {
				ansB += a[i];
			}
		}
		System.out.println(ansA-ansB);
	}

}

Measured memory_bytes: 21972
//Classic
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 1000000007
#define ciN cin
#define X INT_MAX
#define N INT_MIN
////////////////////////////////////////////////////////////////


void solve() {
	string a, b; ciN >> a >> b;
	ll ans = X;
	for (int i = 0; i <= a.size() - b.size(); i++) {
		int curr = 0;
		For(j, 0, b.size()) {
			if (b[j] != a[i + j]) {
				curr++;
			}
		}
		ans = min(1LL * curr, ans);
	}
	cout << ans << endl;
}




////////////////////////////////////////////////////////////////


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

	//int t; cin >> t;
	//while (t--)
	solve();


	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???



Measured memory_bytes: 3652
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		String s = stdIn.next();
		if(a>=3200){
			System.out.println(s);
		}else{
			System.out.println("red");
		}
	}

}


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

int main(){
	int n,m;
	cin>>n>>m;
	
	int a[m+5],sum=0;
	for(int i=1;i<=m;i++){
		cin>>a[i];
		sum+=a[i];
	}  
	
	if(n<sum)  cout<<-1<<endl;
	else       cout<<n-sum<<endl;
		
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
//unionfind
const int MAX_N = 100010;
ll m, n;
int par[MAX_N];    //親
int deapth[MAX_N]; //木の深さ
int cnt[MAX_N];
ll num;

//n要素で初期化
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        deapth[i] = 0;
        cnt[i] = 1;
    }
}
//木の根を求める
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (deapth[x] < deapth[y])
    {
        par[x] = y;
        cnt[y] += cnt[x];
    }
    else
    {
        par[y] = x;
        cnt[x] += cnt[y];
        if (deapth[x] == deapth[y])
            deapth[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}
int main()
{
    cin >> n >> m;
    init(n);
    vector<int> v(m + 1, -1);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int x;
            cin >> x;
            if (v[x - 1] == -1)
            {
                v[x - 1] = i;
            }
            else
            {
                unite(i, v[x - 1]);
            }
        }
    }
    rep(i, n - 1)
    {
        if (!same(i, i + 1))
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define MP make_pair
#define int ll int

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
const int MAX = 1e4 + 5;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int n,k,s;
    cin>>n>>k>>s;int ar[n+1];
    for(int i=1;i<=k;i++)ar[i]=s;
    if(s!=1000000000)
    for(int i=k+1;i<=n;i++)ar[i]=s+1;
    else 
    for(int i=k+1;i<=n;i++)ar[i]=s-1;
    
    for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
}


return 0;
}





Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    char s[1024];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (s[i] == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256