akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >>a>>b>>c;
    if(((100*a)+(10*b)+c)%4==0)printa("YES");
    else printa("NO");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();
        int mAngle;
        double hAngle = h * 30 + 0.5 * m;
        if(m == 0)
        {
            mAngle = 360;
        }
        else
        {
            mAngle = (int)m * 6;
        }
        double absAngle = Math.abs(hAngle - (double)mAngle);
        double cos = Math.cos(Math.toRadians(absAngle));
        double ans = (a * a) + (b * b) - (2 * a * b * cos);
        System.out.println(Math.sqrt(ans));
    }
}

Measured memory_bytes: 37624
//void __(){
//    _(ll,n);
//    _(vl,a,n);
//    ll base = 0;
//    int last_change = 0;
//    for(int i = 0;; ++i){
//        ll times = (a[i%n]+base)/n;
//        a[i%n] -= times*(n+1);
//        base += times;
//        if(times)
//            last_change = i;
//        if(i-last_change > 2*n)
//            break;
//    }
//    print base;
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }
    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define _IWI(type,name,...) type name(__VA_ARGS__); cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
void __(){
    _(ll,n);
    _(vl,a,n);
    ll base = 0;
    int last_change = 0;
    for(int i = 0;; ++i){
        ll times = (a[i%n]+base)/n;
        a[i%n] -= times*(n+1);
        base += times;
        if(times)
            last_change = i;
        if(i-last_change > 2*n)
            break;
    }
    print base;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int mx = -1;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  int ans = INT_MAX;
  for (int i = 0; i <= mx; i++){
    int cur = 0;
    for (int j = 0; j < n; j++){
      cur += ((a[j] - i) * (a[j] - i)); 
    }
    ans = min(ans, cur);
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
b = ['.'] * w

while b in a:
    a.remove(b)

for i in range(w):
    flag = True
    for j in a:
        if j[i] == '#':
            flag = False
            break
    if flag:
        for j in a:
            j[i] = ''

for i in a:
    print(''.join(i))

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


int main()
{
	int r, g, b;
	cin >> r >> g >> b;

	int card;
	card = r * 100 + g * 10 + b;
	if (card % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
    return 0;
}

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

int main()
{
	char s[101], t[101];
	scanf("%s", s);
	scanf("%s", t);
	
	int i, j, s_count = 0, t_count = 0;
	char s_min = 'z' + 1, t_max = 'a' - 1;
	for (i = 0; s[i] != 0; i++) {
		if (s[i] < s_min) {
			s_count = 1;
			s_min = s[i];
		} else if (s[i] == s_min) s_count++;
	}
	for (j = 0; t[j] != 0; j++) {
		if (t[j] > t_max) {
			t_count = 1;
			t_max = t[j];
		} else if (t[j] == t_max) t_count++;
	}
	
	if (s_min < t_max) printf("Yes\n");
	else if (s_min == t_max) {
		if (s_count == i && s_count <= t_count && i < j) printf("Yes\n");
		else printf("No\n");
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
input()
array = sorted(list(map(int,input().split(" "))),reverse=True)
set_array = set(array)
set_array_array = sorted(list(set_array),reverse=True)
dic = {}
for a in set_array:
    dic[a] = 0
for a in array:
    dic[a] += 1
temp = []
for a in set_array_array:
    if dic[a] >= 2:
        temp.append(a)
        if dic[a] >= 4:
            temp.append(a)
if len(temp) >= 2:
    print(temp[0] * temp[1])
else:
    print(0)


Measured memory_bytes: 24460
n = [int(i) for i in input().split()]
count = int(input())
num = []

class Dice(object):
    def __init__(self,num):
        self.one = num[0]
        self.two = num[1]
        self.three = num[2]
        self.four = num[3]
        self.five = num[4]
        self.six = num[5]

    def right(self,top,forward):
        if top == self.one:
            if forward == self.two:
                return self.three
            elif forward == self.three:
                return self.five
            elif forward == self.five:
                return self.four
            elif forward == self.four:
                return self.two
        elif top == self.two:
            if forward == self.six:
                return self.three
            elif forward == self.three:
                return self.one
            elif forward == self.one:
                return self.four
            elif forward == self.four:
                return self.six
        elif top == self.three:
            if forward == self.two:
                return self.six
            elif forward == self.six:
                return self.five
            elif forward == self.five:
                return self.one
            elif forward == self.one:
                return self.two
        elif top == self.four:
            if forward == self.two:
                return self.one
            elif forward == self.one:
                return self.five
            elif forward == self.five:
                return self.six
            elif forward == self.six:
                return self.two
        elif top == self.five:
            if forward == self.one:
                return self.three
            elif forward == self.three:
                return self.six
            elif forward == self.six:
                return self.four
            elif forward == self.four:
                return self.one
        elif top == self.six:
            if forward == self.two:
                return self.four
            elif forward == self.four:
                return self.five
            elif forward == self.five:
                return self.three
            elif forward == self.three:
                return self.two


dice = Dice(n)
for i in range(count):
    num.append([int(i) for i in input().split()])

for i in range(count):
    print(dice.right(num[i][0],num[i][1]))

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


def solve(A: int, B: int, K: int):
    fa = max(0, A - K)
    # print(fa)
    diff = K - (A - fa)
    # print(diff)
    fb = max(0, B - diff)
    # print(fb)
    print(fa, fb)


# Generated by 1.1.6 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		int c = a + b;
		int d = a - b;
		int e = a * b;

		int max1 = Math.max(c, d);
		int max2 = Math.max(max1, e);

		System.out.println(max2);

	}
}

Measured memory_bytes: 23764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// A
		int apple = sc.nextInt();
		// P
		int apple_tri = sc.nextInt();
      	//下拵え
      	apple_tri += apple*3;        
        //調理
      	int apple_pie = apple_tri/2;
		// 出力
		System.out.println(apple_pie);
	}
}



Measured memory_bytes: 23252
n, m, k = map(int, input().split())
R = [[0]*n for _ in range(n)]
for _ in range(m):
  l, r = map(int, input().split())
  l -= 1
  r -= 1
  R[r][l] += 1

for i in range(1,n):
  for j in range(n):
    R[i][j]+=R[i-1][j]
    
for i in range(n):
  for j in range(n-2,-1,-1):
    R[i][j] += R[i][j+1]

#[print(R[i]) for i in range(n)]
for _ in range(k):
  p, q = map(int, input().split())
  print(R[q-1][p-1])

Measured memory_bytes: 9308
#include <iostream>
#include <string>
#define INF 1000000000
using namespace std;

string ary[60];
int cnt[60][36];
int main(){
	int N;
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>ary[i];
	}

	for(int i=1;i<=N;i++){
		for(int j=0;j<ary[i].length();j++){
			cnt[i][ary[i][j]-'a']++;
		}
	}

	string ans="";
	int mar;
	for(int i=0;i<26;i++){
		mar=INF;
		for(int j=1;j<=N;j++){
			mar=min(mar,cnt[j][i]);
		}
		for(int j=0;j<mar;j++)ans+=(char)(i+'a');
	}
	cout<<ans<<endl;
	return 0;
}



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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  int X;
  cin >> X;
  cout << (X >= 30 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3632
X,N=map(int,input().split())
P=list(map(int,input().split()))
m=100
ans=0
lis=list(range(101,-1,-1))
for k in lis:
    for l in range(N):
        if k==P[l]:
            lis[101-k]=0
for i in lis:
    if abs(i-X)<=m:
        m=abs(i-X)
        ans=i
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
 
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
 
// #define double long double
 
typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-6;
const double INF = 1e12;
const double PI = acos(-1);
 
P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}
 
