akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj2107/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aoj2107/result.txt")));
			if (false) throw new FileNotFoundException();
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			solve();
		}
	}


	int[][] identity(int n) {
		int[][] A = new int[n][n];
		for (int i = 0; i < n; i++) A[i][i] = 1;
		return A;
	}

	int[][] mul(int[][] A, int[][] B) {
		int I = A.length, J = B[0].length, K = B.length;
		int[][] C = new int[I][K];
		for (int i = 0; i < I; i++)
			for (int j = 0; j < J; j++)
				for(int k = 0; k < K; k++){
					C[i][j] |= A[i][k] & B[k][j];
					if (C[i][j] > 0) break;
					// C[i][j] += A[i][k] * B[k][j];
					// if (C[i][j] >= MOD) C[i][j] %= MOD;
				}
		return C;
	}
	int[][] pow(int[][] A, long b) {
		int[][] C = identity(A.length);
		while (b > 0) {
			if ((b & 1) == 1) C = mul(C, A);
			A = mul(A, A);
			b >>= 1;
		}
		return C;
	}

	void solve()
	{
		int n = sc.nextInt();
		int m = sc.nextInt();
		int z = sc.nextInt();
		if (0 == (n | m | z)) return;

		int[][] edge = new int[m][2];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			edge[i][0] = a;
			edge[i][1] = b;

		}

		// 直前に使ったエッジが e で、0 の側の頂点に居る <=> i=2*e+0
		// A[i][j] := i から j へ一歩で到達可能なら 1
		// A^x[i][j] := i から j へ x 歩で到達可能なら 1
		int[][] A = new int[2*m][2*m];
		int[][] B = new int[2*m][2*m];

		for (int e = 0; e < m; e++) {
			B[2 * e + 0][2 * e + 1] = 1;
			B[2 * e + 1][2 * e + 0] = 1;
		}

		for (int i = 0; i < 2 * m; i++) {
			int cur = edge[i/2][i%2];
			int prev = edge[i/2][1-i%2];
			for (int e = 0; e < m; e++) {
				if (cur == edge[e][0] && prev != edge[e][1]) {
					A[i][e*2 + 1] = 1;
				}
				if (cur == edge[e][1] && prev != edge[e][0]) {
					A[i][e*2 + 0] = 1;
				}
			}
		}

		int [][] Az = pow(A, z - 1);
		Az = mul(B, Az);

		boolean can = false;
		for (int i = 0; i < 2 * m; i++)
			for (int j = 0; j < 2 * m; j++) {
				if (Az[i][j] > 0) {
					int a = edge[i/2][i%2];
					int b = edge[j/2][j%2];
					if (a == 0 && b == n - 1) {
						can = true;
					}
				}
			}
		System.out.println(can ? "yes":"no");
	}

}

Measured memory_bytes: 14000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		System.out.println((long)a*(long)b/gcd(a,b));
	}
	
	public int gcd(int a, int b) {
		if (a < b) {
			int swap = a;
			a = b;
			b = swap;
		}
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32648
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
	node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
	return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
	return;
      }
      if (node[x].rank < node[y].rank) {
	node[x].par = y;
      } else {
	node[y].par = x;
	if (node[x].rank == node[y].rank) {
	  ++node[x].rank;
	}
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}
  
