akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int n,m,q;
    cin >> n >> m >> q;
    vector<vector<int>>grid(n + 1,vector<int>(n + 1,0));
    rep(_,m){
        int l,r; cin >> l >> r;
        --l,--r;
        grid[l][r]++;
    }
    rep(i,grid.size())rep(j,grid.size()){
        if(j) grid[i][j] += grid[i][j-1];
    }
    rep(j,q){
        int p,q; cin >> p >> q;
        --p,--q;
        int ans = 0;
        for(int j = p; j <= q;++j)ans += grid[j][q] - ( p == 0 ? 0 :grid[j][p-1]);
        cout << ans << endl;
    }
}




Measured memory_bytes: 2944
N,M = map(int,input().split())
G = {}
for _ in range(M):
    a,b = map(int,input().split())
    if a not in G:
        G[a] = []
    G[a].append(b)
    if b not in G:
        G[b] = []
    G[b].append(b)
for i in range(1,N+1):
    if i in G:
    	print(len(G[i]))
    else:
        print(0)

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


struct Segm{
	int x;
	int id;
	Segm(int xx ,int i) {
		x = xx;
		id = i;
	}
	
	inline bool operator <(const Segm& foo) const {
		if (x != foo.x) return x < foo.x;
		return id < foo.id;
	}
};

const int MX = 1000000 + 10;
bool used[MX];
int saves[MX][2];

int main() {

	int n;
	ignore = scanf("%d", &n);
	
	set<Segm> Lb, Rb, Lb2, Rb2;
	
	for (int i = 0; i < n; i++) {
		int a, b;
		ignore = scanf("%d %d", &a, &b);
		saves[i][0] = a;
		saves[i][1] = b;
		
		Lb.insert(Segm(b, i));
		Lb2.insert(Segm(b,i));
		Rb.insert(Segm(a, i));
		Rb2.insert(Segm(a,i));
	}
	long long ans1;
	{
		int x = 0;
		long long ans = 0;
		
		for (int k = 0; k < n; k++) {
			
			if (k % 2 == 0) {
				//Rb
				
				while (true) {
					auto it = Rb.end();
					it--;
					Segm tmp = *it;
					Rb.erase(it);
					
					if (not used[tmp.id]) {
						used[tmp.id] = true;
						
						if (saves[tmp.id][0] <= x and x <= saves[tmp.id][1]) {
						}
						else {
							ans += abs(x - tmp.x);
							x = tmp.x;
						}
						
						break;
					}
				}
				
			}
			else {
				//Lb
				
				while (true) {
					auto it = Lb.begin();
					Segm tmp = *it;
					Lb.erase(tmp);
					
					if (not used[tmp.id]) {
						used[tmp.id] = true;
						
						
						if (saves[tmp.id][0] <= x and x <= saves[tmp.id][1]) {
						}
						else {
							ans += abs(x - tmp.x);
							x = tmp.x;
						}
						
						break;
					}
				}
				
			}
			
		}
		
		ans += abs(x);
		
		ans1 = ans;
	}
	long long ans2;
	swap(Lb, Lb2);
	swap(Rb, Rb2);
	memset(used, 0, sizeof used);
	{
		int x = 0;
		long long ans = 0;
		
		for (int k = 0; k < n; k++) {
			
			if (k % 2 == 1) {
				//Rb
				
				while (true) {
					auto it = Rb.end();
					it--;
					Segm tmp = *it;
					Rb.erase(it);
					
					if (not used[tmp.id]) {
						used[tmp.id] = true;
						
						if (saves[tmp.id][0] <= x and x <= saves[tmp.id][1]) {
						}
						else {
							ans += abs(x - tmp.x);
							x = tmp.x;
						}
						
						break;
					}
				}
				
			}
			else {
				//Lb
				
				while (true) {
					auto it = Lb.begin();
					Segm tmp = *it;
					Lb.erase(tmp);
					
					if (not used[tmp.id]) {
						used[tmp.id] = true;
						
						
						if (saves[tmp.id][0] <= x and x <= saves[tmp.id][1]) {
						}
						else {
							ans += abs(x - tmp.x);
							x = tmp.x;
						}
						
						break;
					}
				}
				
			}
			
		}
		
		ans += abs(x);
		
		ans2 = ans;
	}
	
	
	printf("%lld\n", max(ans1, ans2));

	return 0;
}


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