// rot p around q by theta (counter-clockwise)
P rotP(P p, P q, double theta) {
    p -= q;
    double x = p.real(), y = p.imag();
    p = P(x * cos(theta) - y * sin(theta), x * sin(theta) + y * cos(theta));
    p += q;
    return p;
}
 
P center(P p, P q) {
    // P v = q - p;
    // double theta = asin(abs(v) / 2);
    // v *= (1 / abs(v));
    // P u = rotP(v, p, theta);
    // return p + u;
 
    // P v = q - p;
    // P h = v * P(0., 1.) / abs(v);
    // return p + (v / 2.) + h;
 
    P v = q - p;
    P h = P(v.imag(), -v.real());
    h /= abs(h);
    h *= sqrt(1 - norm(v / 2.));
    P c = p + (v / 2.) + h;
    return c;
}
 
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
 
    int n;
    while (cin >> n, n) {
        vector<P> p(n);
        rep(i, n) p[i] = readP();
 
        int ans = 1;
        rep(i, n) {
            rep2(j, i + 1, n) {
                if (i == j) continue;
                if (norm(p[i] - p[j]) > 4. + EPS) continue;
                rep(s, 2) {
                    P c = (s ? center(p[i], p[j]) : center(p[j], p[i]));
                    int cnt = 2;
                    rep(k, n) {
                        if (k == i || k == j) continue;
                        if (norm(p[k] - c) < 1. + EPS) {
                            cnt++;
                        }
                    }
                    ans = max(ans, cnt);
                }
            }
        }
 
        cout << ans << endl;
    }
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
char s[N];
int a[N],b[N];
int main()
{
    int n;
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++)
        a[i]=a[i-1]+(s[i]=='#');
    for(int i=n;i>=1;i--)
        b[i]=b[i+1]+(s[i]=='.');
    int ans=1<<30;
    for(int i=1;i<=n+1;i++)
        ans=min(ans,a[i-1]+b[i]);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2048