int main(void) {
  int size, n_query, block_size;
  std::cin.read((char *)&size, sizeof(int));
  std::cin.read((char *)&n_query, sizeof(int));
  std::cin.read((char *)&block_size, sizeof(int));

  std::vector<uint64_t> query(n_query * block_size);
  std::cin.read((char *)query.data(), sizeof(uint64_t) * n_query * block_size);

  const int mask = (1 << 30) - 1;

  uint64_t res = 123456789;
  for(int b = 0; b < block_size; ++b) {
    procon::UnionFind uf(size);
    for (int i = 0; i < n_query; ++i) {
      uint64_t q = query[b * n_query + i];
      const int com = q >> 60;
      const int x = (q >> 30) & mask;
      const int y = (q >> 0) & mask;
      assert(0 <= x && x < size);
      assert(0 <= y && y < size);
      if (com) {
        res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
      } else {
        uf.unite(x, y);
      }
    }
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 81784
import java.math.BigDecimal;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<Double> x = new ArrayDeque<Double>();
		ArrayDeque<Double> y = new ArrayDeque<Double>();
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			int e = sc.nextInt();
			int f = sc.nextInt();
			
			double t = (double)(d*c-a*f)/(d*b-a*e);
			double s = (double)(c-t*b)/a;
			x.push(s);
			y.push(t);
		}
		int num = x.size();
		for(int i=0;i<num;i++){
			BigDecimal bdx = new BigDecimal(x.pollLast());
			BigDecimal bdy = new BigDecimal(y.pollLast());

			BigDecimal ansx = bdx.setScale(4, BigDecimal.ROUND_HALF_UP);
			BigDecimal ansy = bdy.setScale(4, BigDecimal.ROUND_HALF_UP);
			
			System.out.printf("%.3f", ansx.doubleValue());
			System.out.print(" ");
			System.out.printf("%.3f", ansy.doubleValue());
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 20232
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    vector<int> log;

    int N,K;
    cin>>N>>K;

    for(int i=0;i<N;i++){
        int A;
        cin>>A;
        log.push_back(A);
    }

    int l=0;
    int r=LLONG_MAX;
    while(1){
        int m=(l+r)/2;
        if(m==0) break;
        int c=0;
        for(int i=0;i<log.size();i++){
            c+=log[i]/m+(log[i]%m!=0)-1;
        }
        if(c<=K){
            if(r==m) break;
            r=m;
        }
        else{
            if(l==m) break;
            l=m;
        }
    }
    cout<<r<<endl;
}



Measured memory_bytes: 4872
import java.util.Scanner;
public class Main{
  
  public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
    String str1 = scan.next();
    String str2 = scan.next();

 	int a = Integer.parseInt(str1);
    int b = Integer.parseInt(str2);
    
    if(a < b){
      int tmp = b;
      b = a;
      a = tmp;
    }
    
      if(a<0 || a>8 || b<0 || b>8 || a+b > 16)
        System.out.println(":(");
	  else
        System.out.println("Yay!");
    }
}

