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

typedef pair<int,int> pii;
int N, K;
pii E[MAXN];
vector<int> G[MAXN];
map<pii,int> col;
bool visit[MAXN];

void dfs(int x, int p) {
  visit[x] = 1;
  int c = 0;
  for (auto y : G[x])
    if (!visit[y]) {
      c++;
      if (c == p) c++;
      col[pii(min(x,y),max(x,y))] = c;
      dfs(y, c);
    }
}

int main () {
  scanf("%d",&N);
  for (int i=1;i<N;++i) {
    int a, b;
    scanf("%d%d",&a, &b);
    E[i] = pii(min(a,b), max(a,b));
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int K = 1;
  for (int i=1;i<=N;++i) K = max(K, (int)G[i].size());
  dfs(1, 0);
  printf("%d\n",K);
  for (int i=1;i<N;++i) printf("%d\n", col[E[i]]);
}


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

int countTwo(int a){
    int m=0;
    while(a%2==0){
        a=a/2;
        m++; 
    }
    return m;    
}

int main(){
    int n;cin>>n;
    int a;cin>>a;
    int Min=countTwo(a);
    for(int i=1;i<n;i++){
        cin>>a;
        int m=countTwo(a);
        Min=min(Min,m);
    }
    cout<<Min<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll H,W;
    cin >> H >> W;
    if(H * W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = INF;
    rep(i,H){
        ll a = i * W,b = ((H - i) / 2) * W,c = (H-i-(H-i)/2) * W;
        ans = min(ans,max({a,b,c})-min({a,b,c}));
        b = (W / 2) * (H-i),c = (W-W/2)*(H-i);
        ans = min(ans,max({a,b,c})-min({a,b,c}));
    }
    swap(H,W);
    rep(i,H){
        ll a = i * W,b = ((H - i) / 2) * W,c = (H-i-(H-i)/2) * W;
        ans = min(ans,max({a,b,c})-min({a,b,c}));
        b = (W / 2) * (H-i),c = (W-W/2)*(H-i);
        ans = min(ans,max({a,b,c})-min({a,b,c}));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var sum = A.Sum();
            var limit = (double)sum / (double)(4 * M);

            var get = 0;
            foreach (int a in A)
            {
                if ((double)a >= limit) get++;
            }
            Console.WriteLine(get >= M ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		System.out.println(search(N));
	}

	public static int search(int N) {
		int ans = 0;

		for(int n = 1; n <= N; n++) {
			if (Integer.toString(n).length() % 2 == 0) continue;
			ans++;
		}
		return ans;
	}
}


Measured memory_bytes: 33420
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

constexpr long long mod = 1000000007;

std::vector<long long> a;
std::vector<long long> dp;

long long sol(int k) {
  if ( k < 0 ) return 0;
  if ( dp[k] != -1 ) return dp[k];

  int rtn = 0;
  if (!std::binary_search(a.begin(), a.end(), k-2)) rtn += (sol(k-2)%mod);
  if (!std::binary_search(a.begin(), a.end(), k-1)) rtn += (sol(k-1)%mod);
  return dp[k] = (rtn%mod);
}

int main (void) {

  int N, M;
  std::cin >> N >> M;

  a.resize(M);
  for(int i=0; i<M; i++) std::cin >> a[i];

  dp.assign(N+1, -1);
  dp[0] = 1;
  std::cout << sol(N) << std::endl;

  return 0;
}

Measured memory_bytes: 3968
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		
		while (line.equals("0") == false) {
			int num = Integer.parseInt(line);
			
			String[] nico = sc.nextLine().split(" ");
			
			int[] a = new int[num];
			for (int i = 0; i < num; i++) {
				a[i] = Integer.parseInt(nico[i]);
			}

			operation(a, 0);
			
			line = sc.nextLine();
		}
	}
	
	private void operation(int[] a, int n) {
		int[] b = new int[a.length];
		
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < a.length; i++) {
			if (map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
		}
		
		for (int i = 0; i < b.length; i++) {
			b[i] = map.get(a[i]);
		}
		
		boolean flag = true;
		for (int i = 0; i < b.length; i++) {
			if (a[i] != b[i]) {
				flag = false;
				break;
			}
		}
		
		if (flag == true) {
			System.out.println(n);
			
			for (int i = 0; i < b.length; i++) {
				System.out.print(b[i]);
				if (i < (b.length - 1)) System.out.print(" ");
			}
			System.out.println();
		} else {
			operation(b, (n + 1));
		}
	}
}

Measured memory_bytes: 28660
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int H, W;
bool M[20][20] = {false};

void update(int16_t distance[][20], int h, int w, int new_distance)
{
  if (!M[h][w]) {
    distance[h][w] = -2;
    return;
  }

  if (distance[h][w] == -1 || distance[h][w] > new_distance) {
    distance[h][w] = new_distance;

    if (h>0)
      update(distance, h-1, w, new_distance+1);
    if (h<H-1)
      update(distance, h+1, w, new_distance+1);
    if (w>0)
      update(distance, h, w-1, new_distance+1);
    if (w<W-1)
      update(distance, h, w+1, new_distance+1);
  }    
}

int main()
{
  cin >> H >> W;

  for (int h=0; h<H; ++h) {
    for (int w=0; w<W; ++w) {
      char c;
      cin >> c;
      M[h][w] = c=='.';
    }
  }

  int16_t max_distance = 0;
  
  for (int h=0; h<H; ++h) {
    for (int w=0; w<W; ++w) {
      if (!M[h][w])
	continue;

      int16_t distances[20][20];
      for (int hh=0; hh<H; ++hh)
	for (int ww=0; ww<W; ++ww)
	  distances[hh][ww] = -1;

      update(distances, h, w, 0);

      for (int hh=0; hh<H; ++hh) {
	for (int ww=0; ww<W; ++ww) {
	  max_distance = max(max_distance, distances[hh][ww]);
	}
      }
    }
  }

  cout << max_distance << endl;

  return 0;
}


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

#define ll long long int 

const ll N = 1e5+7 ;

ll dp[101][N] ;

ll max_cost ( ll w[] , ll v[] , ll n ,ll W ) {

	if(dp[n][W] != -1) return dp[n][W] ;
	if(n <= 0 ){
		dp[n][W] = 0 ;
		return 0 ;
	}
	if( (W - w[n]) < 0 ) {
		dp[n][W] = max_cost(w,v,n-1,W) ;
		return dp[n][W] ;
	}
	dp[n][W] = max(max_cost(w,v,n-1,W-w[n])+v[n] , max_cost(w,v,n-1,W) ) ;
	return dp[n][W] ;

}
void solve(ll n , ll W ) {
	ll w[n+3] , v[n+3] ;
	for(int i = 1; i <= n ; i++ ){
		cin >> w[i] ;
		cin >> v[i] ;
	} 
	memset( dp , -1 , sizeof(dp) ) ;
	cout <<  max_cost(w,v,n,W) ;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n ,w; cin >> n  >> w;
    solve(n , w) ;
    return 0;
}

Measured memory_bytes: 79232
package main
import "fmt"

func main() {
  var (
    a int
    b int
  )
  fmt.Scan(&a)
  fmt.Scan(&b)

  if a % 2 == 0 || b % 2 == 0 {
    fmt.Println("Even")
  } else {
    fmt.Println("Odd")
  }

}


Measured memory_bytes: 512
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  if( (s == "a") or (s == "i") or (s == "u") or (s == "e") or(s == "o") ) {
  cout << "vowel" << endl;
  } else{
  cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int tate,yoko,takasa;
	int irigutinum;
	int i;
	int hankei;
	int size;
	int minsize;
	while(1) {
		scanf("%d %d %d",&tate,&yoko,&takasa);
		if(tate==0 && yoko==0 && takasa==0)break;
		scanf("%d",&irigutinum);
		for(i=0;i<irigutinum;i++) {
			scanf("%d",&hankei);
			hankei*=2;
			hankei*=hankei;
			minsize=tate*tate+yoko*yoko;
			size=tate*tate+takasa*takasa;
			if(size<minsize)minsize=size;
			size=yoko*yoko+takasa*takasa;
			if(size<minsize)minsize=size;
			if(minsize<hankei)puts("OK");
			else puts("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n-1];
    int ans = 0;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    rep(i,n){
        ans += b[a[i]-1];
        if(i != 0){
            if(a[i] - a[i-1] == 1){
                ans += c[a[i]-2];
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Long K = sc.nextLong();
    char ans;
    if(K == 1){
      ans = S.charAt(0);
    }else{
      int count = 0;
      for(int i=0; i<S.length(); i++){
        if(S.charAt(i) != '1') break;
        count++;
      }
      if(K <= count) ans = '1';
      else ans = S.charAt(count);
    }
    System.out.println(ans);
  }

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

Measured memory_bytes: 22996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll x;
    cin >> x;
    cout << ((x < 1200) ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((abs(a-b)<abs(a-c)) ? "A" : "B") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
const int dy[] = { 1,  1,  1,  1,  1,  2,  2,  2,  3};
const int dx[] = {-2, -1,  0,  1,  2, -1,  0,  1,  0};
const int INF = 1001001001;
const int K = 3;
typedef pair<int, int> P;
struct STATE
{
	int x, y, a, d;
	bool operator <(const STATE &t) const{
		return d > t.d;
	}
};

char grid[256][256];
int d[256][256][2];
void init();

int main()
{
	int w, h;
	while (scanf("%d %d", &w, &h), w + h){
		init();
		w += K; h += K;
		
		vector<P> start;
		for (int i = K; i < h; i++){
			for (int j = K; j < w; j++){
				scanf(" %c", &grid[i][j]);
				if (grid[i][j] == 'S'){
					start.PB(P(i, j));
					grid[i][j] = 127;
				}
				else if (grid[i][j] == 'T'){
					grid[i][j] = 0;
				}
				else if (grid[i][j] >= '1' && grid[i][j] <= '9'){
					grid[i][j] -= '0';
				}
			}
		}
		
		int res = INF;
		for (int i = 0; i < start.size(); i++){
			priority_queue<STATE> que;
			que.push({start[i].first, start[i].second, 1, 0});
			que.push({start[i].first, start[i].second, -1, 0});
			for (; que.size(); que.pop()){
				STATE st = que.top();
				if (d[st.x][st.y][st.a == 1] <= st.d) continue;
				d[st.x][st.y][st.a == 1] = st.d;
				if (st.d >= res) continue;
				if (grid[st.x][st.y] == 0){
					res = st.d;
					break;
				}
				
				//cout << st.x << " " << st.y << endl;
				
				for (int dir = 0; dir < 9; dir++){
					int tx = st.x + dx[dir] * st.a;
					int ty = st.y + dy[dir] * st.a;
					int ta = -st.a;
					int td = st.d + grid[tx][ty];
					if (grid[tx][ty] == 'X') continue;
					que.push({tx, ty, -st.a, td});
				}
			}
		}
		
		if (res != INF) cout << res << endl;
		else cout << "-1" << endl;
	}
	
	return 0;
}

void init()
{
	memset(grid, 'X', sizeof(grid));
	for (int i = 0; i < 256; i++){
		for (int j = 0; j < 256; j++){
			for (int k = 0; k < 2; k++){
				d[i][j][k] = INF;
			}
		}
	}
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    a -= c;
    int ans = a / (b + c);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
long long N;
cin>>N;
long long a[N+10];
long long b[N+10];
long long counter=0;
for(long long j=0; j<N+1;j++){
cin>>a[j];}
for(long long j=0; j<N;j++){
cin>>b[j];}
for(long long j=0; j<N;j++){
if(a[j]>=b[j]){
counter+=b[j];
a[j]-=b[j];
continue;}
else if(a[j]<b[j]&&b[j]-a[j]<=a[j+1]){
counter+=b[j];
a[j+1]=a[j+1]-(b[j]-a[j]);
a[j]=0;
continue;}
else if(a[j]<b[j]&&b[j]-a[j]>a[j+1])
counter+=a[j]+a[j+1];
a[j+1]=0;
a[j]=0;}
cout<<counter<<endl;}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	cout << " ";
	cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
n = int(input())
l = list(map(int, input().split()))
tl = sum(l)
dp=[]
for _ in range(n):
    dp.append([0]*n)
for i in range(n):
    dp[i][i]=l[i]
for i in range(n-1):
    dp[i][i+1]=max(l[i],l[i+1])
for i in range(n-1,-1,-1):
    for j in range(i+2,n):
        ans1=l[i]+min(dp[i+2][j],dp[i+1][j-1])
        ans2=l[j]+min(dp[i+1][j-1],dp[i][j-2])
        dp[i][j]=max(ans1,ans2)
a = dp[0][n-1]
b = tl-a
print(a-b)

Measured memory_bytes: 115292
#include<bits/stdc++.h>
#define ll long long
#define inf 9999999999999999
#define F first
#define S second
#define eb emplace_back
#define mpp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 100009
#define mod 10000007
using namespace std;
ll dp[109][mx];

int main(){//read(x);
//fast;
ll r,g,h,i,j,t,e,a,b,c,d,n,l,k,z=0;
cin>>n>>k;
ll w[n],p[n];
for(i=0;i<n;i++)cin>>w[i]>>p[i];
dp[n][0]=0;
for(i=1;i<=k;i++)dp[n][i]=inf*-1;
for(i=n-1;i>=0;i--){
    for(j=0;j<=k;j++){
        dp[i][j]=max(dp[i+1][j],(j-w[i]>=0)?p[i]+dp[i+1][j-w[i]]:-inf);
    }
}
l=0;
    for(j=0;j<=k;j++)l=max(l,dp[0][j]);
    cout<<l<<endl;
}





















Measured memory_bytes: 82468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(void){
    int N,L;
    cin>>N>>L;
    int sum=0;
    int mi=INF;
    int j=0;
    for(int i=0;i<N;i++){
        sum+=L+i;
        if(mi>abs(L+i)){
            mi=abs(L+i);
            j=i;
        }
    }
    cout<<sum-(L+j)<<endl;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private Integer[][] graph;
	private boolean[][] g;
	private int[] d,f;
	private int time = 0;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		g = new boolean[totalVertex][totalVertex];
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
				g[idx1][idx2] = true;
			}	
			adjList.add(tmp);
		}
		in.close();
		
		d = new int[totalVertex];
		f = new int[totalVertex];
		
		graph = new Integer[totalVertex][totalVertex];
		for(int i = 0; i < totalVertex; i++) {
			for(int x = 0; x < totalVertex; x++) {
				graph[i][x] = 0;
			}
		}
		for(int i = 0; i < adjList.size(); i++) {
			LinkedList<Integer> curr = adjList.get(i);
			for(int x = 0; x < curr.size(); x++) {
				graph[i][curr.get(x)] = 1;
			}
		}
		
		dfs(0);
		for (int i = 0; i < totalVertex; i++)
			if (d[i] == 0)
				dfs(i);
		for(int i = 0;i < totalVertex;i++){
            System.out.println((i + 1) + " " + d[i] + " " + f[i]);
        }
	}
	public void printAdjMatrix() {
		for(int i = 0; i < totalVertex; i++) {
			for(int x = 0; x < totalVertex; x++) {
				if(x != totalVertex - 1) System.out.print(graph[i][x] + " ");
					else System.out.print(graph[i][x]);
			}
			System.out.println();
		}
	}
	public void dfs(int u) {
		if (d[u] > 0 || f[u] > 0)
			return;

		d[u] = ++time;
		for (int i = 0; i < totalVertex; i++)
			if (g[u][i])
				dfs(i);
		f[u] = ++time;
	}
}
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
//		g.printAdjMatrix();
	}
}


Measured memory_bytes: 28640
[n,m]=[int(i) for i in input().split()]
py=[]
for i in range(m):
    temp=[int(i) for i in input().split()]
    py.append([i+1, temp[0], temp[1]])

py.sort(key=lambda x:x[2])

count=[0 for i in range(n)]

ans=[]
#print(py)
#print(count)
for i in py:
    #print(i)
    count[i[1]-1]+=1
    ans.append([i[0], i[1], count[i[1]-1]])

ans.sort(key=lambda x:x[0])
for i in ans:
    a1=str(i[1])
    #print("a1!", i[1])
    c1=len(a1)
    while c1<6:
        print("0", end="")
        c1+=1
    print(a1, end="")

    a2=str(i[2])
    c2=len(a2)
    while c2<6:
        print("0", end="")
        c2+=1
    print(a2)

#print(ans[1], ans[2])


Measured memory_bytes: 39088
def main():
	h , w = map(int , input().split())
	ls =[]
	ans = []
	for i in range(0 ,h):
		ls.append(list(map(int , input().split())))
	for i in range(0 , h):
		for j in range(0 , w-1):
			if ls[i][j]%2==1:
				ls[i][j+1]+=1
				ans.append([i+1, j+1, i+1, j+2])
	for i in range(h-1):
		if ls[i][-1]%2==1:
			ls[i+1][-1]+=1
			ans.append([i+1,  w, i+2 , w])
	print(len(ans))
	for i in ans:
		print(*i)
if __name__=="__main__":
	main()

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

int main(){
 int K,A,B;
 cin>>K>>A>>B;
 int x=0;
 for (int i=A;i<=B;i++){
   if (i%K==0){
      x++;
   }
 }
  if (x==0){
   cout<<"NG"<<endl;
  }
  else{
   cout<<"OK"<<endl;
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

#define FOR(i,a,b) for(long long int i =(a); i <(b);i++)
#define REP(i,N)   FOR(i,0,N)
#define debug(x)   cout << #x << " = " << x << endl;

using namespace std;

int main(void){

    long long N;
    cin >> N;

    long long ans = 0;

    ans += 2*(N / 11);
    N = N % 11;
    int cnt = 1;
    while(N > 0){
        if(cnt % 2 != 0){
            N -= 6;
        }else{
            N -= 5;
        }
        ans++;
        cnt++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int dfs(vector<int>*gr,int *dp,int src)
{
	if(dp[src] != -1)
		return dp[src];
	int maxChild = 0;
	int leaf = 1;
	for(auto ele:gr[src])
	{
		leaf = 0;
		maxChild = max(maxChild,dfs(gr,dp,ele));
	}
	return dp[src]=(leaf?0:1+maxChild);
}
int main()
{
	ios_base::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	vector<int>gr[n];
	int dp[n];
	for(int i = 0;i < n;++i)
		dp[i] = -1;
	for(int i = 0;i < m;++i)
	{
		int x,y;
		cin >> x >> y;
		gr[x-1].push_back(y-1);
	}
	int answer = 0;
	for(int i = 0;i < n;++i)
		answer = max(answer,dfs(gr,dp,i));
	cout << answer << "\n";
	return 0;
}

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


class Program {

	static long mod = 998244353;
	static int[] ans;
	static void Main(string[] args) {

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

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		int res = 0;

		int n = int.Parse(Console.ReadLine());
		int[] x = new int[n];
		int[] y = new int[n];
		for ( int i = 0; i < n; i++ ) {
			int[] vals = parseAry(Console.ReadLine().Split(cs));
			x[i] = vals[0];
			y[i] = vals[1];
		
		}

		Dictionary<KeyValuePair<int, int>, int> dic = new Dictionary<KeyValuePair<int, int>, int>();

		for ( int i = 0; i < n; i++ ) {

			for ( int k = 0; k < n; k++ ) {
				if ( i == k ) { continue; }
				KeyValuePair<int, int> pa = new KeyValuePair<int, int> (x[i] - x[k],y[i] - y[k]);

				//long t = ((x[i] - x[k])<<32)+y[i]-x[k];
				if ( dic.ContainsKey(pa) ) { dic[pa]++; } else {
					dic.Add(pa, 1);
				}
			}
		}

		int xxx=0;
		int yyy = 0;
		int cnt=0;

		foreach ( KeyValuePair<KeyValuePair<int, int>, int> p in dic ) {
			KeyValuePair<int, int> kkk = new KeyValuePair<int, int>(p.Key.Key,p.Key.Value);
			if ( p.Value > cnt ) { cnt = p.Value; xxx = kkk.Key; yyy = kkk.Value; }
		}

		//int px = (int)vvv >> 32;
		//int py = (int)vvv & ( ( 1 << 32 ) - 1 );


		res = n - cnt;

			Console.WriteLine(res);

		return;

	}




	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}

}

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

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

    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;

    }

    int rem = (n-1)*(n-2)/2 - k;

    vector<pair<int, int>> ans;
    rep(i, n-1){
        ans.push_back(mp(i+1, n));
    }
    rep(i, n-1){
        if(rem == 0) break;
        REP(j, i+1, n-1){
            ans.push_back(mp(i+1, j+1));
            if(--rem == 0) break;
        }
    }
    cout << ans.size() << endl;
    repe(i, ans){
        cout << i.first << " " << i.second << endl;
    }



}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long;
#define dbg(x) cout<<#x<<"--------------"<<x<<endl;
#define dl cout<<"LINE"<<__LINE__<<endl;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string s;
	cin>>s;
	int t=s.size();
	for(int i=0;i<t;i++)cout<<'x';
	cout<<endl;
	
	
	
	
		
	return 0;
}

Measured memory_bytes: 256
// ?????¬???????????¬??????

#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
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 int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N; cin >> N;
    if(N == 0 || N == 2) cout << 1 << endl;
    else if(N == 1) cout << 2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)   int x; cin>>x; while(x--)
#define Aayush         main
const double pi=3.14159265359;
const int mod = 1e9 + 6;
//Actual Code Is At The Top
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int nodes,edges;
vector<int>adj[100001];
int vis[100001];
void dfs(int node)
{
    if(vis[node]) return;
    vis[node]=1;
    for(auto child:adj[node])
    {
        dfs(child);
    }
}
int32_t Aayush()
{   
	very_slow
//	no_of_test(x)
	{  
	   cin>>nodes>>edges;
       for(int i=1;i<=edges;i++)
       {    int x,y;
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
       }
       int cc=0;
       for(int i=1;i<=nodes;i++)
       {
           if(!vis[i])
           {
               dfs(i);cc++;
           }
       }
       cout<<cc-1<<'\n';
	}
	return 0;
}


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

int check_num(int i){
  int n;
  bool a,b,c;
  a = b= c=false;
  while(i>0){
    n = i%10;
    i /= 10;
    if(n == 3)
      a = true;
    else if(n==5)
      b = true;
    else if(n==7)
      c = true;
    else
      return 0;
  }
  return (a&b&c);
}


long n;
int dfs(long i,long depth, bool three, bool five, bool seven){
  if(n<i){
    return 0;
  }
  // if(three & five & seven){
  //   return 1;
  // }
  return (three & five & seven)
        +dfs(i+depth*3,depth*10,true,five,seven)
        +dfs(i+depth*5,depth*10,three,true,seven)
        +dfs(i+depth*7,depth*10,three,five,true);
}

int main(){
  // int n;
  cin >> n;
  cout << dfs(3,10,true,false,false)
          +dfs(5,10,false,true,false)
          +dfs(7,10,false,false,true) << endl;
  // int count = 0;
  // for(int i=357;i<=n;i+=2){
  //   count += check_num(i);
  // }
  // cout << count << endl;
}

// int check_num2(int i){
//
// }


// int main(){
//   int nums[] = {3,5,7};
//
// }


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif


class AGC001B
{
public:
	AGC001B()
	{
		cin >> n_;
		cin >> x_;
		ans_ = 0;
	}
	void Run(void)
	{
		ans_ += x_;
        if (Length1(x_, n_ - x_))
        {
    		cout << ans_;
            return;
        }
		Length2(n_ - x_, n_ % (n_- x_));
		cout << ans_;
	}
private:
	bool Length1(llong n, llong x)
	{        
        if (n % x == 0)
        {
            ans_ += (n / x * 2) * x;
            return true;
        }
        else
        {
            ans_ += (n / x * 2 + 1) * x;
        }
        return false;
	}
	void Length2(llong n, llong x)
	{
		llong next_n = x;
		llong next_x = n % x;
        
        if (next_x == 0)
        {
            ans_ += (n / x * 2 - 1) * x;
            return;
        }
        else
        {
            ans_ += (n / x * 2) * x;
        }

        Length2(next_n, next_x);
	}

	llong n_;
	llong x_;
	llong ans_;
};


int main()
{
	AGC001B agc001b;

	TimeStart();
	agc001b.Run();
	TimeEnd();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 2e5 + 5;

int n, q, ans, idx, cg, l;
int a[N], freq[N], cov[N];

void work() {
    cin >> idx >> cg;
    l = a[idx] - freq[a[idx]] + 1;
    if(l > 0) {
        cov[l]--;
        if(!cov[l]) ans++;
    }
    freq[a[idx]]--;
    l = cg - freq[cg];
    if(l > 0) {
        cov[l]++;
        if(cov[l] == 1) ans--;
    }
    a[idx] = cg;
    freq[cg]++;
    cout << ans << "\n";
}

void solve() {
    cin >> n >> q;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        freq[a[i]]++;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = max(0, i - freq[i] + 1); j <= i; j++) {
            cov[j]++;
        }
    }
    ans = 0;
    for(int i = 1; i <= n; i++) {
        if(!cov[i]) ans++;
    }
    while(q--) {
        work();
    }
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    solve();
    
}

Measured memory_bytes: 5992
package main

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

func Solve() {
  var N int
  NextInt(&N)
  var A []int
  NextIntSlice(&A)
  C := make([]int, MaxInt(A...) + 1)
  for _, a := range A {
    for d := 2; d * d <= a; d++ {
      if a % d > 0 { continue }
      C[d]++
      for a % d == 0 { a /= d }
    }
    if a > 1 { C[a]++ }
  }
  M := MaxInt(C...)
  if M <= 1 {
    Write("pairwise coprime")
  } else if M < N {
    Write("setwise coprime")
  } else {
    Write("not coprime")
  }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 50552
#include<iostream>
#include<string>
using namespace std;
int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  string ans;
  for (char& c : s) {
    ans += (s[k - 1] == c ? string(1, c) : "*");
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "yes"  # type: str
NO = "no"  # type: str

def solve(S: str):
    if len(set(S)) == len(S):
        print('yes')
    else:
        print('no')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
// atcoder/abc153/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "("; each (i, s) os << i << ","; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "("; each (i, m) os << i << ","; os << ")"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> swap(pair<P, Q> p) { return make_pair(p.second, p.first); }

constexpr lli mod = 1e9 + 7;

lli fn(lli h)
{
  if (h == 1) return 1;
  return fn(h / 2) * 2LL + 1LL;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n;
  while (cin >> n) {
    cout << fn(n) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string n; cin >> n;
  int length=n.size();
  int sum=0;
  
  if (n=="0" && n.size()==1){
    cout << "Yes" << endl;
    return 0;
  }
  
  for (int i=0; i<length; i++){
    sum = sum + ((n.at(i))-'0');
  }
  
  if (sum%9==0){ cout << "Yes" << endl;}
  else { cout << "No" << endl;}
}

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

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

	int ans = 0;
	rep(i,s.size()) {
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int N=S.size();
    int M=N;
    for(int i=1;i<N/2;i++){
        S.pop_back();S.pop_back();
        M-=2;
        if(S.substr(0,M/2)==S.substr(M/2,M/2))
        {cout<<M<<endl;exit(0);}
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>

using namespace std;

bool dfs(vector<vector<pair<int, int>>>&da, vector<bool> &ju, vector<int> &po, int x) {
	int n = da[x].size();
	for (int i = 0;i < n;i++) {
		if (ju[da[x][i].first]) {
			ju[da[x][i].first] = false;
			po[da[x][i].first] = po[x] + da[x][i].second;
			bool y=dfs(da, ju, po, da[x][i].first);
			if (!y) {
				return false;
			}
		}
		else {
			if (po[da[x][i].first] - po[x] != da[x][i].second && (x != 0)) {
				return false;

			}
		}
	}
	return true;
}

void deb(vector<int> &da) {
	int x = da.size();
	for (int i = 0;i < x;i++) {
		cout << da[i] << endl;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int, int>>> da(n + 1, vector<pair<int, int>>(0));
	for (int i = 0;i < m;i++) {
		int x, y, d;
		cin >> x >> y >> d;
		da[x].push_back(make_pair(y, d));
		da[y].push_back(make_pair(x, d*(-1)));
	}
	vector<bool> ju(n + 1, true);
	vector<int> po(n + 1, 0);
	for (int i = 0;i < n;i++) {
		da[0].push_back(make_pair(i + 1, 0));
	}
	if (dfs(da, ju, po, 0)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	//deb(po);
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll a, b, c, d, v1, v2, v3, v4 ;
    cin >> a >> b >> c >> d ;
    v1 = a * c, v2 = a * d, v3 = b * c, v4 = b * d ;
    cout << max(v1, max(v2, max(v3, v4))) ;

    return 0 ;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int N = s.size();
  vector<int> fs(128, -1);
  vector<int> ft(128, -1);
  for(int i = 0; i < N; i++) {
  	if (fs[s[i]] == -1 && ft[t[i]] == -1) {
      fs[s[i]] = t[i];
      ft[t[i]] = s[i];
    } else {
      if (fs[s[i]] != t[i] || ft[t[i]] != s[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int intLoop = scan.nextInt();
		String strTaro = "";
		String strHana = "";
		int intTaro = 0;
		int intHana = 0;

		for(int i = 0; i < intLoop; i++){
			strTaro = scan.next();
			strHana = scan.next();
			int intJudge = strTaro.compareTo(strHana);
			if(intJudge < 0){
				intHana += 3;
			}else if(intJudge == 0){
				intTaro++;
				intHana++;
			}else if(0 < intJudge){
				intTaro += 3;
			}
		}
		System.out.println(intTaro + " " + intHana);
		scan.close();
	}
}

Measured memory_bytes: 20976
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int w, n; cin >> w >> n;
  vector<pair<int, int>> vp(w);
  for (int i = 0; i < w; i++) {
      vp.at(i) = make_pair(i + 1, i + 1);
  }

  for (int i = 0; i < n; i++) {
    int a, b; char c; cin >> a >> c >> b;
    int tmp;
    for (int i = 0; i < w; i++) {
      if (vp.at(i).second == a) {
        vp.at(i).second = b;
        tmp = i;
      }
    }
    for (int i = 0; i < w; i++) {
      if (i == tmp) continue;
      if (vp.at(i).second == b) {
        vp.at(i).second = a;
      }
    }
  }

  for (int i = 0; i < w; i++) {
    swap(vp.at(i).first, vp.at(i).second);
  }

  sort(vp.begin(), vp.end());
  for (int i = 0; i < w; i++) {
    cout << vp.at(i).second << endl;;
  }
}



Measured memory_bytes: 3080
import java.util.*;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int i = 3;
		while(i <= n) {
			if(i % 3 == 0 || String.valueOf(i).contains("3")) {
				System.out.printf(" %d", i);
			}
			i++;
		}
		System.out.println();
	}
}

Measured memory_bytes: 39148
#include<stdio.h>

int main()
{
  int n,a[200000],mini,maxi=-1000000001,i;
  scanf("%d",&n);
  for(i = 0;i<n;i++)
    scanf("%d",&a[i]);
  mini = a[0];
  for (i =1;i<n;i++) {
    if(maxi<a[i]-mini)
      maxi = a[i]-mini; 
    if(mini>a[i])
       mini = a[i];
  }
  printf("%d\n",maxi);
  return 0;
}

Measured memory_bytes: 2552
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

vector<int> to[200000+5];
vector<int> ans;

void dfs(int v, int p=-1)
{
	for(int u : to[v])
	{
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	rep(i, n-1)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	rep(i, q)
	{
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n)
	{
		printf("%d ", ans[i]);
	}
	cout << endl;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int n, m, x;
		cin >> n >> m >> x;
		vector<int> c(n, 0);
		vector<vector<int>> a(n, vector<int>(m, 0));
		for (int i = 0; i < n; i++) {
			cin >> c[i];
			for (int j = 0; j < m; j++) cin >> a[i][j];
		}
		int ans = 0x7f7f7f7f;
		for (int i = 0; i < (1 << n); i++) {
			vector<int> y(m, 0);
			int cost = 0;
			for (int j = 0; j < n; j++) {
				if ((i >> j) & 1) continue;
				cost += c[j];
				for (int k = 0; k < m; k++) {
					y[k] += a[j][k];
				}
			}
			bool ok = true;
			for (int j = 0; j < m; j++) {
				if (y[j] < x) ok = false;
			}
			if (ok) ans = min(ans, cost);
		}
		if (ans == 0x7f7f7f7f) ans = -1;
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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


namespace Test1 {

    


    class ClassMain {


        



        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);

                int score = Math.Max(40, n);
                for (int i = 0; i < 4; i++) {
                    n = int.Parse(Console.ReadLine());
                    score += Math.Max(40, n);
                }
                Console.WriteLine(score / 5);
                break;
            }
            
        }

        
    }

    

    
}

Measured memory_bytes: 5600
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string a, b; cin >> a >> b;
	if (a.length() < b.length())a = string(b.length() - a.length(), '0') + a;
	else if (a.length() > b.length())b = string(a.length() - b.length(), '0') + b;
	cout << (
		a<b ? "LESS"
		: a>b ? "GREATER"
		: "EQUAL"
		) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> a(H,vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    
    bool flag1 = true;
    bool flag2 = true;
    
        for(int i = 0; i < H; i++){
            flag1 = true;
            for(int j = 0; j < W; j++){
               if(a[i][j] == '#') flag1 = false;
            }
            if(flag1 == true){
                for(int j = 0; j < W; j++){
                    a[i][j] = 'a';
                }
            }
        }
        
        for(int j = 0; j < W; j++){
               flag2 = true;
            for(int i = 0; i < H; i++){
               if(a[i][j] == '#') flag2 = false;
            }
            if(flag2 == true){
                for(int i = 0; i < H; i++){
                    a[i][j] = 'a';
                }
            }
        }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            flag1 = true;
            
            for(int j = 0; j < W; j++){
               if(a[i][j] == '#' || a[i][j] == '.') flag1 = false;
            }
            
            if(a[i][j] != 'a') cout << a[i][j];
            if(j == W-1 && flag1 == false) cout << endl;
        }
    }
}


Measured memory_bytes: 256
N, A, B, C, D = map(int,input().split())
S = input()

for i in range(A,D-1):
    if S[i] == '#':
        if S[i - 1] == '#':
            print('No')
            exit(0)
if C < D:
    print('Yes')
    exit(0)

for i in range(B, D + 1):
    if S[i] == '.':
        if S[i - 1] == '.' and S[i - 2] == '.':
            print('Yes')
            exit(0)
print('No')

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

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

    int a, b, result;
    string op;

    while(1){
        cin >> a >> op >> b;
        if(op == "?"){
            break;
        }else{
            if(op == "+"){
                result = a + b;
            }else if(op == "-"){
                result = a - b;
            }else if(op == "*"){
                result = a * b;
            }else if(op == "/"){
                result = a / b;
            }
            printf("%d\n", result);
        }
    }

    return 0;
}

Measured memory_bytes: 3228