import numpy as N;p=print;n=int(input());c=int(N.sqrt(n*2))
if c**2+c-n*2:p('No')
else:a=N.zeros((c+1,c));t=N.triu_indices(c);a[t]=a[1:].T[t]=N.arange(n)+1;p('Yes');p(c+1);[p(c,*map(int,r))for r in a]

Measured memory_bytes: 18464
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		String S=sc.next();
		String T=sc.next();
		char a[]=S.toCharArray();
		char b[]=T.toCharArray();
		int ans=0;
		for(int i=0;i<3;i++) {
			if(a[i]==b[i])ans++;
			
		}
		p(ans);
		
		
		
		
		
		
		}
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 22612
#include <stdio.h>
int main(void)
{
	int n,x,i=1;
	scanf("%d",&n);
	do{
		x=i;
		if(x%3==0) printf(" %d",i);
		else{
			do{
				if(x%10==3){printf(" %d",i);break;}
				else x/=10;
			}while(x>0);
		}
	}while(++i<=n);
	puts("");
    return 0;
}

Measured memory_bytes: 608
#include <iostream>

int main()
{
    int x, n, t;
    std::cin >> n >> x >> t;
    const auto div = n / x;
    const auto mod = n % x;
    const auto ans = (div + (mod > 0 ? 1 : 0)) * t;
    std::cout << ans;
    return 0;
}

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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;

int a[N];

ll call(int left, int right) {
	if(left == right) return 0;
	int mid = (left + right) >> 1;
	std::vector<int> v;
	for(int i = left; i <= mid; i++) {
        v.push_back(a[i] + i);
	}
	sort(all(v));
	ll ans = 0;
	for(int i = mid + 1; i <= right; i++) {
		int cur = i - a[i];
		ans += upper_bound(all(v), cur) - lower_bound(all(v), cur);
	}
	return ans + call(left, mid) + call(mid + 1 , right);
}