Measured memory_bytes: 35204
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<iosfwd>
#include<sstream>
#include <algorithm>
#define N 100
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    sort(a.begin(), a.end());
    int cnt=1;

    for(int i=1; i<n; i++) {
        if(a[i-1]!=a[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  llvec v(M, 0);
  rep(i, N){
    ll K;
    cin >> K;
    rep(j, K){
      ll a;
      cin >> a;
      v[a-1]++;
    }
  }
  ll ans = 0;
  rep(i, M)ans += v[i]==N?1:0;
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
s = input()
K = int(input())

for i in range(len(s)-1):
    z2a = (ord('z') + 1 - ord(s[i])) % 26
    if z2a <= K:
        s = s[:i] + 'a' + s[i+1:]
        K -= z2a

print(s[:len(s)-1] + chr(((ord(s[len(s)-1]) - ord('a')) + K % 26) % 26 + ord('a')))

Measured memory_bytes: 3452
#include<stdio.h>
#include<string.h>

#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,L,x;
  l=i*2;
  r= 2*i+1;

  if(l<=H && A[l]>A[i]) L=l;
  else L=i;
   if(r<=H && A[r]>A[L]) L=r;

   if(L!=i){
     x=A[i];
     A[i]=A[L];
     A[L]=x;
     maxHeapify(L);
   }
}

int extract(){
  int maxv,x;
  if (H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  int x;
  if (key<A[i]) return;
   A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    x=A[i];
    A[i]=A[i/2];
    A[i/2]=x;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else {
      printf("%d\n",extract());
    }
  }

  return 0;
}



Measured memory_bytes: 5628
#include <cstdio>

int n;
int ans;

int main(){
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		int l, r;
		scanf("%d %d", &l, &r);
		ans += r - l + 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>

typedef long long ll;

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
using namespace std;
ll n, x;
struct T{
    ll b, l, r;
    pair<ll, ll> tt;
};
vector<T> a;
bool comp(T a, T b)
{
    return a.tt > b.tt;
}

bool can(ll t)
{
    ll full = t / x;
    ll more = t % x;
    for (int i = 0; i < a.size(); i++)
        a[i].tt = {(x - a[i].b) * a[i].r + a[i].l * a[i].b, a[i].b * a[i].l + max(0LL, more - a[i].b) * a[i].r};
    sort(a.begin(), a.end(), comp);
    ll we = 0, he = 0;
    for (int i = 0; i < full; i++)
    {
        we += x * a[i].r;
        he += a[i].b * a[i].r;
    }
    for (int i = full; i < n; i++)
    {
        he += a[i].l * a[i].b;
    }
    for (int i = full; i < n; i++)
    {
        he += (a[i].r - a[i].l) * a[i].b;
        we += a[i].r * more;
        if (we >= he)
            return 1;
        we -= a[i].r * more;
        he -= (a[i].r - a[i].l) * a[i].b;

        we += a[i].l * more;
        if (we >= he)
            return 1;
        we -= a[i].l * more;
    }
    we += x * a[full].r;
    he += a[full].b * (a[full].r - a[full].l);
    for (int i = 0; i < full; i++)
    {
        we -= x * a[i].r;
        we += more * a[i].r;
        if (we >= he)
            return 1;
        we -= more * a[i].r;
        we += x * a[i].r;

        we -= x * a[i].r;
        we += more * a[i].l;
        he -= (a[i].r - a[i].l) * a[i].b;
        if (we >= he)
            return 1;
        we += x * a[i].r;
        we -= more * a[i].l;
        he += (a[i].r - a[i].l) * a[i].b;
    }
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        int b, l, r;
        cin >> b >> l >> r;
        a.push_back({b, l, r});
    }
    ll l = -1, r = n * x;
    while (l + 1 < r)
    {
        ll mid = (l + r) / 2;
        if (can(mid))
            r = mid;
        else
            l = mid;
    }
    cout << r;
}


Measured memory_bytes: 7536
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if((a<c&&c<b) || (b<c&&c<a)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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



int main() {
    int n;
    cin >> n;
   
    if(n/100==n%10) cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll n, m;
vll c;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    c.resize(m);
    for (ll i = 0; i < m; i++) cin >> c[i];

    vll dp(n + 1, HIGHINF);
    dp[0] = 0;
    for (ll i = 0; i < m; i++) {
        for (ll j = 0; j < n; j++) {
            if (j + c[i] <= n) chmin(dp[j + c[i]], dp[j] + 1);
        }
    }

    cout << dp[n] << '\n';
    return 0;
}



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

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }

    int dp[n+1];
    dp[0]=dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n]<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
int main(){
	long long d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int total,a;
  char ch, r;
  int j,i;
  int cards[4][13];
 
  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      cards[i][j]=0;
    }
  }
 
  scanf("%d",&total);
  for(a=0;a<total;a++){
    scanf("%c%c %d",&r,&ch,&j);
    if(ch=='S') i=0;
    if(ch=='H') i=1;
    if(ch=='C') i=2;
    if(ch=='D') i=3;
    cards[i][j]=1;
  }
  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      if(cards[i][j]!=1){
    if(i==0) ch='S';
    if(i==1) ch='H';
    if(i==2) ch='C';
    if(i==3) ch='D';
    printf("%c %d\n",ch,j);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2036
#include <cstdio>
int h, w, cnt;
char a[55][55];
int main() {
	int i, j, x, y;
	scanf("%d%d", &h, &w);
	for(i=1; i<=h; i++) scanf("%s", &a[i][1]);
	for(i=1; i<=h; i++, puts("")) for(j=1; j<=w; j++) {
		if(a[i][j]=='#') {printf("#"); continue;}
		cnt = 0;
		for(x=i-1; x<=i+1; x++) for(y=j-1; y<=j+1; y++) if(a[x][y]=='#') cnt++;
		printf("%d", cnt);
	}
	return 0;
}


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

string s, t;
int x, ans;

int main() {
  cin >> s >> t;
  ans = 10000;
  rep (i, s.size()-t.size()+1) {
    x = 0;
    rep (j, t.size()) {
      if (s[i+j] != t[j]) x++;
    }
    ans = min(ans, x);
  }
  cout << ans << endl;
  return 0;
}


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

int gcd(int lhs, int rhs)
{
  int a = max(lhs, rhs);
  int b = min(lhs, rhs);
  while (a % b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }
  return b;
}

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

  deque<int> q;
  rep(i,0,N-1) {
    int a;
    cin >> a;
    q.push_back(a);
  }

  while (1 < q.size()) {
    int a = q.front(); q.pop_front();
    int b = q.front(); q.pop_front();
    int c = gcd(a, b);
    q.push_front(c);
  }

  cout << q.front() << endl;
  return 0;
}


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

