akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;

class Main {

  public static void main(String[] args) {
    final FastScanner sc = new FastScanner();
    final PrintWriter writer = new PrintWriter(System.out);
    List<Integer> l = new ArrayList<>(Arrays.asList(1, 2, 3));
    l.remove(Integer.valueOf(sc.nextInt()));
    l.remove(Integer.valueOf(sc.nextInt()));
    writer.println(l.get(0));
    writer.flush();
    writer.close();
  }

  // FastScanner --
  static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    public FastScanner() {
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte())
        return buffer[ptr++];
      else
        return -1;
    }

    private boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr]))
        ptr++;
      return hasNextByte();
    }

    public String next() {
      if (!hasNext())
        throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext())
        throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
        throw new NumberFormatException();
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}

Measured memory_bytes: 19668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            final int n = Integer.parseInt(in.readLine());
            long[] A = new long[n + 1];

            String[] line = in.readLine().split(" ");
            for (int i = 0; i < n; i++) {
                A[i + 1] = Long.parseLong(line[i]);
            }

            StringBuilder out = new StringBuilder();
            for (int i = 0; i < n; i++) {
                int node = i + 1;
                int pkey = node / 2;
                int left = 2 * node;
                int right = 2 * node + 1;

                long key = A[node];
                out.append("node ").append(node).append(": key = ").append(key).append(", ");
                if (0 < pkey && pkey < n + 1) {
                    out.append("parent key = ").append(A[pkey]).append(", ");
                }
                if (0 < left && left < n + 1) {
                    out.append("left key = ").append(A[left]).append(", ");
                }
                if (0 < right && right < n + 1) {
                    out.append("right key = ").append(A[right]).append(", ");
                }
                out.append("\n");
            }
            System.out.print(out.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24608
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    if(a+b < 2 * c){
        ans = a * x + b * y;
    }else{
        int pa = min(x,y);
        ans += pa * c * 2;
        x -= pa; y -= pa;
        if(x*a + y*b < c*max(x,y)*2){
            ans += x*a+y*b;
        }else{
            ans += c * max(x,y) * 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

public class Solve
{
    static void Main(string[] args)
    {
        new ABC_C();
    }
}

public class ABC_C
{
    int n;
    int[] arr;
    int[] p;
    int[] q;

    public ABC_C()
    {
        In();
        int a = 0;
        int b = 0;
        int i = 0;
        arr = Enumerable.Range(1, n).ToArray();
        do
        {
            i++;
            if (isSame(p)) a = i;
            if (isSame(q)) b = i;
        } while (NextPermutation(arr));

        Console.WriteLine(Math.Abs(a-b));
    }

    bool isSame(int[] p)
    {
        for (int i = 1; i < arr.Length; i++)
        {
            if (arr[i] != p[i]) return false;
        }
        return true;
    }

    void In()
    {
        n = int.Parse(Console.ReadLine().Trim());
        p = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        q = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
    }

    void swap(int[] nums, int i, int j)
    {
        var tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }

    void reverse(int[] nums, int start)
    {
        int i = start;
        int j = nums.Length - 1;
        while (i < j)
        {
            swap(nums, i, j);
            i++;
            j--;
        }
    }

    bool NextPermutation(int[] nums)
    {
        int i = nums.Length - 2;
        while (i >= 0 && nums[i + 1] < nums[i])
        {
            i--;
        }
        if (i >= 0)
        {
            int j = nums.Length - 1;
            while (j >= 0 && nums[j] <= nums[i])
            {
                j--;
            }
            swap(nums, i, j);
        }
        reverse(nums, i + 1);
        return (i >= 0);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N, K;
string S;
int a[100010];


signed main(){
    cin >> N >> K;
    cin >> S;

    int n = 0;
    if(S[0] == '0') S = '1'+S, a[0]--;
    for(int i = 0;i < SZ(S);n++){
        char c = S[i];
        a[n]++;
        i++;
        while(i != SZ(S) && c == S[i]) a[n]++, i++;
    }
    if(S.back() == '0') n++;

    int ans = 0;
    if(n < 2*K+1) 
        rep(i, 0, n) ans += a[i];
    else {
        int prev = 0;
        repe(i, 0, 2*K) prev += a[i];
        ans = prev;
        for(int i = 2;i+2*K < n;i+=2) prev = prev-a[i-2]-a[i-1]+a[i+2*K]+a[i+2*K-1], chmax(ans, prev);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  int T;
  cin >> T;
  T = T + 0.5;
  int C;
  C = T / A;
  C = C % 1;
  T = T - C;
  T = T / A;
  cout << T * B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<ll> x(m);
    rep(i, m)cin >> x[i];
    sort(ALL(x));

    if(n >= m){
        cout << 0;
        return 0;
    }

    vector<ll> dif(m-1);
    ll sum = 0;
    rep(i, m-1){
        dif[i] = abs(x[i+1] - x[i]);
        sum += dif[i];
    }
    sort(ALL(dif), greater<ll>());

    rep(i, n-1)sum -= dif[i];
    
    cout << sum << endl;
}

Measured memory_bytes: 4728
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int a, b, c;
  cin >> a >> b >> c;

  int ans;
  if((c - 1) <= (a + b)){
    ans = c + b;
  }
  else{
    ans = (a + b + 1) + b;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = []
P = []

# 点数hash
th = {}

# city hash
ch = {}

for i in range(N):
    s, p = input().split()
    p = int(p)
    S += [s]
    P += [p]

    # 点数hash
    th[p] = [s, i+1]

    # city hash
    if s in ch:
        tmp = ch[s]
        tmp += [p]
        ch[s] = tmp
    else:
        ch[s] = [p]

#print(th)
#print(ch)

x = list(set(S))
x.sort()
for city in x:
    tmp = ch[city]
    tmp.sort(reverse=True)
    for i in tmp:
        print(th[i][1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
string s,t;
int a,b;
cin>>s;
cin>>t;
a=0;
if(s[0]==t[0]){a++;}
if(s[1]==t[1]){a++;}
if(s[2]==t[2]){a++;}
cout<<a<<endl;
}

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

struct suffix_array{

    int n,logn;
    string s;
    vector<int> rank,sa,lcp;

    suffix_array(string &str):s(str){
        build_suffix_array();
        build_lcp();
    }

    void build_suffix_array(){
        n=s.size();
        logn=floor(log2(n));
        rank.resize(n);
        sa.resize(n);
        for(int i=0;i<n;++i){
            rank[i]=s[i];
            sa[i]=i;
        }
        for(int k=0;k<=logn;++k){
            auto comp=[&](int a,int b){
                if(rank[a]!=rank[b])return rank[a]<rank[b];
                a=(a+(1<<k)<n)?rank[a+(1<<k)]:-1;
                b=(b+(1<<k)<n)?rank[b+(1<<k)]:-1;
                return a<b;
            };
            sort(sa.begin(),sa.end(),comp);
            vector<int> tmp=rank;
            tmp[sa[0]]=0;
            for(int i=1;i<n;++i)tmp[sa[i]]=tmp[sa[i-1]]+comp(sa[i-1],sa[i]);
            rank=tmp;
        }
    }

    void build_lcp(){
        vector<int> tmp(n);
        for(int i=0;i<n;++i){
            tmp[sa[i]]=i;
        }
        int h=0;
        lcp.resize(n);
        for(int i=0;i<n;++i){
            if(tmp[i]==0){
                lcp[0]=0;
                if(h>0)h--;
                continue;
            }
            int j=sa[tmp[i]-1];
            if(h>0)h--;
            for(;i+h<n&&j+h<n;++h){
                if(s[i+h]!=s[j+h])break;
            }
            lcp[tmp[i]]=h;
        }
    }

    int compare(string t,int s_idx=0,int t_idx=0){
        while(s_idx<s.size()&&t_idx<t.size()){
            if(s[s_idx]<t[t_idx]){
                return 1;
            }else if(s[s_idx]>t[t_idx]){
                return -1;
            }
            s_idx++;
            t_idx++;
        }
        if(t_idx>=t.size()){
            return 0;
        }else{
            if(s_idx>=s.size()){
                return 1;
            }else{
                return -1;
            }
        }
    }

    int lower_bound(string t){
        int l=0;
        int r=n-1;
        while(l<=r){
            int mid=l+(r-l)/2;
            if(compare(t,sa[mid])>0){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        return l;
    }

    int upper_bound(string t){
        int l=0;
        int r=n-1;
        while(l<=r){
            int mid=l+(r-l)/2;
            if(compare(t,sa[mid])>=0){
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        return l;
    }

    int operator[](int k)const{
        return sa[k];
    }

    int size()const{
        return n;
    }

};

ll num(ll a){
    return a*(a+1)/2;
}

int main(){
    string s;
    cin>>s;
    suffix_array sa(s);
    ll n;
    cin>>n;
    rep(i,n){
        string t;
        cin>>t;
        cout<<(sa.upper_bound(t)!=sa.lower_bound(t))<<endl;
    }
}



Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
# Binary Indexed Tree
# https://www.topcoder.com/community/competitive-programming/tutorials/binary-indexed-trees
# http://hos.ac/slides/20140319_bit.pdf
class BIT
  def initialize(n)
    @tree = Array.new(n + 1, 0)
  end

  def add(i, diff)
    while i < @tree.size
      @tree[i] += diff
      i += (i & -i)
    end
  end

  def sum(i)
    t = 0
    while i > 0 do
      t += @tree[i]
      i -= (i & -i)
    end
    return t
  end
end

n, k = gets.chomp.split.map(&:to_i)

bit = BIT.new(n)
bit.add(1, 1)

rng = []
k.times do
  l, r = gets.chomp.split.map(&:to_i)
  rng.push([l, r])
end

2.upto(n) do |i|
  t = 0

  rng.each do |a, b|
    aa = i - a
    bb = i - b - 1

    aa = 0 if aa < 0
    bb = 0 if bb < 0

    t += bit.sum(aa) - bit.sum(bb)
  end

  bit.add(i, t % 998244353)
end

puts bit.sum(n) - bit.sum(n-1)


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

int main() {
	int N,K;
	cin >> N >> K;
	
	int x[N], y[N];
	char c[N];
	for(int i=0; i<N; i++){
		cin >> x[i] >> y[i] >> c[i];
	}
	
	int num_B[2*K][2*K]={};
	int num_W[2*K][2*K]={};
	for(int i=0; i<N; i++){
		if(c[i]=='B'){
			num_B[x[i]%(2*K)][y[i]%(2*K)]++;
		}
		if(c[i]=='W'){
			num_W[x[i]%(2*K)][y[i]%(2*K)]++;
		}
	}
	

	
	int B[2*K][2*K]={};	//horizonal range K
	int W[2*K][2*K]={};
	for(int j=0; j<2*K; j++){
		for(int i=0; i<K; i++){
			B[0][j]+=num_B[i][j];
			W[0][j]+=num_W[i][j];
		}
		for(int i=1; i<2*K; i++){
			B[i][j]=B[i-1][j];
			W[i][j]=W[i-1][j];
			B[i][j]-=num_B[i-1][j];
			W[i][j]-=num_W[i-1][j];
			B[i][j]+=num_B[(i+K-1)%(2*K)][j];
			W[i][j]+=num_W[(i+K-1)%(2*K)][j];
		}
	}
	
	
		
	int answer[2*K][2*K]={};	//[i][j] means (i,j) is left-down corner
	for(int i=0; i<2*K; i++){
		for(int j=0; j<K; j++){
			answer[i][0]+=B[i][j];
			answer[i][0]+=W[(i+K)%(2*K)][j];
		}
		for(int j=K; j<2*K; j++){
			answer[i][0]+=W[i][j];
			answer[i][0]+=B[(i+K)%(2*K)][j];
		}
	}
	
	

	
	
	for(int j=1; j<2*K; j++){
	for(int i=0; i<2*K; i++){
		answer[i][j]=answer[i][j-1];
		
		answer[i][j]-=B[i][j-1];
		answer[i][j]+=W[i][j-1];
		answer[i][j]+=B[i][(j+K-1)%(2*K)];
		answer[i][j]-=W[i][(j+K-1)%(2*K)];
		
		answer[i][j]+=B[(i+K)%(2*K)][j-1];
		answer[i][j]-=W[(i+K)%(2*K)][j-1];
		answer[i][j]-=B[(i+K)%(2*K)][(j+K-1)%(2*K)];
		answer[i][j]+=W[(i+K)%(2*K)][(j+K-1)%(2*K)];	
	}
	}
	
	
	
	
	int ans=0;
	for(int i=0; i<2*K; i++){
	for(int j=0; j<2*K; j++){
		if(ans<answer[i][j]){
			ans=answer[i][j];
		}
	}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 79232
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[][] k=new int[n][10];
for(int i=0;i<n;i++){
for(int j=0;j<10;j++){
k[i][j]=sc.nextInt();
}
}
for(int g=0;g<n;g++){
if(dfs(g,0,0,0,k)==true){System.out.println("YES");}
else{System.out.println("NO");}
}
}
public static boolean dfs(int i,int j,int r,int l,final int[][] k){
if(j==10){return true;}
else if(k[i][j]>r&&k[i][j]>l){
if(r>l){r=k[i][j];}
else{l=k[i][j];}
}
else if(k[i][j]>r){r=k[i][j];}
else if(k[i][j]>l){l=k[i][j];}
else{return false;}
return dfs(i,j+1,r,l,k);
}
}

Measured memory_bytes: 18396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const int N=2e6+20;
ll n,x,a[N];
int main()
{	
	while(cin>>n>>x)
	{
		for(int i=1;i<=n;i++)
			scanf("%lld",&a[i]);	
		ll ans=0;
		a[n+1]=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]>x)
				ans+=a[i]-x,a[i]=x;
			if(a[i]+a[i+1]>x)
				ans+=(a[i]+a[i+1]-x),a[i+1]-=(a[i]+a[i+1]-x);
		}
		cout<<ans<<endl;
	}
		
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<algorithm>
#include<list>
using namespace std;

class dice{
public:
	int d[6], tmp[6];
	dice(int n[6]){
		for (int i = 0; i < 6; i++){
			d[i] = n[i];
		}
	}
	void throwdice(char c){
		for (int i = 0; i < 6; i++){
			tmp[i] = d[i];
		}
		if (c == 'N'){
			d[0] = tmp[1];
			d[1] = tmp[5];
			d[2] = tmp[2];
			d[3] = tmp[3];
			d[4] = tmp[0];
			d[5] = tmp[4];
		}
		else if (c == 'E'){
			d[0] = tmp[3];
			d[1] = tmp[1];
			d[2] = tmp[0];
			d[3] = tmp[5];
			d[4] = tmp[4];
			d[5] = tmp[2];
		}
		else if (c == 'W'){
			d[0] = tmp[2];
			d[1] = tmp[1];
			d[2] = tmp[5];
			d[3] = tmp[0];
			d[4] = tmp[4];
			d[5] = tmp[3];
		}
		else if (c == 'S'){
			d[0] = tmp[4];
			d[1] = tmp[0];
			d[2] = tmp[2];
			d[3] = tmp[3];
			d[4] = tmp[5];
			d[5] = tmp[1];
		}
		else if (c == 'R'){
			d[0] = tmp[0];
			d[1] = tmp[3];
			d[2] = tmp[1];
			d[3] = tmp[4];
			d[4] = tmp[2];
			d[5] = tmp[5];
		}
	}
};
int main()
{
	int n, m[6];
	cin >> n;
	bool allsame = false;
	list<dice> dicelist;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 6; j++){
			cin >> m[j];
		}
		dice dice1(m);
		for (dice dice2 : dicelist){
			bool upsame = false;
			for (int j = 0; j < 4; j++){
				dice1.throwdice('S');
				if (dice1.d[0] == dice2.d[0]){
					upsame = true;
					break;
				}
			}
			if (!upsame){
				for (int j = 0; j < 4; j++){
					dice1.throwdice('W');
					if (dice1.d[0] == dice2.d[0]){
						break;
					}
				}
			}

			for (int j = 0; j < 4; j++){
				dice1.throwdice('R');
				if (dice1.d[1] == dice2.d[1]){
					break;
				}
			}
			bool same = true;
			for (int j = 0; j < 6; j++){
				if (dice1.d[j] != dice2.d[j]){
					same = false;
				}
			}
			if (same){
				allsame = true;
			}
		}
		dicelist.push_back(dice1);
	}
	if (allsame){
		cout << "No"<<endl;
	}
	else{
		cout << "Yes"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll H,W,N;
	cin >> H >> W >> N;
	ll ans[H][W];
	ll hi=0,wi=0;
	FOR(t,0,N){
		ll a;
		cin >> a;
		FOR(i,0,a){
			ans[hi][wi]=t+1;
			wi++;
			if(wi==W){
				wi=0;
				hi++;
			}
		}
	}
	FOR(i,0,H){
		if(i&1){cout<<ans[i][W-1];FORR(j,0,W-1)cout<<" "<<ans[i][j];}
		else {cout<<ans[i][0];FOR(j,1,W)cout<<" "<<ans[i][j];}
		cout<<endl;
	}
}

Measured memory_bytes: 384
S = gets.chomp
n = S.size - 1

ans = 0
(1 << n).times do |i|
  w = S[0]
  n.times do |j|
    if (i >> j & 1) > 0
      ans += w.to_i
      w = S[j + 1]
    else
      w += S[j + 1]
    end
  end
  ans += w.to_i
end

puts ans


Measured memory_bytes: 1788
#include<iostream>
  using namespace std;
  int main()
  {
    int a,b;
    cin>>a>>b;
    string ans;
    if(a * b % 2 == 0) {
      ans = "Even";
    } else {
      ans = "Odd";
    }
    cout << ans << endl;
    return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n, a;
  cin >> n;
  long long sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a;
    sum += a - 1;
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    /* Input */
    int A, B, H, M;
    cin >> A >> B >> H >> M;
   
    /* Main Logic */
    long double ans;
    double m_theta = (M * 2.0 * PI) / 60.0;
    double h_theta = ((60.0 * H + M) * 2.0 * PI) / 720.0;

    double theta = min(abs(m_theta - h_theta), 2 * PI - abs(m_theta - h_theta));

    /* cosine formula */
    ans = A * A + B * B - 2.0 * A * B * cos(theta);

    /* Output */    
    cout << fixed << setprecision(18) << sqrt(ans) << endl;
}

Measured memory_bytes: 4148
a, b, c, d, e, f = gets.split.map(&:to_i)
x = []
y = []

0.upto(3000 / (100 * a)) do |i|
  0.upto(3000 / (100 * b)) do |j|
    x << 100 * a * i + 100 * b * j
  end
end

0.upto(3000 / c) do |i|
  0.upto(3000 / d) do |j|
    y << c * i + d * j
  end
end

x = x.reject { |e| e > f }.uniq.sort
y = y.reject { |e| e > f }.uniq.sort
h = {}

x.each do |i|
  y.each do |j|
    next if i / 100.0 * e < j || i + j > f

    h[[i, j]] = 100.0 * j / (i + j) unless i == 0 && j == 0
  end
end

u, v = h.sort_by { |k, v| -v }[0][0]

puts "#{u + v} #{v}"

Measured memory_bytes: 53628
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 1000000007

#define MAXR 100000
#define PI 3.14159265358979323846
using namespace std;

signed main() {
    string A;
    cin >> A;

    //  cout <<A[A.size()-1]  <<endl ;

    if (A[A.size() - 1] == 's') {
        A += "es";
    } else {
        A += "s";
    }

    cout << A << endl;

    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	LL n; cin >> n;
	LL ans = n + 1;
	for (LL a = 1; a * a <= n; a++) {
		if (n % a == 0) {
			ans = min(ans, a + n / a);
		}
	}
	cout << (ans - 2) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int W, H, N;
vector<string> board;
vector<vector<bool>> visit;

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

bool Search(int x, int y)
{
    if (board[y][x] == '#')
        board[y][x] = '.';

    if (!visit[y][x])
        return false;

    queue<pair<int, int>> que;
    que.push(make_pair(x, y));

    while (!que.empty()) {
        pair<int, int> now = que.front();
        que.pop();

        if (board[now.second][now.first] == 't')
            return true;

        for (int d = 0; d < 4; ++d) {
            int nx = now.first + dx[d];
            int ny = now.second + dy[d];

            if (nx < 0 || nx >= W || ny < 0 || ny >= H)
                continue;
            if (visit[ny][nx])
                continue;

            visit[ny][nx] = true;

            if (board[ny][nx] != '#')
                que.push(make_pair(nx, ny));
        }
    }

    return false;
}

int main()
{
    cin >> W >> H;
    board.resize(H);
    visit.resize(H, vector<bool>(W, false));

    for (int i = 0; i < H; ++i)
        cin >> board[i];

    cin >> N;
    int x[N + 1], y[N + 1];
    x[0] = y[0] = 0;
    for (int i = 1; i <= N; ++i)
        cin >> x[i] >> y[i];

    bool not_found = true;
    visit[0][0] = true;

    for (int t = 0; t <= N; ++t) {
        if (Search(x[t], y[t])) {
            cout << t << endl;
            not_found = false;
            break;
        }
    }

    if (not_found)
        cout << "-1\n";

    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int IINF = INT_MAX;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    V<ll> a(n);
    for(int i = 0; i < n; i++){
        ll x; cin >> x;
        x = x - (i + 1);
        a[i] = x;
    }

    sort(ALL(a));
    ll m = a[n / 2];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(a[i] - m);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

#define MAX_N 200000
struct UF{
    int par[MAX_N];
    int rank[MAX_N];
    int si[MAX_N];
    int dead[MAX_N];

    void init(int n){
        rep(i,n){
            par[i] = i;
            rank[i] = 0;
            si[i] = 1;
            dead[i] = 0;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) {
            if (dead[x]) return false;
            dead[x] = true;
            return true;
        }
        if (dead[x] && dead[y]) return false;
        
        if(rank[x] < rank[y]){
            par[x] = y;
            if (dead[x]) dead[y] = true;
            si[y] += si[x];
        } else{
            par[y] = x;
            if (dead[y]) dead[x] = true;
            if(rank[x] == rank[y]) rank[x]++;
            si[x] += si[y];
        }
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
} uf;

struct X {
    int r, c, a;
};

bool cmp (const X &l, const X &r) {
    return l.a > r.a;
}

int n, h, w;
X x[100000];

int main() {
    cin >> n >> h >> w;
    rep(i,n) {
        cin >> x[i].r >> x[i].c >> x[i].a;
        x[i].r--; x[i].c--;
    }
    sort(x, x+n, cmp);
    uf.init(h+w);
    ll ans = 0;
    rep(i,n) {
        if (uf.unite(x[i].r, h+x[i].c)) {
            ans += x[i].a;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int N, M;
	cin >> N >> M;
	cout << (N == M? "Yes": "No") << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
	long long n, m;
	while(cin >> n >> m){
		vector<long long> x(n), y(m);
		for(long long& t : x) cin >> t;
		for(long long& t : y) cin >> t;
		long long resX = 0, resY = 0;
		for(int i=0;i+1<n;i++){
			long long add = (x[i+1] - x[i]) % MOD;
			add = (add * (n - i - 1)) % MOD;
			add = (add * (i + 1)) % MOD;
			resX = (resX + add) % MOD;
		}
		for(int i=0;i+1<m;i++){
			long long add = (y[i+1] - y[i]) % MOD;
			add = (add * (m - i - 1)) % MOD;
			add = (add * (i + 1)) % MOD;
			resY = (resY + add) % MOD;
		}
		cout << (resX * resY) % MOD << endl;
	}
}



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

int main() {
    long long k;
    cin >> k;
    int ans = 1;
    long long n = 7;
    if(k % 2 == 0){
        cout << -1 << endl;
    }
    else{
        rep(i,1000000){
            if(n % k == 0){
                cout << ans << endl;
                break;
            }
            else{
                n = n*10 + 7;
                n %= k;
                ans++;
            }
        }
        if( n % k != 0 ) cout << -1 << endl;
    }
}

Measured memory_bytes: 3612
n = int(input())
ab =[tuple(map(int, input().split( ))) for i in range(n)]
ab.sort(key = lambda x:x[0]+x[1],reverse = True)
ans = 0
for i in range(n):
    if i%2==0:
        ans += ab[i][0]
    else:
        ans -= ab[i][1]
print(ans)


Measured memory_bytes: 63064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define MAX_N (1<<18)

struct SegTree {
  int seg[MAX_N*2-1];
  SegTree() {
    for (int i=0; i<MAX_N*2-1; i++) seg[i] = INF;
  }

  void update(int i, int x) {
    i += MAX_N-1;
    if (seg[i] <= x) return;
    seg[i] = x;
    while (i > 0) {
      i = (i-1) / 2;
      seg[i] = min(seg[i*2+1], seg[i*2+2]);
    }
  }
  int query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return seg[k];
    return min(
      query(a, b, k*2+1, l, (l+r)/2),
      query(a, b, k*2+2, (l+r)/2, r)
    );
  }
};


int N;
int A[200000];
int pos[200000];
SegTree seg[2];
priority_queue<P2, vector<P2>, greater<P2> > q;
void add(int l, int r) {
  if (l >= r) return;
  int e = l%2;
  q.push(P2(seg[e].query(l, r+1), P(l, r)));
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    cin >> A[i], A[i]--;
    pos[A[i]] = i;
  }
  rep(i, N) {
    seg[i%2].update(i, A[i]);
  }
  add(0, N-1);

  vector<int> ans;
  while (!q.empty()) {
    int val = q.top()._1,
        l = q.top()._2._1,
        r = q.top()._2._2;
    q.pop();
    int e = l%2;
    int a = pos[val];
    int b = pos[seg[e^1].query(a, r+1)];
    ans.pb(A[a]);
    ans.pb(A[b]);
    assert(a%2 == e);
    // [l a-1] | [a+1 b-1] | [b+1 r]
    add(l, a-1);
    add(a+1, b-1);
    add(b+1, r);
  }
  assert(ans.size() == N);
  rep(i, N) {
    cout << ans[i]+1;
    if (i == N-1) cout << "\n";
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 8616
l = int(input())
le = l.bit_length()
li = []
for i in range(1, le):
    li.append([i, i + 1, 0])
    li.append([i, i + 1, 1 << (i - 1)])
for i in range(1, le):
    if (1 << (i - 1)) & l:
        l -= 1 << (i - 1)
        li.append([i, le, l])
print(le, len(li))
for i in range(len(li)):
    print(*li[i])

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

using namespace std;

#define fo(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define lli long long int
#define all(c) c.begin(),c.end()
#define lower(c) tolower(c)
#define upper(c) toupper(c)
#define MAX(c) *max_element(c.begin(),c.end())
#define MIN(c) *min_element(c.begin(),c.end())
#define len(c) c.size()
const int MOD = 1000000007;
const int MX = 2e5 + 5;
const int INF = 1e9 + 10;
const lli LINF = 1e18;

void solve() {
	string S;
    cin >> S;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if (p and q and r) {
        cout << 3 << endl;
    } else if ((p and q) or (q and r)) {
        cout << 2 << endl;
    } else if (p or q or r) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

}


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



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

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

	int n;
	cin >> n;
	vector<int>	V(n);
	rep(i, n)
		cin >> V.at(i);
	rep(i, n - 1)
	{
		if (V.at(i) < V.at(i + 1))
			V.at(i + 1)--;
		if (V.at(i + 1) < V.at(i))
		{
			cout << "No" << endl;
			return (0);
		}
	}
	cout << "Yes" << endl;
}


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

int ans[2001];

int main(){
    int n,x,y; cin >> n >> x >> y;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            ans[min({abs(i-j),abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y)})]++;
        }
    }
    for(int k=1;k<=n-1;k++) cout << ans[k]/2 << endl;
}

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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int A, B;
  cin >> A >> B;
  cout << ((A == 2 || B == 2) ? "No" : "Yes");
}


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

int main(){
  int64_t N;
  cin >> N;
  map<string, int64_t> tisa;

  //alphabet順に各stringを並べ替え
  for(int i=0; i<N; i++){
    string A;
    cin >> A;
    sort(A.begin(),A.end());
    if(tisa.count(A)){
      tisa.at(A)++;
    }else{
      tisa[A]=1;
    }
  }
  
  int64_t ans = 0;
  for(auto p : tisa){
    auto k = p.second;
    ans += k*(k-1)/2;
  }
  
  cout << ans << endl;

} 


Measured memory_bytes: 11136
h,w = gets.split.map(&:to_i)
sum = 0
if w.even?
  sum += w/2 * h
else
  if h.even?
    sum += w * h/2
  else
    sum += w * (h / 2 + 1)
    sum -= (w / 2)
  end
end
if w == 1 || h == 1
  sum = 1
end

puts sum

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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int D;
    cin >> D;
    string s = "Christmas";
    rep(i,25-D){
        s += " Eve";
    }

    cout <<s << endl;
    return 0;
}

Measured memory_bytes: 3636
import math

def main():
  a, b, h, m = map(int, input().split())
  m_rad = m / 60 * 360
  h_rad = h / 12 * 360 + (m / 60) * (360 // 12)
  s = 0
  if h_rad > m_rad:
    s = min(h_rad - m_rad, 360 - h_rad + m_rad)
  else:
    s = min(m_rad - h_rad, 360 - m_rad + h_rad)

  s = math.radians(s)

  print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(s)))


main()


Measured memory_bytes: 9476
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,k;
    cin>>n>>k;
    vi d(k);
    vii a(k,vi());
    vi c(n,0);
    FOR(i,0,k){
        cin>>d[i];
        FOR(j,0,d[i]){
            int aa;
            cin>>aa;
            a[i].PB(aa);
            c[aa-1]=1;
        }
    }
    int sm=0;
    FOR(i,0,n){
        sm+=1-c[i];
    }
    cout<<sm;

}


Measured memory_bytes: 3632
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

# 大きい数用


import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

# 大きい数用


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7
N = 2 * 10**6 + 5  # 出力の制限
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


K = ni()
S = ns()
s_len = len(S)
mod = 10 ** 9 + 7
ans = 0

total = K + s_len

rui = 1


for i in range(total, s_len - 1, -1):
    ans = (ans + cmb(total, i, mod) * rui) % mod
    # print(ans)
    rui = (rui * 25) % mod
print(ans)


Measured memory_bytes: 205104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,k,a,b,c,p,q,r,s,x,y,z,ct=0,flag;
    cin>>a>>b>>c;
    ct=flag=0;
    while(a!=b || b!=c || c!=a)
    { //cout<<"palash"<<endl;
        while(a>b && a>c) {b++;c++;ct++;}
        while(b>a && b>c) {a++;c++;ct++;}
        while(c>b && c>a) {b++;a++;ct++;}
        while(a==b && c<a && c<b) {c+=2;ct++;}
        while(b==c && a<b && a<c) {a+=2;ct++;}
        while(a==c && b<a && b<c) {b+=2;ct++;}
        if(a==b && b==c && a==c){flag=1;break;}
        //cout<<a<<" "<<b<<" "<<c<<endl;
    }
    if(flag==1) cout<<ct<<endl;
    else cout<<"0"<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
# 上記の文がないとREになる。
N = int(input())
graph = [[] for _ in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))
# これによって木が定義できた
# print(graph)

flag = [None for _ in range(N)]  # まだどの頂点も探索していない


def k(v, distance):  # distanceは0or1
    flag[v] = distance  # 最初は0

    for next_v, w in graph[v]:
        if flag[next_v] == 1 or flag[next_v] == 0:  # 到達済み（親）であればcontinue
            continue
        if (w % 2) == 0:  # そのノードへの距離が偶数であればそのまま（最初は0なので）
            k(next_v, distance)
        else:
            k(next_v, 1-distance)


k(0, 0)  # 親を強制的に決めてよい, この場合は0のノードを親にしている
for i in range(N):
    print(int(flag[i]))


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

#define MAX_N 100001
int dp[MAX_N];
int flag[MAX_N];
vector<int> graph[MAX_N];
void dfs(int v){
    if(flag[v] == 1) return;
    flag[v] = 1;
    int res = 0;
    for (int x: graph[v]){
        dfs(x);
        res = max(res, dp[x]+1);
    }
    dp[v] = res;
}

int main() {
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
    }
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        dfs(i);
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

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

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

void swap(int *a, int *b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void bubble_sort(int *p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int det(int p[5][5], int n)
{
	int ans = 0;

	int tmp[25] = { 0 };
	int tmp2[5][5];
	int cnt = 0;

	if (n == 2)
		return p[0][0] * p[1][1] - p[0][1] * p[1][0];
	else
	{
		for(int i = 0; i < n; i++)
		{
			cnt = 0;
			for (int k = 0; k <n; k++)
			{
				for (int l = 0; l < n; l++)
				{
					if (k != 0 && l != i)
					{
						tmp[cnt] = p[k][l];
						cnt++;
					}
				}
			}
			cnt = 0;
			for (int k = 0; k < n-1; k++)
			{
				for (int l = 0; l < n-1; l++)
				{
					tmp2[k][l] = tmp[cnt];
					cnt++;
				}
			}
			ans+=p[0][i]*pow(-1,i)*det(tmp2, n - 1);
		}
	}
	return ans;
}

int main()
{
	char str[20];
	int n[20];

	scanf("%s", str);

	for (int i = 0; str[i] != '\0'; i++)
	{
		if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T')
			n[i] = 1;
		else
			n[i] = 0;
	}

	int max = 0, count = 0;

	for (int i = 0; str[i] != '\0'; i++)
	{


		if (n[i] == 1 && count == 0)
			count++;


		if (count > max)
			max = count;

	    if (n[i] == 1 && n[i + 1] == 1)
			count++;
		else
			count = 0;

		if (count > max)
			max = count;
	}

	printf("%d\n", max);
}

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

main(){
	while(true){
		int n;
		cin>>n;
		
		if(n<=0){
			break;
		}
		
		for(int i=0; i<n; ++i){
			// 数学の点数、英語の点数、国語の点数 pj
			int m,e,j;
			cin>>m>>e>>j;
			
			if(m==100||e==100||j==100||m+e>=90*2||m+e+j>=80*3){
				puts("A");
			}else if(m+e+j>=70*3||(m+e+j>=50*3&&(m>=80||e>=80))){
				puts("B");
			}else{
				puts("C");
			}
			
		}
	}
}


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

int main() {
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int X;
    X=tx-sx;
    int Y;
    Y=ty-sy;
    string answer="";
    for(int i=0;i<Y;i++)
    {answer+="U";}
    for(int i=0;i<X;i++)
    {answer+="R";}
    answer+="D";
    for(int i=0;i<X-1;i++)
    {answer+="L";}
    for(int i=0;i<Y-1;i++)
    {answer+="D";}
    answer+="LL";
    for(int i=0;i<Y+1;i++)
    {answer+="U";}
    for(int i=0;i<X+1;i++)
    {answer+="R";}
    answer+="DRDD";
    for(int i=0;i<X-1;i++)
    {answer+="L";}
    for(int i=0;i<Y-1;i++)
    {answer+="D";}
    answer+="LLU";
    cout<<answer<<endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k;
    cin >> n >> k;
    int sz = 0;
    ll s = 0;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    ll mx = 0;
    rep(i,n){
        if(sz == k){
            s += a[i];
            s -= a[i-k];
        }else{
            s += a[i];
            sz++;
        }
        mx = max(mx, s);
    }
    printf("%.10lf\n", (double)(mx+k)/2);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    int ans = 0;

    for (int i = 1; i <= n; i++)
    {
        if (i % 2 == 1 && a[i] % 2 == 1)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
s = input()
a, b = s[:2], s[2:]
def isMonth(string):
  if int(string) >= 1 and int(string) <= 12:
    return True
  else:
    return False
if isMonth(a) and isMonth(b):
  print("AMBIGUOUS")
elif isMonth(a) and not(isMonth(b)):
  print("MMYY")
elif not(isMonth(a)) and isMonth(b):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define Nmax 22

using namespace std;

const long long INF=1e18l+2;
const int MOD = 1e9+7;
ifstream f("1.in");

int dp[1<<(Nmax-1)+5];
int n, can[Nmax][Nmax];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> can[i][j];

    dp[0]=1;
    for (int mask = 0; mask < (1<<n)-1; mask++)
    {
        int a= __builtin_popcount(mask);
        for (int b = 0; b < n; b++)
            if(can[a][b] && !(mask&(1<<b)))
            {
                dp[mask^(1<<b)]+=dp[mask];
                dp[mask^(1<<b)]%=MOD;
            }

    }

    cout << dp[(1<<n)-1];

    return 0;
}


Measured memory_bytes: 10496