int main () {

    int N;
    cin >> N;

    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    sort(L, L + N);
    
    int other_edges = 0;
    for (int i = 0; i < N-1; i++) {
        other_edges += L[i];
    }

    cout << ((L[N-1] < other_edges)? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
def action_handler(array)
  array.each_with_index do |items, items_index|
    items.each_with_index do |str, i|
      if str == "#"
        if variable_checker(array, items_index, items, i) == false
          return false
        end
      end
    end
  end
  return true
end

def variable_checker(array, items_index, items, i)
  result = []
  #top
  if array[items_index - 1] != nil
    top_item = array[items_index - 1][i]
    result.push(top_item == "#")
  end
  #left
  if items[i - 1] != nil
    left_item = items[i - 1]
    result.push(left_item == "#")
  end
  #right
  if items[i + 1]  != nil
    right_item = items[i + 1]
    result.push(right_item == "#")
  end
  #bottom
  if array[items_index + 1] != nil
    bottom_item = array[items_index + 1][i]
    result.push(bottom_item == "#")
  end

  true_results = result.select {|n| n == true}
  return true if true_results.size != 0
  return false
end

input = gets.chop.split.map(&:to_i)
#入力:1234
#    1234 -> [["1", "2", "3", "4"], ["1", "2", "3", "4"], ["1", "2", "3", "4"]]
#    1234
lines = []
while line = gets
    lines << line.chop.split('').map(&:to_s)
end

print action_handler(lines) ? 'Yes' : 'No'


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,c,d,e=0;
cin>>a;
b=a;
while(a)
{
e+=a%10;
a=a/10;
}
if(b%e==0)cout<<"Yes\n";
else cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  int d[110];
  for(int i=0;i<n;i++) cin >>d[i];
  int sum=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }
  cout <<sum<<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    ll l, r; cin >> l >> r;
    if (l + 2019 < r) r = l + 2019;
    long long ans = 1e18;
    for (ll i = l; i < r; i++) {
        for (ll j = l+1; j <= r; j++) {
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int sum = 0;
		sum += x/500*1000;
		sum  +=(x%500)/5*5;
		System.out.print(sum);
	}
}

Measured memory_bytes: 21716
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
from scipy.misc import comb
# from scipy.special import perm
# from scipy.special import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########
n = i_inpl()
a = l_inpl()
max_v = max(a)/2

an = INF
for ai in a:
    if abs(an-max_v) > abs(ai-max_v) and max(a) != ai:
        an = ai
print(max(a), an)



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

int main()
{
	int n; char c; string s;
	while(cin >> n)
	{
		int cd[13]={0},pr[5]={0};

		cd[n-1]++;
		for(int i=0; i<4; i++)
		{
			cin >> c >> n;
			cd[n-1]++;
		}

		for(int i=0; i<13; i++)
		{
			pr[cd[i]]++;
		}

		bool st=false;
		for(int i=0; i<10; i++)
		{
			int sm=0;
			for(int j=0; j<5; j++) sm+=(cd[(i+j)%13]?1:0);
			if(sm==5) st=true;
		}

		                      s="null";
		     if(pr[4])        s="four card";
		else if(pr[3]&&pr[2]) s="full house";
		else if(st)           s="straight";
		else if(pr[3])        s="three card";
		else if(pr[2]==2)     s="two pair";
		else if(pr[2])        s="one pair";

		cout << s << endl;
	}
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


def solve(N: int, Y: int):

    for i in range(N+1):
        if 10000*i + 5000*(N-i) < Y:
            continue

        for j in range(N+1-i):
            k = N - i - j 
            if 10000*i + 5000*j + 1000*k == Y: 
                print(i,j,k)
                return

    print(-1,-1,-1)
    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()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int ans(char x){
  int ans;
  if(x=='A')
    ans=10;
  else if(x=='B')
    ans=11;
  else if(x=='C')
    ans=12;
  else if(x=='D')
    ans=13;
  else if(x=='E')
    ans=14;
  else
    ans=15;
  
  return ans;
}
int main() {
  char a,b;
  cin >> a>>b;
  int x,y;
  x=ans(a);
  y=ans(b);
  if(x>y)
    cout<<'>'<<endl;
  else if(x<y)
    cout<<'<'<<endl;
  else
    cout<<'='<<endl;
  
  

}



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

long long gcd(long long a,long long b){
    while(a&&b){
        if(a>b){
            a = a%b;
        }else{
            b = b%a;
        }
    }
    return a+b;
}

long long lcm(long long a,long long b){
    return a*b / gcd(a,b);
}

int main()
{
    int a,b;
    std::cin >> a >> b;
    std::cout << lcm(a,b) << std::endl;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] f = new int[N + 10];
		f[0] = 0;
		f[1] = 1;
		for(int i=2;i<N + 10;i++){
			int bc = PopCnt(i);
			if(i % bc == 0){
				f[i] = 1;
			} else {
				f[i] = 1 + f[i % bc];
			}
		}
		
		
		int bt = 0;
		for(int i=0;i<N;i++) if(S[i] == '1') bt++;
		
		int[] a0 = new int[N];
		int m0 = bt - 1;
		
		if(m0 != 0){
			a0[N-1] = 1 % m0;
			for(int i=N-2;i>=0;i--){
				a0[i] = a0[i + 1] * 2 % m0;
			}
		}
		
		int[] a1 = new int[N];
		int m1 = bt + 1;
		
		a1[N-1] = 1 % m1;
		for(int i=N-2;i>=0;i--){
			a1[i] = a1[i + 1] * 2 % m1;
		}
		
		
		int X0 = 0;
		int b = 1;
		if(m0 != 0){
			for(int i=N-1;i>=0;i--){
				X0 += (S[i] - '0') * b % m0;
				X0 %= m0;
				b *= 2; b %= m0;
			}
		}
		int X1 = 0;
		b = 1;
		for(int i=N-1;i>=0;i--){
			X1 += (S[i] - '0') * b % m1;
			X1 %= m1;
			b *= 2; b %= m1;
		}
//Console.WriteLine("X0:{0}",X0);
//Console.WriteLine("X1:{0}",X1);
//Console.WriteLine("a0: {0}",String.Join(" ",a0));
//Console.WriteLine("a1: {0}",String.Join(" ",a1));

		int[] ans = new int[N];
		for(int i=0;i<N;i++){
			if(S[i] == '0'){
				int m = m1;
				int md = (X1 + a1[i]) % m;
				ans[i] = 1 + f[md];
//Console.WriteLine("i:{0} m:{1} md:{2} ans:{3}",i, m, md, ans[i]);
			} else {
				int m = m0;
				if(m == 0){
					ans[i] = 0;
					continue;
				}
				int md = (X0 - a0[i]) % m;
				if(md < 0) md += m;
				ans[i] = 1 + f[md];
//Console.WriteLine("i:{0} m:{1} md:{2} ans:{3}",i, m, md, ans[i]);
			}
		}
		
		
		Console.WriteLine(String.Join("\n",ans));
		
		
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
		
	}
	int PopCnt(int bits){
		bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
		bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
		bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
		bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
		return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 31876
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;

  int num[100100] = {};
  for (int i = 0; i < n - 1; ++i)
  {
    if (s[i] == 'A' && s[i + 1] == 'C')
      num[i + 1] = num[i] + 1;
    else
      num[i + 1] = num[i];
    //cout << num[i + 1] << endl;
  }

  while (q--)
  {
    int l, r;
    cin >> l >> r;
    cout << num[r - 1] - num[l - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
import time


_, = map(int,readline().split())
D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(ans,s,c): # ans: 0-indexed としたときのスコアの計算
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        #print(score) # i日目のスコア
    return score


#ans = [max(range(26),key=lambda x: si[x]) for si in s]
#ans = (list(range(26))*20)[:365]

def first_solution(s,c):
    minus = c[:]
    ans = [0]*365
    for i, si in enumerate(s):
        ans[i] = idx = max(range(26), key=lambda x:si[x]+minus[x])
        for i in range(26):
            minus[i] += c[i]
        minus[idx] = 0
    return ans        


"""
solution = 初期解(ランダム生成や、貪欲法など他の手法で求めたものを利用)
while 時間のある限り:
    solution を(ランダムに)少し変形
    if 変形前より解が悪化:
        solution を変形前の状態に戻す
"""


from bisect import bisect_left, bisect_right
"""
i 日目と i+1 日目を入れ替え
"""
def swap(i,ans,days,c,s):
    j = i+1
    ai = ans[i]
    aj = ans[j]
    di = days[ai]
    dj = days[aj]
    idx_i = bisect_left(di,-i)
    idx_j = bisect_left(dj,-j)
    
    #print(di,i,idx_i,ai)
    #print(dj,j,idx_j,aj)
    #assert di[idx_i] == -i and dj[idx_j] == -j 
    
    i_prev = -di[idx_i - 1]
    i_next = -di[idx_i + 1] if di[-1] != -i else -1

    j_prev = -dj[idx_j - 1]
    j_next = -dj[idx_j + 1] if dj[-1] != -j else -1

    delta_i = c[ai]*(2*i-i_prev-i_next) + s[j][ai] - s[i][ai]
    delta_j = c[aj]*(j_prev+j_next-2*i) - s[j][aj] + s[i][aj]
    delta = delta_i + delta_j

    return delta,idx_i,idx_j


def main(ans,s,c):
    from random import randrange
    start = time.time()
    days = [[-365] for _ in range(26)]
    for i in range(364,-1,-1):
        days[ans[i]].append(-i)

    while time.time() - start < 0.5:
        i = randrange(364)
        if ans[i] != ans[i+1]:
            delta,idx_i,idx_j = swap(i,ans,days,c,s)
            if delta > 0:
                days[ans[i]][idx_i] -= 1
                days[ans[i+1]][idx_j] += 1
                ans[i],ans[i+1] = ans[i+1],ans[i]

    return ans

#print(score(ans,s,c))
output(main(first_solution(s,c),s,c))







Measured memory_bytes: 9980
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll K, X;
  cin >> K >> X;
  if (K * 500 >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    int slen = s.size();
    string res = "Yes";
    rep(i, slen){
        if(i%2){
            if(s[i]=='R'){
                res = "No";
                break;
            }
        }else{
            if(s[i]=='L'){
                res = "No";
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <deque>
#include <iostream>
#include <string>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
  string S;
  int Q;
  cin >> S >> Q;

  deque<char> str(S.begin(), S.end());

  int query, f;
  char c;
  bool reversed = false;
  for (auto i = 0; i != Q; ++i) {
    cin >> query;
    switch (query) {
      case 1:
        reversed = !reversed;
        break;
      case 2:
        cin >> f >> c;
        if ( (f == 1) == reversed ) {
            str.push_back(c);
        } else {
            str.push_front(c);
        }
        break;
    }
  }

  cout << (reversed ? string(str.rbegin(), str.rend())
                    : string(str.begin(), str.end()))
       << endl;

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int x;
	cin>>x;
	cout<<!x;
	return 0;
}



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

A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
C = [0 for _ in range(M)]
D = [0 for _ in range(M)]

for _ in range(N):
    A[_], B[_] = map(int, input().split())

for _ in range(M):
    C[_], D[_] = map(int, input().split())

# マンハッタン距離
# A(x1, y1), B(x2, y2)とすると、dist(A,B)=|x1-x2|+|y1-y2|

# N, M の最大値は50
# 50個のcheck pointに対して50個の学生を調べても余裕で間に合う
# 普通に実装してOK
ans = []
for s in range(N):
    nearest_cp = -1
    nearest_dist = 10e12 
    for c in range(M):
        d = abs(A[s]-C[c]) + abs(B[s]-D[c])
        if d < nearest_dist:
            nearest_dist = d
            nearest_cp = c
    
    ans.append(nearest_cp+1)

for a in ans:
    print(a)
    

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

class Program
{
    static void Main(string[] args)
    {
        List<byte> NM = Console.ReadLine().Split(' ').Select(o => byte.Parse(o)).ToList();
        byte N = NM[0], M = NM[1];

        Console.WriteLine(N == M ? "Yes" : "No");
    }
}

Measured memory_bytes: 11348
#include<iostream>
 
using namespace std;
 
int main(void){
  int K, S;
  int ans = 0;
  cin >> K >> S;
  for(int X = 0; X <= K; X++){
    for(int Y = 0; Y <= K; Y++){
      if(X + Y <= S && S <= X + Y + K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI           acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    //scan(n);
    cin>>n;
    ll A[n], B[n-1];
    f0(i,n-1)
    {
        cin>>B[i];
    }
    A[0]=B[0];
    f0(i,n-1)
    {
        if(A[i]<B[i])
        {
            A[i+1]=B[i];
        }
        else
        {
            A[i]=B[i];
            A[i+1]=B[i];
        }
    }
    f0(i,n)
    {
        sum+=A[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
bool visited[100001];
int ans[100001];

void bfs(){
    queue<int> q;
    q.push(1);
    visited[1] = true;
    
    while(q.size()){
        int cur = q.front(); q.pop();
        for(auto i : adj[cur]){
            if(!visited[i]){
                ans[i] = cur;
                q.push(i);
                visited[i] = true;
            }
        }
    }
}
int main()
{
	memset(visited,false,sizeof(visited));
	memset(ans,0,sizeof(ans));
	int nodes,edges;
	cin >> nodes >> edges;
	for(int i=0;i<edges;i++)
	{
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bfs();
	cout << "Yes\n";
	for(int i=2;i<=nodes;i++)
		cout << ans[i] << "\n";
}
 

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n), s(n + 1, 0);
  map<ll, ll> mp;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s[i + 1] = a[i] + s[i];
    mp[s[i]]++;
  }
  mp[s[n]]++;

  for (auto m : mp)
    ans += m.second * (m.second - 1) / 2;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
function main()  

  N = parse(Int,readline())
  R = [(0,0) for i in 1:N]
  
  for i in 1:N
    
    (a,b) = map(x -> parse(Int,x), split(readline()))
    R[i] = (a-b,a+b)
    
  end

  sort!(R, by = R -> R[2])
  
  check = R[1]
  count = 0

  for i in 2:N
   
    if check[2] <= R[i][1]
      count += 1
      check = R[i]
    end

  end
  
  println(count+1)
  
end

main()


Measured memory_bytes: 154412
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;

  int a = A/10;
  int b = B/10;
  int c = C/10;
  int d = D/10;
  int e = E/10;
  vector<int> x(5);

  x.at(0) = A%10;
  x.at(1) = B%10;
  x.at(2) = C%10;
  x.at(3) = D%10;
  x.at(4) = E%10;

  
  sort(ALL(x));
  int cnt=0;
  int flag = 0;
  REP(i,5){
    if(x.at(i)!=0&&flag==0){
      flag = 1;
      cnt+=x.at(i);
      continue;
    }else if(x.at(i)!=0){
      cnt+=10;
    }
  }
  cout << (a+b+c+d+e)*10+cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

struct event {
  int t, type, val;
  bool operator < (const event &e) const {
    return t < e.t;
  }
};

signed main() {
  int N, Q;
  cin >> N >> Q;

  vector<event> v(2*N);
  REP(i, N){
    int s, t, x;
    cin >> s >> t >> x;
    v[i] = {s-x, 1, x};
    v[i+N] = {t-x, -1, x};
  }
  sort(ALL(v));

  multiset<int> s;

  int k = 0;
  REP(i, Q){
    int D;
    cin >> D;

    while(k < 2*N && v[k].t <= D){
      if(v[k].type == 1) s.insert(v[k].val);
      else s.erase(s.find(v[k].val));
      k++;
    }

    if(s.empty()) cout << -1 << "\n";
    else cout << *s.begin() << "\n";
  }

  return 0;
}


Measured memory_bytes: 21824
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, X[2000];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];
	sort(X, X + N);
	cout << (X[N - 1] - X[0] + 1) / 2 << endl;
}


Measured memory_bytes: 3176
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b;
    cin>>a>>b;
    if(a*b==15){
        cout<<'*'<<endl;
    }
    else if(a+b==15){
        cout<<'+'<<endl;
    }
    else{
        cout<<'x'<<endl;
    }
    
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**9)

def dfs(l,d):
    loc[l]=d
    for n_l,n_d in way[l]:
        if loc[n_l]==10**9:
            dfs(n_l,d+n_d)
        elif loc[n_l]!=d+n_d:
            print("No")
            exit()

N,M=map(int,input().split())

way=[[] for i in range(N)]
loc=[10**9]*N

for _ in range(M):
    L,R,D=map(int,input().split())
    way[L-1].append([R-1,D])
    way[R-1].append([L-1,-D])

for i in range(N):
    if loc[i]==10**9:
        dfs(i,0)

print("Yes")

Measured memory_bytes: 135196
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants 
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007
 
// // for using in pairs
#define F first
#define S second
 
// Macros
#define all(x) begin(x), end(x)
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.
/**
 * The type of element in the vector should have overload for << operator with ostream. 
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T> v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

/**
 * Both types in the pair should have overload for << operator with ostream. 
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2> p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

template<typename T>
void swap(T &a, T &b)
{
	T t = a;
	a = b;
	b = t;
}

// Utility functions.
void swap(int &a, int &b)
{
	int t = a;
	a = b;
	b = t;
}

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}

//////////////////// START CODE HERE ///////////////////////////


void solve(int tc)
{
	int n, W;
	cin >> n >> W;


	int w[n], val[n];
	int valSum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i] >> val[i];
		valSum += val[i];
	}

	int dp[n + 1][valSum + 1];
	// dp[i][j]: upto using  i - 1th items, minimum weights required to get val = j
	int ans = 0;

	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= valSum; j++)
		{
			if (!j)
			{
				dp[i][j] = 0;
				continue;
			}
			if (!i)
			{
				dp[i][j] = INF;
				continue;
			}
			dp[i][j] = dp[i - 1][j];
			if (j >= val[i - 1])
				dp[i][j] = min(dp[i][j], dp[i - 1][j - val[i - 1]] + w[i - 1]);

			if (dp[i][j] <= W)
				ans = max(ans, j);
		}
	}
	cout << ans << "\n";
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

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

	int t = 1;
	// cin >> t;		
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}


Measured memory_bytes: 82388
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, k;
long long ans = 0;
vector< int > arr( 2e5 + 5 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> k;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];		
	}
	sort( arr.begin() + 1, arr.begin() + n + 1, greater< int >() );
	k = min( n, k );
	for( int i = k + 1; i <= n; ++i )
	{
		ans += arr[ i ];
	}
	cout << ans << "\n";	
	return 0;
}

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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+1

#define N 105

//time complexity will be O(N^2*V) space complexity will be O(N^2*V)

class item{
    public:
    int val;
    int wt;
};

int n,w;
item arr[N];

int solve(){
    int maxVal=n*1000;
    int dp[n+1][maxVal+1];

    for(int v=0;v<=maxVal;v++){
       dp[1][v]=INF; 
    }
    dp[1][arr[1].val]=arr[1].wt;
    dp[1][0]=0;

    for(int i=2;i<=n;i++){
        
        for(int v=0;v<=maxVal;v++){
            dp[i][v]=dp[i-1][v];

            if(arr[i].val>v) continue;

            dp[i][v]=min(dp[i][v],arr[i].wt+dp[i-1][v-arr[i].val]);
        }
    }
    int ans;
    for(int v=0;v<=maxVal;v++){
        if(dp[n][v]<=w){
            ans=v;
        }
    }
    return ans;
}

int32_t main(){
    cin>>n>>w;
    for(int i=1;i<=n;i++) cin>>arr[i].wt>>arr[i].val;
    cout<<solve()<<endl;
}

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

int euclid(int a, int b){
    if (a < b){
        int temp = a;
        a = b;
        b = temp;
    }

    int r = a % b;
    while (r != 0){
        a = b;
        b = r;
        r = a % b;        
    }

    return b;
}

int main(){
    int N, ans;
    cin >> N;
    int A[N];
    for (int i=0; i<N; i++){
        cin >> A[i];
        if (i==0) ans = A[0];
        else ans = euclid(ans, A[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
void movePut(int fx, int fy, int tx, int ty) {
	cout << fx << " " << fy << " " << tx << " " << ty << "\n";
}
struct p {
	int fx;
	int fy;
	int tx;
	int ty;
	p(int _fx, int _fy, int _tx, int _ty) {
		fx = _fx;
		fy = _fy;
		tx = _tx;
		ty = _ty;
	}
};
void MakeThemEven() {
	int H, W;
	cin >> H >> W;
	int t[501][501];
	for (size_t i = 0; i < H; i++)
	{
		for (size_t j = 0; j < W; j++)
		{
			int a;
			cin >> a;
			if (a % 2 == 0) {
				t[i][j] = 0;
			}
			else {
				t[i][j] = 1;
			}
		}
	}
	int nH = 0;
	int nW = 0;
	int count = 0;
	vector<p> vp;

	for (size_t w = 0; w < W; w++)
	{
		for (size_t h = 0; h < H; h++)
		{
			if (w < W - 1) {
				if ((t[h][w] % 2) == 1) {
					t[h][w + 1] += 1;
					count++;
					vp.push_back(p(h, w, h, w + 1));
				}
			}
			else {
				if ((t[h][w] % 2) == 1 && h < H - 1) {
					t[h + 1][w] += 1;
					count++;
					vp.push_back(p(h, w, h + 1, w));
				}
			}
		}
	}
	cout << count << "\n";
	for (size_t i = 0; i < vp.size(); i++)
	{
		movePut(vp[i].fx + 1, vp[i].fy + 1, vp[i].tx + 1, vp[i].ty + 1);
	}
}
int main() {
	MakeThemEven();
	return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
int h,w,k;
char a[6][6];
char b[6][6];
bool fb(){
int c=0;
for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    if(a[i][j]=='#')
    c++;
if(c==k)
    return true;
return false;
}
void same(){
for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
        a[i][j]=b[i][j];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	//map<string,int>m;
	while(t--)
	{
	cin>>h>>w>>k;
	for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
        cin>>a[i][j];
        b[i][j]=a[i][j];
        }
    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            int r=i;
            int rn=0;
            while(r>0){
                if(r%2){
                    for(int l=0;l<w;l++)
                    a[rn][l]='r';
                }
                rn++;
                r/=2;
            }
            int c=j;
            int cn=0;
            while(c>0){
                if(c%2){
                    for(int l=0;l<h;l++)
                        a[l][cn]='r';
                }
                cn++;
                c/=2;
            }
            if(fb())
                ans++;
            same();
        }
    }
    cout<<ans;
	}

return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int ans = 700;
	if (s[0] == 'o') ans+=100;
	if (s[1]=='o') ans+=100;
	if (s[2]=='o') ans+=100;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

const int limit = 50;
int N, M;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < N; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

int main() {

    scanf("%d %d", &N, &M);

    for (int i = 0; i < M; ++i) {
        scanf("%d %d", &a[i], &b[i]);
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < M; ++i) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for (int j = 0; j < N; ++j) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for (int j = 0; j < N; ++j) if (visited[j] == false) bridge = true;
        if (bridge == true) ans++;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

s = input()[:-1]

ans = True
for i in range(len(s)):
    if (i+1) % 2 == 1:
        # print(1, s[i])
        if s[i] == 'L':
            ans =False
            break
    if (i + 1) % 2 == 0:
        # print(2, s[i])
        if s[i] =='R':
            ans = False
            break

if ans:
    print('Yes')
else:
    print('No')



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

int main(){
  int N;
  cin>>N;
  vector<int64_t> v(N);
  for(int i=0;i<N;i++){
    cin>>v.at(i);
  }
  vector<int64_t> work(N);
  for(int i;i<N;i++){
    work.at(i)=v.at(i)*(N+1)+i+1;
  }
  sort(work.begin(),work.end());
  for(int i;i<N;i++){
    cout<<work.at(i)%(N+1)<<" ";
  }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int sum = 0,powsum = 0,N = in();
    REP(i,N){
        int tmp = in();
        sum += tmp;
        powsum += tmp*tmp;
    }
    cout << (sum*sum - powsum)/2 << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

vll v(3000, -1);

ll f(ll n) {
	if (n < 3)
		return 0;
	else if (n < 6)
		return 1;
	if (v[n] == -1) {
		v[n] = 1;
		for (ll i = 3; i < n; i++) {
			v[n] += f(n - i);
			v[n] = (v[n] + MOD) % MOD;
			// LG("", n, v[n], i)
		}
	}
	// LG(n, v[n]);
	return v[n];
}

int main() {
	fastio;
	ll n;
	cin >> n;
	cout << f(n);
}

Measured memory_bytes: 3688
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC ZZZZZZZZZZZZZZZ.
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT INP.
        	PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		COMPUTE C = A - B - B.
			IF A > B + B THEN
				DISPLAY C
			ELSE 
				DISPLAY "0"
			END-IF.
		STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

vector<mint> ones;

struct S {
    mint x;
    int size;
    S(mint x = 0, int size = 0) : x(x), size(size) {}
};

S op(S a, S b) {
    return S(a.x * ((mint)10).pow(b.size) + b.x, a.size + b.size);
}

S e() { return S(); }

int id() { return 0; }

S mapping(int d, S a) {
    if (d == id())
        return a;
    else
        return S(ones.at(a.size) * d, a.size);
}

int comp(int d2, int d1) {
    if (d2 == id())
        return d1;
    else
        return d2;
}

void solve(int N, int Q, vector<int> L, vector<int> R, vector<int> D) {
    ones = vector<mint>(N + 1);
    for (int i = 0; i < N; i++) {
        ones.at(i + 1) = ones.at(i) * 10 + 1;
    }

    lazy_segtree<S, op, e, int, mapping, comp, id> seg(N);
    for (int i = 0; i < N; i++) {
        seg.set(i, S(1, 1));
    }

    for (int i = 0; i < Q; i++) {
        seg.apply(L.at(i), R.at(i), D.at(i));
        mint S = seg.all_prod().x;
        printf("%d\n", S.val());
    }
}

int main() {
    int N;
    cin >> N;
    int Q;
    cin >> Q;
    vector<int> L(Q);
    vector<int> R(Q);
    vector<int> D(Q);
    for (int i = 0; i < Q; i++) {
        cin >> L.at(i);
        cin >> R.at(i);
        cin >> D.at(i);
        --L.at(i);
    }
    solve(N, Q, move(L), move(R), move(D));
    return 0;
}


Measured memory_bytes: 13076
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int K; string S;
    cin >> K >> S;
    if(K >= S.length()){
        res = S;
    }else{
        res = S.substr(0,K) + "...";
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<string>() << endl;
    return 0;
}

Measured memory_bytes: 3652