long long R, C, N;
long long X1[100005];
long long X2[100005];
long long Y1[100005];
long long Y2[100005];

#define LEFT   0
#define TOP    1
#define RIGHT  2
#define BOTTOM 3
#define ERROR  4

vector<pair<long long, long long> >lleft;
vector<pair<long long, long long> >top;
vector<pair<long long, long long> >rright;
vector<pair<long long, long long> >bottom;

bool isedge(long long x, long long y){
	return (x == 0 || x == R || y == 0 || y == C);
}


int where(long long x, long long y){
	if(x == 0 && y < C){
		return LEFT;
	}
	if(y == 0 && x > 0){
		return TOP;
	}
	if(x == R && y > 0){
		return RIGHT;
	}
	if(y == C && x < R){
		return BOTTOM;
	}
	return ERROR;
}



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

	for(long long i = 0; i < N; i++){
		cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		if(isedge(X1[i], Y1[i]) && isedge(X2[i], Y2[i])){
			int pos = where(X1[i], Y1[i]);
			int x = X1[i];
			int y = Y1[i];
			if(pos == LEFT){
				lleft.push_back(make_pair(y, i));
			}else if(pos == TOP){
				top.push_back(make_pair(x, i));
			}else if(pos == RIGHT){
				rright.push_back(make_pair(y, i));
			}else if(pos == BOTTOM){
				bottom.push_back(make_pair(x, i));
			}else{
				return 1;
			}

			pos = where(X2[i], Y2[i]);
			x = X2[i];
			y = Y2[i];
			if(pos == LEFT){
				lleft.push_back(make_pair(y, i));
			}else if(pos == TOP){
				top.push_back(make_pair(x, i));
			}else if(pos == RIGHT){
				rright.push_back(make_pair(y, i));
			}else if(pos == BOTTOM){
				bottom.push_back(make_pair(x, i));
			}else{
				return 1;
			}
		}
	}

	//down to up
	sort(lleft.begin(), lleft.end(), greater<pair<long long, long long> >());
	sort(top.begin(), top.end());
	sort(rright.begin(), rright.end());
	sort(bottom.begin(), bottom.end(), greater<pair<long long, long long> >());

	stack<long long> st;
	for(int i = 0; i < lleft.size(); i++){
		if(st.size() > 0 && st.top() == lleft[i].second){
			st.pop();
		}else{
			st.push(lleft[i].second);
		}
	}
	for(int i = 0; i < top.size(); i++){
		if(st.size() > 0 && st.top() == top[i].second){
			st.pop();
		}else{
			st.push(top[i].second);
		}
	}
	for(int i = 0; i < rright.size(); i++){
		if(st.size() > 0 && st.top() == rright[i].second){
			st.pop();
		}else{
			st.push(rright[i].second);
		}
	}
	for(int i = 0; i < bottom.size(); i++){
		if(st.size() > 0 && st.top() == bottom[i].second){
			st.pop();
		}else{
			st.push(bottom[i].second);
		}
	}

	if(st.size() == 0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}


}



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

template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}

const long long INF = 1LL << 60;

int main() {
  int N,K;
  cin >> N >> K;
  int h[N + 10];
  for (int i = 0; i < N; ++i) cin >> h[i];
  long long dp[N + 110];
  for (int i = 0; i < N; ++i) dp[i] = INF;
  dp[0] = 0;
  
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));  
    }
  }
  cout << dp[N-1] << endl;
}

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

int main() {
    int x;
    cin >> x;
    int a;
    cin >> a;
    int b;
    cin >> b;
    int y = x - a;
    while (y >= b) {
        y = y - b;
    }
    cout << y << endl;
    return 0;
}

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

int A[1000000], n;