int solve() {
    int n; Int(n);
    for(int i = 1; i <= n; i++) {
    	Int(a[i]);
    }
    printf("%lld\n", call(1, n));
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


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

int main(){
  int n, i, j;
  cin >> n;
  vector<int> L(n);
  rep(p, n) cin >> L[p];
  sort(L.begin(), L.end());
  //int s = n*(n-1)/2;
  //vector<int> T(s);
  int sum = 0;
  /*for(i=0; i<n-1; i++){
    for(j=i+1; j<n){
      T[ch] = L[i]+L[j];
      ch++;
    }
  }*/
  //sort(T.begin(), T.end());
  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      int p = L[i] + L[j];
      auto itr1 = lower_bound(L.begin(), L.end(), p);
      itr1 += -1;
      auto itr2 = L.begin()+j;
      sum += distance(itr2, itr1);
      //cout << sum << endl;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)
S = H.times.map { gets.chomp }
# 下右上左...の順
di = [1,  0, -1,  0,  1, -1, -1,  1]
dj = [0,  1,  0, -1,  1,  1, -1, -1]

H.times do |i|
  W.times do |j|
    # 爆弾はパス
    next if S[i][j] == '#'

    # 周囲のマスをチェック
    bomb = 0
    8.times do |k|
      # 調査対象の座標
      ni = i + di[k]
      nj = j + dj[k]

      # 調査対象の範囲外チェック
      next if ni < 0 or H <= ni
      next if nj < 0 or W <= nj

      # 調査対象が爆弾ならカウント
      bomb += 1 if S[ni][nj] == '#'
    end
    S[i][j] = bomb.to_s
  end
  puts S[i]
end

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(R);
  string ans;
  if (R < 1200) ans = "ABC";
  else if (R < 2800) ans = "ARC";
  else ans = "AGC";
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> ans(n,0);
  for(long long int i=1; i<=n; i++){
    if(i*i+i+i>n){
      break;
    }
    for(long long int j=i; j<=n; j++){
      if(i*i+j*j+i*j+j+i>n){
        break;
      }
      for(long long int k=j; k<=n; k++){
        if(i*i+j*j+k*k+i*j+j*k+k*i>n){
          break;
        }else{
          if(i==j&&j==k){
            ans.at(i*i+j*j+k*k+i*j+j*k+k*i-1)++;
          }else if(i==j||j==k||k==i){
            ans.at(i*i+j*j+k*k+i*j+j*k+k*i-1)+=3;
          }else{
            ans.at(i*i+j*j+k*k+i*j+j*k+k*i-1)+=6;
          }
        }
      }
    }
  }
  for(long long int i=0; i<n; i++){
    cout<<ans.at(i)<<endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


	int parent[200005];
	int sz[200005];

	void make_set(int n)
	{
		for(int i = 0; i <= n; i++)
		{
			parent[i] = i;
			sz[i] = 1;
		}
	}

	int getParent(int x)
	{
		if(x == parent[x])
			return x;
		return parent[x] = getParent(parent[x]);
	}

	void merge(int u, int v)
	{
		u = getParent(u);
		v = getParent(v);
		if(u == v)return;
		sz[u] += sz[v];
		sz[v] = sz[u];
		parent[v] = u;
		return;
	}

int32_t main()
{


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



    int n,m;
    cin >> n >> m;


    make_set(n+1);

    for(int i =1; i <= m; i++)
    {
    	int x,y;
    	cin >> x >> y;
    	merge(x,y);

    }

    int ans = 1;

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

    	int p = getParent(i);
    	//trace3(i,p,sz[p]);
    	ans = max(ans,sz[p]);
    }

    cout << ans;

    return 0;
}


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (min(A,B) < C && C < max(A,B)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int P[1000000];

signed main()
{
	cin >> N;
	REP(i, N) cin >> P[i];

	int ans = 1;
	int min = P[0];
	for (int i = 1; i < N; i++)
	{
		if (P[i] <= min)
		{
			ans++;
			min = P[i];
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10;
struct node{int x,y;}a[N];
int n,t,x,y,ta,tb,b[N],f[N],ans;
bool cmp(node a,node b){return a.x*(b.y+1)>b.x*(a.y+1);}
signed main()
{
	scanf("%lld%lld",&n,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if(x)a[++ta]={x,y};
		else b[++tb]=y+1;
	}
	sort(a+1,a+ta+1,cmp);
	sort(b+1,b+tb+1);
	for(int i=1;i<=30;i++)f[i]=t+1;
	for(int i=1;i<=ta;i++)
		for(int j=30;j>=1;j--)
			f[j]=min(f[j],(f[j-1]+1)*(a[i].x+1)+a[i].y);
	for(int i=1;i<=tb;i++)b[i]+=b[i-1];
	for(int i=0;i<=30;i++)
	{
		if(f[i]>t)continue;
		if(tb)x=upper_bound(b+1,b+tb+1,t-f[i])-(b+1);
		else x=0;
		ans=max(ans,i+x);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6828
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, c;
char t[105];

int main() {
scanf("%d", &n);
scanf("%s", t);
c = 0;
for (int i=0;i<n;i++) if (t[i] == 'R') c++;
if (c > n - c) printf("Yes\n"); else printf("No\n");
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  string S;
  int m;
  while(true) {
    cin >> S;
    if(S == "-") break;
    cin >> m;
    for(int i = 0; i < m; i++) {
      int h;
      cin >> h;
      string temp = S.substr(0, h);
      S.erase(0, h);
      S = S + temp;
    }
    cout << S << endl;
  }

  return 0;
}


Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){

  int a[5] = {};
  int d,e,f,g;
  bool c = true;

  d = e = f = g = 0;

  while(cin >> a[0] >> a[1] >> a[2]){
    sort(a,a+3);
    if(a[2] < a[0] + a[1] && c == true){
      d++;

      if(a[2]*a[2] == a[1]*a[1]+a[0]*a[0]) e++;
      else if(a[2]*a[2] < a[1]*a[1]+a[0]*a[0]) f++;
      else g++;
    }

    else if(c == true){
      printf("%d %d %d %d\n",d,e,f,g);
      c = false;
    }
 
  }
}

Measured memory_bytes: 1160
from collections import defaultdict

H, W, M = map(int, input().split())
h = [0] * M
w = [0] * M

nh = [0] * H  # number of h == i+1
nw = [0] * W  # number of w == i+1
dic = defaultdict(bool)

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1
    dic["{}-{}".format(h[i],w[i])] = True

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

for h1 in mh:
    for w1 in mw:
        if not dic["{}-{}".format(h1,w1)]:
            print(mnh + mnw)
            exit()
print(mnh + mnw - 1)

Measured memory_bytes: 90680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int M=1000000,N=1010000;

int n,cnt[N],x;
ll f[N],ans;
int main() {
    scanf("%d",&n);
    rep(i,0,n) scanf("%d",&x),cnt[x]++;
    rep(i,1,M+1) f[i]=powmod(i,mod-2);
    int pp=f[2]; 
    rep(i,1,M+1) {
        f[i]%=mod; if (f[i]<0) f[i]+=mod;
        for (int j=i+i;j<=M;j+=i) {
            f[j]=f[j]-f[i];
        }
    }
    for (int i=1;i<=M;i++) {
        ll pc=0;
        ll ps=0; 
        for (int j=i;j<=M;j+=i) {
            pc=(pc+(ll)cnt[j]*j)%mod;
            ps=(ps+(ll)cnt[j]*j*j)%mod; 
        }
        ans=(ans+((pc*pc%mod-ps)*pp%mod)*f[i])%mod;
    }
    // rep(i,1,M+1) ans=(ans-(ll)cnt[i]*i)%mod;
    // ans=ans*(mod+1)/2%mod;
    if (ans<0) ans+=mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 12032
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

/* this is port of top c++ answer to test go performance */
func main() {
	n, m := in.Int(), in.Int()
	a, b := in.ArrayIntx(n, n+1), in.ArrayIntx(m, m+1)
	a.SortR()
	b.SortR()
	ans, c := 1, 0
	for i, j, k := n*m, 0, 0; i > 0; i-- {
		if a[j] == i && b[k] == i {
			c += j + k
			j++
			k++
		} else if a[j] == i {
			ans = ans * k % M7
			c += k - 1
			j++
		} else if b[k] == i {
			ans = ans * j % M7
			c += j - 1
			k++
		} else {
			ans = ans * c % M7
			c--
		}
	}
	Pln(ans)
}

const M7 = 1000000007

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayIntx(n, m int) IntSlice {
	r := make(IntSlice, m)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}

type ByteSlice []byte
type IntSlice []int

func (p IntSlice) Len() int           { return len(p) }
func (p IntSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p IntSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
func (p IntSlice) SortR()             { sort.Sort(sort.Reverse(p)) }


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

int  main()
{
	long int a, b, k;
	scanf("%ld %ld %ld", &a,&b, &k);

	if (k <= a)
	{
		a = a - k;
		printf("%ld %ld\n", a, b);
	}

	else
	{
		k = k - a;
		a = 0;
		b = b - k;

		if (b < 0)
		{
			b = 0;
		}

		printf("%ld %ld\n", a, b);
	}

	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    int ans=n/500*1000;
    int left=n%500;
    ans+=(left/5*5);
    cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200000
int main() {
	int num,i,count,nowNum;
	int a[N];
	int flag=0;
	scanf("%d",&num);
	for(i=0;i<num;i++) {
		scanf("%d ",&a[i]);
	}
	
	for(i=0;i<num;i++) {
		if(a[i]==1) {
			flag=1;
			break;
		}
	}
	
	if(flag==0) {
		printf("-1");
		return 0;
	}
	count=0;
	nowNum=1;
	for(i=0;i<num;i++) {
		if(a[i]==nowNum) {
			nowNum++;
		} else {
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 896
/* 134b */
#include<stdio.h>
#include<math.h>
int main(void)
{
  int n,b,r,a;
  scanf("%d %d",&n,&r);
  b=n%(2*r+1);
  a=(n-b)/(2*r+1);
  if(b>0){
    a=a+1;
  }
  printf("%d\n",a);
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();
	var d = new Tuple<int, int>[n];
	for (int i = 0; i < n; i++)
	    d[i] = Tuple.Create(a[i], i+1);
	Array.Sort(d);

	for (int i = 0; i < n; i++)
	{
	    var t = d[i];
	    Write(t.Item2);
	    if (i < n-1) Write(" ");
	}
	WriteLine("");
    }
}


Measured memory_bytes: 29180
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN * 3];
ll l[MAXN * 3], r[MAXN * 3];
priority_queue<int> h2;
priority_queue<int, vector<int>, greater<int> > h;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,3*n) cin >> a[i];
    ll s = 0;
    FOR(i,1,n) {
        h.push(a[i]);
        s += a[i];
    }
    l[n] = s;
    FOR(i,n+1,2*n) {
        h.push(a[i]);
        s += a[i];
        int g = h.top(); h.pop();
        s -= g;
        l[i] = s;
    }
    s = 0;
    FORE(i,3*n,2*n+1) {
        h2.push(a[i]);
        s += a[i];
    }
    r[2*n+1] = s;
    FORE(i,2*n,n+1) {
        h2.push(a[i]);
        s += a[i];
        int g = h2.top(); h2.pop();
        s -= g;
        r[i] = s;
    }
    // FOR(i,1,3*n) cout << l[i] << ' ';
    // cout << endl;
    // FOR(i,1,3*n) cout << r[i] << ' ';
    // cout << endl;
    ll res = -1e18;
    FOR(i,n,2*n) res = max(res, l[i] - r[i+1]);
    cout << res;
    return 0;
}

Measured memory_bytes: 5240
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		int[] a = new int[n];
		
		for(int i = 0 ; i < n ; i++){
			
			a[i] = scan.nextInt() - 1;
			
		}
		
		int cnt = 0;
		
		for(int i = 0 ; i < n ; i++){
			
			if(a[i] == -1){
				
			} else if(a[a[i]] == i){
				
				cnt++;
				a[a[i]] = -1;
				
			}
			
		}
		
		System.out.println(cnt);
		
	}
}


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

int main(){
    int n; cin >> n;
    int odd_counter = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a % 2 == 1) odd_counter++;
    }
    if(odd_counter % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m, r;
int d[210][210];


void init(int n){
   rep(i, 0, n){
       rep(j, 0, n){
           d[i][j] = INF;
           if(i == j) d[i][j] = 0;
       }
   }
}

void warshall_floyd(){
   rep(k, 0, n){
       rep(i, 0, n){
           rep(j, 0, n){
               d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
           }
       }
   }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> r;
    vector<int> p(r);
    rep(i, 0, r){
        cin >> p[i]; p[i]--;
    }
    init(n);
    rep(i, 0, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd();
    int MIN = INF;
    sort(all(p));
    do{
        int tmp = 0;
        rep(i, 1, r){
            tmp += d[p[i - 1]][p[i]];
        }
        // for(int ii = 0; ii < p.size(); ii++){
        //     if(ii) cout << ' ';
        //     cout << p[ii];
        // }
        // cout << endl;
        chmin(MIN, tmp);
    }while(next_permutation(all(p)));
    cout << MIN << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vecint v(n);
  REP(i,n) {
    cin>>v[i];
  }
  int old = -1;
  int length = 0;
  int cnt = 0;
  REP(i,n) {
    if (v[i] == old) {
      ++length;
    } else {
      old = v[i];
      cnt += length / 2;
      length = 1;
    }
  }
  cnt += length / 2;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
t,x,y = map(int , input().split())
if x+y>t or (x+y+t)%2 !=0:
	print('No')
	exit()
for i in range(n-1):
	t_i,x_i,y_i = map(int , input().split())
	e=abs(x-x_i)+abs(y-y_i)-t_i-t
	if e>0  or e%2 !=0:
		print('No')
		exit()
	x=x_i
	y=y_i
	t=t_i
print('Yes')

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int c[3][3];
    rep(i,0,3)rep(j,0,3) cin >> c[i][j];
    int a[3],b[3];
    bool ok = true;
    rep(i,0,3) b[i] = c[0][i];
    rep(j,1,3){
        int tmp = c[j][0]-b[0];
        rep(i,1,3){
            if(tmp != c[j][i]-b[i]) ok = false;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int mat[1001];
int main()
{
  int n,m;
  char ch;
  cin >> n >> m;
  mat[1]=1;
  for(int i=0; i<n; i++) {
    for(int j=1; j<=m; j++) {
      cin >> ch;
      if(ch=='.') {
        mat[j]+=mat[j-1];
        mat[j]-=1000000007*(mat[j]>=1000000007);
      }
      else
        mat[j]=0;
    }
  }
  cout << mat[m];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;

int main()
{
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 int l,d,r;
 cin>>l>>r>>d;
 if (l%d==0)
 {
 cout<<(r/d-l/d+1);
 }
 else
 cout<<r/d-l/d;


}


Measured memory_bytes: 3656
import numpy as np
n, m = map(int,input().split())

ks = np.array([list(map(int,input().split()[1:])) for _ in range(m)])

ss = np.array(list(map(int,input().split())))

def ans(n):
    return(b1(n,np.zeros(m))+b0(n,np.zeros(m)))

def b0(n,t):
    global ss
    if n == 0:
        return 0
    return b0(n-1,t)+b1(n-1,t)

def b1(n,t):
    global ks
    global ss
    t = t + np.array([int(n in k) for k in ks])
    if n == 0:
        return all([i%2==s for i,s in zip(t,ss)])
    return b0(n-1,t)+b1(n-1,t)

print(ans(n))

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

public class Main {
    public static int matches(boolean[][] compatible){
        int[] dp = new int[1<<compatible.length];
        dp[0] = 1;

        for (int mask = 0; mask < (1 << compatible.length) - 1; mask++) {
            int i = Integer.bitCount(mask);
            for (int j = 0; j < compatible.length; j++) {
                int setCheck = mask & (1 << j);
                if(compatible[i][j] && (setCheck == 0)){
                    int high = mask ^ (1 << j);
                    dp[high] += dp[mask];
                    if (dp[high] > mod){
                        dp[high] -= mod;
                    }
                }
            }
        }
        return dp[dp.length - 1];
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        boolean[][] compat = new boolean[N][N];
        for (int i = 0; i < N; i++) {
            StringTokenizer st = new StringTokenizer(reader.readLine());
            for (int j = 0; j < N; j++) {
                int t = Integer.parseInt(st.nextToken());
                if (t == 0){
                    compat[i][j] = false;
                }else {
                    compat[i][j] = true;
                }
            }
        }
        System.out.println(matches(compat));
    }
    private static int mod = (int) (1e9+7);
}


Measured memory_bytes: 29908
#include<stdio.h>

int main(void)
{
	int i,k, n;

	scanf("%d", &n);

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


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

// 素因数分解
template <typename T>
map<T, T> prime_factor(T n)
{
  map<T, T> ret;
  for (T i = 2; i * i <= n; i++)
  {
    T tmp = 0;
    while (n % i == 0)
    {
      tmp++;
      n /= i;
    }
    ret[i] = tmp;
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}
template <typename T>
struct PrimeFact
{
  vector<T> spf;
  PrimeFact(T N) { init(N); }
  void init(T N)
  { // 前処理。spf を求める
    spf.assign(N + 1, 0);
    for (T i = 0; i <= N; i++)
      spf[i] = i;
    for (T i = 2; i * i <= N; i++)
    {
      if (spf[i] == i)
      {
        for (T j = i * i; j <= N; j += i)
        {
          if (spf[j] == j)
          {
            spf[j] = i;
          }
        }
      }
    }
  }
  map<T, T> get(T n)
  { // nの素因数分解を求める
    map<T, T> m;
    while (n != 1)
    {
      m[spf[n]]++;
      n /= spf[n];
    }
    return m;
  }
};
/*  divisor_num(n)
    入力：整数 n
    出力：nの約数の個数
    計算量：O(√n)
*/
PrimeFact<long long> pff(10101010);
template <typename T>
T divisor_num(T N)
{
  map<T, T> pf = pff.get(N);
  T ret = 1;
  for (auto p : pf)
  {
    ret *= (p.second + 1);
  }
  return ret;
}

long long N;

int main()
{
  cin >> N;
  pff.init(N);
  long long ans = 0;
  for (long long i = 1; i <= N; ++i)
  {
    ans += i * divisor_num(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81968