int main(){
    cin >> n;
    for (int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    
    int q, k, sum=0;
    cin >> q;
    for (int i = 0; i < q; i++){
        scanf("%d", &k);
        // 標準ライブラリのlower_boundを使用
        if (*lower_bound(A, A+n, k) == k) sum++;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=13){
		cout<<b<<endl;
	}
	else if(a<=5){
		cout<<0<<endl;
	}
	else {
		cout<<b/2<<endl;
	}
}



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

int n, m, p;
int grid[7][7][7];
int height[7][7];
int x[7 * 7 * 7], y[7 * 7 * 7];

bool inBounds(int x, int y, int z){
	if (min({x, y, z}) < 0) return false;
	if (max({x, y, z}) >= n) return false;
	return true;
}

bool check(int x, int y, int z)
{
	int color = grid[x][y][z];
	for (int dx = -1; dx <= 1; dx++){
		for (int dy = -1; dy <= 1; dy++){
			for (int dz = -1; dz <= 1; dz++){
				if (!(dx | dy | dz)) continue;
				bool f = true;
				for (int i = 0; i < m; i++){
					int nx = x + dx * i;
					int ny = y + dy * i;
					int nz = z + dz * i;
					if (!inBounds(nx, ny, nz)){
						f = false;
						break;
					}
					if (grid[nx][ny][nz] != color){
						f = false;
						break;
					}
				}
				if (f) return true;
			}
		}
	}
	return false;
}

int solve()
{
	memset(grid, -1, sizeof(grid));
	memset(height, 0, sizeof(height));
	for (int i = 0; i < p; i++){
		int t = grid[x[i]][y[i]][height[x[i]][y[i]]++] = i & 1;
		for (int x = 0; x < n; x++)
			for (int y = 0; y < n; y++)
				for (int z = 0; z < n; z++)
					if (t == grid[x][y][z] && check(x, y, z)) return i + 1;
	}
	return -1;
}

int main()
{
	while (scanf("%d %d %d", &n, &m, &p), n){
		for (int i = 0; i < p; i++){
			scanf("%d %d", x + i, y + i);
			x[i]--; y[i]--;
		}
		int res = solve();
		if (res == -1) puts("Draw");
		else printf("%s %d\n", res & 1 ? "Black" : "White", res);
	}
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
long long n,p,total;
long long arr[200001];
long long power(long long x,long long y){
    long long ans=1;
    x%=p;
    while (y>0){
        if (y%2==1) ans=(ans*x)%p;
        y/=2;
        x=(x*x)%p;
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++) cin>>arr[i];
    p=1e9+7;
    sort(arr,arr+n);
    long long inv=power(2,p-2);
    for (int i=0;i<n;i++){
        long long j=n-i-1;
        long long cur=power(2,j)*power(2,i);
        cur%=p;
        cur*=(j+2);
        cur%=p;
        cur*=inv;
        cur%=p;
        total+=arr[i]*cur;
        total%=p;
    }
    cout<<(total*power(2,n))%p;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);

  int i = 1, x;
  for(i = 1; i <= n; ++i)
  {
    x = i;
    if(x%3 == 0){
      printf(" %d",i);
    }
    else{
      while(1)
      {
        if(x%10 == 3){
          printf(" %d",i);
          break;
        }
        x /= 10;
        if(x == 0){
          break;
        }
      }
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2036
import sys
h,w=[int(i) for i in input().split()]
map=[]
for i in range(h):
    map.append([str(i) for i in input()])
new_map=[]
for i in range(h):
    new_map.append(map[i])
    new_map.append(map[i])

for i in range(h*2):
    for j in range(w):
        sys.stdout.write(str(new_map[i][j]))
    print()

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

struct lagu{
	int durasi;
	string nama;
};

int main(){
	//ios::sync_with_studio(false);
	cin.tie(0);
	
	int N; cin >> N;
	vector<lagu> playlist;
	vector<int> wow;
	for(int i = 0; i < N; i++){
		int a; string b;
		cin >> b >> a;
		playlist.push_back({a, b});
	}
	
	string X; cin >> X;
	int sum = 0;
	bool cek = false;
	for(int i = 0; i < N; i++){
		if(!cek){
			if(playlist[i].nama == X)
				cek = true;
		}
		else{
			sum += playlist[i].durasi;
		}
	}
	
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
d=100
for i in range(n):
  s1=0
  s2=0
  for j in range(i+1):
    s1=s1+w[j]
  for k in range(i+1,n):
    s2=s2+w[k]
  if abs(s1-s2)<d:
    d=abs(s1-s2)
print(d)

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

bool IsExist(vector<int>& S, int Number);

bool IsExist(vector<int>& S, int Number)
{
    int left = 0;
    int right = S.size();
    
    while(left < right){
        int Index = (left + right) / 2;
        if(S[Index] == Number){
            return true;
        } else if(Number < S[Index]){
            right = Index;
        } else{
            left = Index + 1;
        }
    }
    return false;
}

int main(void){
    int n, q, Number, count;
    bool Exist;
    vector<int> S;
    
    std::cin >> n;
    S.clear();
    for(int i = 0; i < n; i++){
        std::cin >> Number;
        if(S.empty()){
            S.push_back(Number);
        } else{
            if(S[S.size() - 1] != Number)   S.push_back(Number);
        }
    }
    
    std::cin >> q;
    count = 0;
    for(int i = 0; i < q; i++){
        std::cin >> Number;
        if(IsExist(S, Number) == true)  count++;
    }
    
    std::cout << count << std::endl;
    
}

Measured memory_bytes: 1532
s = input()

ans = ''
if int(s[0:2])>12 and int(s[2:4])==0:
  ans = 'NA'
elif int(s[0:2])>12 and int(s[2:4])>12:
  ans = 'NA'
elif int(s[0:2])>12 and int(s[2:4])<=12:
  ans = 'YYMM'
elif 0<int(s[0:2]) and int(s[0:2])<=12 and int(s[2:4])==0:
  ans = 'MMYY'
elif 0<int(s[0:2]) and int(s[0:2])<=12 and int(s[2:4])<=12:
  ans = 'AMBIGUOUS'
elif 0<int(s[0:2]) and int(s[0:2])<=12 and int(s[2:4])>12:
  ans = 'MMYY'
elif 0==int(s[0:2]) and 0<int(s[2:4]) and int(s[2:4])<=12:
  ans = 'YYMM'
else:
  ans = 'NA'
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll x,y,a,b,c,p[100005],q[100005],r[100005],ans;
int main(){
	scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
	for(ll i=1;i<=a;i++) scanf("%lld",&p[i]);
	for(ll i=1;i<=b;i++) scanf("%lld",&q[i]);
	for(ll i=1;i<=c;i++) scanf("%lld",&r[i]);
	sort(p+1,p+a+1,greater<ll>());
	sort(q+1,q+b+1,greater<ll>());
	sort(r+1,r+c+1,greater<ll>());
	for(ll i=1;i<=x;i++) ans+=p[i];
	for(ll i=1;i<=y;i++) ans+=q[i];
	for(ll i=1;i<=c;i++){
		if(y<=0||p[x]<=q[y]){
			if(r[i]>p[x]){
				ans-=p[x];
				ans+=r[i];
				x--;
			}
		}
		else if(x<=0||q[y]<=p[x]){
			if(r[i]>q[y]){
				ans-=q[y];
				ans+=r[i];
				y--;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void)
{
    int b,i,j,k;
    int a[30];
    for(i=0;i<30;i++)
    {
        a[i]=0;
    }
    for(j=0;j<28;j++)
    {
        cin>>b;
        a[b-1]=1;
    }
    for(k=0;k<30;k++)
    {
        if(a[k]==0)
        {
            cout<<k+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080
import java.util.Scanner;
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=a*b;
        int d=a*2+b*2;
        System.out.println(c+" "+d);
        
    }

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

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

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

#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 10;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n;
int a[maxn];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    scanf("%d", &n);
    REP(i, 0, n) scanf("%d", a + i);

    sort(a, a + n);
    if(a[n-1] - a[0] > 1) { 
        return puts("No"), 0;
    }

    if(a[n-1] - a[0] == 0) {
        return puts((a[0] == n-1 || a[0] <= n/2) ? "Yes" : "No"), 0;
    }

    int col = a[0], gro = 0;
    for(int i = 1; i < n; i++) {
        if(a[i] == a[0]) 
            -- col;
        else ++ gro;
    }

    puts((col > 0 && col <= gro/2) ? "Yes" : "No");
    
    return 0;
}


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

using namespace std;

//#define debug

#ifdef debug
#define dump(i) cout << "[*] " #i ": " << i << " (" << __LINE__ << ")" << endl
#else
#define dump(i)
#endif

int a, b;

bool isbar(char c) {
  return c == '-';
}

bool check(const string& str) {
  int i;
  for (i = 0; i < str.size(); ++i) {
    if (!isdigit(str[i])) {
      break;
    }
  }
  if (i != a || i == str.size()) {
    dump(i);
    return false;
  }
  if (!isbar(str[i])) {
    dump(str[i]);
    return false;
  }
  ++i;
  for (; i < str.size(); ++i) {
    if (!isdigit(str[i])) {
      dump(str[i]);
      return false;
    }
  }
  if (i != a + b + 1) {
    dump(i);
    return false;
  }

  return true;
}

int main() {
  string s;
  cin >> a >> b;
  cin >> s;
  cout << (check(s) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k;
  if(a>b){
    if(a>c) cout << a*(1 << k)+b+c << endl;
    else cout << a+b+c*(1 << k) << endl;
  } else {
    if(b>c) cout << a+b*(1 << k)+c << endl;
    else cout << a+b+c*(1 << k) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  int ans=0;
  rep(i,3){
    if(s[i]=='1') ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); ++i)

int main()
{
  string n;
  cin >> n;
  int size = n.size();
  int count = 0;
  int flag = 0;
  rep(i, 0, size)
  {
    int num = n[size - 1 - i] - '0' + flag;
    if (num <= 4)
    {
      count += num;
      flag = 0;
    }
    else if (num == 5)
    {
      count += 5;
      if (n[size - 2 - i] - '0' >= 5)
      {
        flag = 1;
      }
      else
      {
        flag = 0;
      }
    }
    else if (num == 10)
    {
      flag = 1;
    }
    else
    {
      count = count + 10 - num;
      flag = 1;
    }
  }
  if (flag == 1)
  {
    count++;
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)

const int pSz = 2000006;
bool np[pSz + 10];
vi prime;
int prime_size;
void sieve()
{
    np[0] = np[1] = 1;
    prime.pb(2);
    for(LL i = 4; i <= pSz; i+=2)
        np[i] = 1;
    for(LL i = 3; i <= pSz; i+=2)
    {
        if(!np[i])
        {
            prime.pb(i);
            for(LL j = i * i; j <= pSz; j += (i << 1))
                np[j] = 1;
        }
    }

}
int main()
{
    sieve();
    LL a,b,cnt=0;
    cin>>a>>b;
    for(int i=0;i<prime.size()&&prime[i]<=min(a,b);i++)
    {
        if(a%prime[i]==0&&b%prime[i]==0)
            cnt++;
        while(a%prime[i]==0)
        {
            a=a/prime[i];
        }

        while(b%prime[i]==0)
        {
            b=b/prime[i];
        }
    }
    if(a==b&&a!=1)
        cnt++;
    cout<<cnt+1;

}


Measured memory_bytes: 3320
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int num = Integer.parseInt(br.readLine());
			int calculationCount = 0;
			int[] intArr;
			boolean isEvenNumber = true;

			String[] stringArr = br.readLine().split(" ");
			intArr = new int[num];

			for (int i = 0; i < num; i++) {
				intArr[i] = Integer.parseInt(stringArr[i]);
			}

			while (true) {
				for (int i = 0; i < num; i++) {
					if (intArr[i] % 2 == 0) {
						calculationCount++;
						intArr[i] = intArr[i] / 2;
					} else {
						isEvenNumber = false;
					}
				}
				if (!isEvenNumber) {
					break;
				}
			}

			System.out.println(calculationCount / num);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 32736
#encoding utf-8

a,b,k = map(int, input().split())
# print(a,b,k)

for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += int(a/2)
        a = int(a/2)
    # turn b
    else:
        if b%2 == 1:
            b -= 1
        a += int(b/2)
        b = int(b/2)



print(a,b)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    string s, t, u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b >> u;
    
    if(s == u) cout << a - 1 << " " << b << endl;
    else cout << a << " " << b - 1 << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(), Q = sc.nextInt();
    String S = sc.next();
    int A[] = new int[S.length() + 1];
    for (int i = 1; i < S.length(); i++)
    {
      if (S.charAt(i - 1) == 'A' && S.charAt(i) == 'C')
      {
        A[i] = 1;
      }
      else
      {
        A[i] = 0;
      }
    }
    int PSA[] = new int[S.length() + 1];
    for (int i = 1; i <= S.length(); i++)
    {
      PSA[i] = PSA[i - 1] + A[i];
    }
    for (int i = 0; i < Q; i++)
    {
      int l = sc.nextInt(), r = sc.nextInt();
      int result = PSA[r - 1] - PSA[l - 1];
      System.out.println(result);
    }
  }
}


Measured memory_bytes: 64160
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N;
int cnt[114514]={0};
int main(){
	ll t,s,a,b,c,d;
	cin>>t>>s;
	cin>>a>>b>>c>>d;
	ll P=(a-c)*t,Q=(b-d)*s;
	if(P==0||(P+Q)==0)cout<<"infinity"<<endl;
	else{
		if(P<0) P*=-1,Q*=-1;
		ll ans=0;
		if(Q<0&&(P+Q)<0){
			ll dif=-(P+Q);
			ll fuga=P/dif + 1;
			fuga*=2;
			fuga--;
			if(P%dif==0)fuga--;
			ans=fuga;
		}
		cout<<ans<<endl;
	}
}





Measured memory_bytes: 256
NN = list(input())
 
for i in range(2**3):
    N = NN[:]
    for j in range(3):
        if i & 2**j:
            if j == 0:
                N.insert(1, '+')
            elif j == 1:
                N.insert(3, '+')
            else:
                N.insert(5, '+')
        else:
            if j == 0:
                N.insert(1, '-')
            elif j == 1:
                N.insert(3, '-')
            else:
                N.insert(5, '-')
    if eval(''.join(N)) == 7:
        print(''.join(N)+'=7')
        break

Measured memory_bytes: 3064
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

struct UnionFind {
    parents: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let par = (0..n).collect();
        UnionFind { parents: par }
    }
    pub fn root(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            return x;
        }
        let par = self.parents[x];
        self.parents[x] = self.root(par);
        self.parents[x]
    }
    pub fn union(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return;
        }
        self.parents[rx] = ry;
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        let rx = self.root(x);
        let ry = self.root(y);
        rx == ry
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, m, k) = parse!(it, 3);
    let mut res = vec![0; n];
    let mut ren = vec![0; n];
    let mut uf = UnionFind::new(n);
    for i in 0..m {
        let (x, y): (usize, usize) = parse!(it, 2);
        uf.union(x - 1, y - 1);
        ren[x - 1] += 1;
        ren[y - 1] += 1;
    }

    for _ in 0..k {
        let (x, y): (usize, usize) = parse!(it, 2);
        let x = x - 1;
        let y = y - 1;
        if uf.is_same(x, y) {
            res[x] += 1;
            res[y] += 1;
        }
    }
    for i in 0..n {
        uf.root(i);
    }
    let mut counts = std::collections::HashMap::new();
    for i in 0..n {
        let r = uf.root(i);
        let mut c = 1;
        if let Some(t) = counts.get(&r) {
            c = *t + 1;
        }
        counts.insert(r, c);
    }
    let ret = (0..n)
        .map(|x| {
            let a = *counts.get(&uf.root(x)).unwrap();
            let b = res[x];
            a - b - ren[x] - 1
        })
        .map(|x: usize| x.to_string())
        .collect::<Vec<_>>()
        .join(" ");
    println!("{}", ret);
}


Measured memory_bytes: 21268
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void)
{
    int n;
    cin >> n;
    long long fb;
    fb = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if ((i % 3 == 0) && (i % 5 == 0))
        {
        }
        else if (i % 3 == 0)
        {
        }
        else if (i % 5 == 0)
        {
        }
        else
        {
            fb += i;
        }
    }

    cout << fb << endl;
    return 0;
}


Measured memory_bytes: 3568
def main():
    N = int(input())
    A, B, C = [], [], []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        C.append(a+b)
    C.sort(reverse=True)
    ans = 0
    for i in range(N//2+N%2):
        ans += C[2*i]
    ans -= sum(B)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 21396