akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    ll n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P pair <int,int>

int N;
const int MAXN = 105;
P A[MAXN],B[MAXN];
bool f[MAXN];
int ans;
bool mycmp(P a,P b){
	return a.first<b.first;
}

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d%d",&A[i].first,&A[i].second);	
	for(int i=0;i<N;i++) scanf("%d%d",&B[i].first,&B[i].second);

	sort(A,A+N,mycmp);
	sort(B,B+N,mycmp);

	for(int i=0;i<N;i++){
		int maxx = 0;int t = 1000;
		for(int j=0;j<N;j++){
			if(A[j].first>B[i].first) break;
			if(f[j]==0 & A[j].second<B[i].second){
				if(A[j].second>=maxx){
				 	maxx = A[j].second;
					t=j;
				}	
			}
			
		}
		if(t!=1000){
			f[t]=1;
			ans++;
		}
	}

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

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int arr[5];
	int ans = -1;
	for(int z=0;z<5;z++){
		scanf("%d",&arr[z]);
	}

	for(int i=0;i<5;i++){
		if(arr[i]==0){
			ans = i+1;
		}
	}

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

	
	
}

Measured memory_bytes: 1732
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

char a[60][60];
char b[60][60];

int main(void) {
  int n, m;
  scanf("%d %d ", &n, &m);
  REP(i, n)
    scanf("%s", a[i]);
  REP(i, m)
    scanf("%s", b[i]);
  REP(i, n-m+1) REP(j, n-m+1) {
    bool ok = true;
    REP(ii, m) REP(jj, m) {
      if (a[i+ii][j+jj] != b[ii][jj]) {
        ok = false;
      }
    }
    if (ok) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
   
  return 0;
}


Measured memory_bytes: 256
N=int(input())
i=0
while i<N:
    a,b,c=map(int,input().split())
    if a>b:
        a,b=b,a
    if b>c:
        b,c=c,b
    if a>b:
        a,b=b,a
    if a**2+b**2==c**2:
        print('YES')
    else:
        print('NO')
    i+=1
        


Measured memory_bytes: 5596
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    ll ans = (x / 500) * 1000;
    x %= 500;
    cout << ans + (x / 5) * 5;
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    counter = Counter()
    for _ in range(N):
        K, *A = map(int, input().split())
        counter += Counter(A)
    print(sum(1 for c in counter.values() if c == N))

main()


Measured memory_bytes: 63980
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ns <- replicateM n readLn
  print $ length $ filter isPrime ns
    where
      isPrime n = all ((/=0).mod n) (primes' n)
      primes' n = takeWhile ((<=n).(^2)) primes
      primes = 2 : filter isPrime [3..]

Measured memory_bytes: 7732
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input(A) for(auto &i:A) cin>>i;
void solve()
{
    ll n,d,a,b,ans = 0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        long double dis = sqrt(a*a + b*b);
        // cout<<dis<<" ";
        if(dis<=d){
            ans++;
        }
    }
    cout<<ans<<'\n';
}
signed main()
{
    fasino
    int testcase=1;
    // cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>

int main(void){
        int i,x,num;
        scanf("%d",&num);
        for(i=1;i<=num;i++){
                x=i;
                while(x>0){
                        if(x%10==3)break;
                        x/=10;
                }
                if(i%3==0 || x%10==3){
                        printf(" %d",i);
                }
        }

        printf("\n");
        return 0;
}


Measured memory_bytes: 2100
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        long ans = 0;
        if(M-2*N >= 0){
            ans += N;
            ans += (M-2*N)/4;
        }else{
            ans += M/2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    r = ''.join(map(lambda x: x[0], LS())).upper()

    return r

print(main())


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

using ll = long long;
using pii = pair<int, int>;

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }
 



int main(int argc, char** argv) {
    fast_io
   
	int a, b;
	while(cin >> a >> b && (a || b)) {
	    
	    for(int i = 0; i < b; ++i) cout << '#';
	    cout << endl;
	    for(int j = 1; j < a-1; ++j) {
	        cout << '#';
    	    for(int i = 1; i < b-1; ++i) cout << '.';
    	    cout << '#' << endl;
	    }
	    
	    for(int i = 0; i < b; ++i) cout << '#';
	    cout << endl << endl;
	}
	

    return 0;
}























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

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int>> dp(N + 1, vector<int>(3));
    for (int i = 1; i <= N; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i - 1];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i - 1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i - 1];
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]});
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int dp[10000+1];

int main(){
  int h,n;
  cin>>h>>n;
  int a[n], b[n];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
  for(int i=0;i<10000+1;i++) dp[i] = 1000000000;

  for(int i=0; i<=h; i++){
    for(int j=0; j<n; j++){
      if(i-a[j]>0)
        dp[i] = min(dp[i], dp[i-a[j]] + b[j]);
      else
        dp[i] = min(dp[i], b[j]);
    }
  }

  cout << dp[h] << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int n;

void dfs(string s, char ma) {
	if (sz(s) == n) {
		out(s);
		return;
	}
	for (char c = 'a'; c <= ma; c++) {
		dfs(s + c, c == ma ? ma + 1 : ma);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	cin >> n;

	dfs("", 'a');

	return 0;
}

Measured memory_bytes: 1536
fn main() {
    let _ = read::<usize>();
    let v = read_vec::<usize>();

    for a in v.iter() {
        if a % 2 != 0 {
            continue;
        }

        if a % 3 == 0 || a % 5 == 0 {
            continue;
        } else {
            println!("DENIED");
            return;
        }
    }
    println!("APPROVED");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  //int i = 0;
  cin >> n;
  
  	if ((n[0] == n[1] && n[1] == n[2])
        || (n[1] == n[2] && n[2] == n[3])) {
  		cout << "Yes" << endl;
  	} else {
  		cout << "No" << endl;
  	}
}

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


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    solved = [False]*N
    WAs = [0]*N
    WA = 0
    for i in range(M):
        if not solved[p[i]-1]:
            if S[i] == "WA":
                WAs[p[i]-1] += 1
            else:
                solved[p[i]-1] = True
    penalty = 0
    ACs = 0
    for i in range(N):
        if solved[i]:
            ACs += 1
            penalty += WAs[i]
    print(ACs, penalty)
    return


# 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()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14876
#!/snap/bin/pypy3
def gcd(a, b):
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def main():
    N = int(input())
    nums = list(map(int, input().split()))

    L = [0 for _ in range(N + 1)]
    R = [0 for _ in range(N + 1)]

    for i, num in enumerate(nums):
        L[i + 1] = gcd(L[i], num)

    for i in range(N - 2, -1, -1):
        R[i] = gcd(R[i + 1], nums[i + 1])

    print(max(gcd(L[i], R[i]) for i in range(N)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65124
#include<stdio.h>

int main(int argc, char const* argv[])
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a < b && b < c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2104
import scala.annotation.tailrec

object Main extends App {
  import scala.io.StdIn._
  solve
  @tailrec def solve: Unit = {
    val Array(n, l, r) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0) return
    val t = Array.tabulate(n){_ ⇒ readLine.trim.toInt}
    val default = if (n % 2 == 0) true else false
    val memo = Array.tabulate(r - l + 1){_ ⇒ Int.MaxValue}
    for ((a, i) ← t.zipWithIndex) {
      for (year ← memo.indices){
        if ((year + l) % a == 0 && memo(year) > i) memo(year) = i
      }
    }
    println(
      memo.count{ minI ⇒ if (minI == Int.MaxValue) default else minI % 2 == 0}
    )
    solve
  }
}



Measured memory_bytes: 48500
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> ch(26);
  rep(i, n) {
    int c = s[i] - 'a';
    ch[c].insert(i);
  }
  int q;
  cin >> q;
  rep(qi, q) {
    int type;
    cin >> type;
    if (type == 1) {
      int i;
      char c;
      cin >> i >> c;
      --i;
      int pre = s[i] - 'a';
      ch[pre].erase(i);
      s[i] = c;
      
      int next = c - 'a';
      ch[next].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l; --r;
      int ans = 0;
      rep(i, 26) {
        auto p = ch[i].lower_bound(l);
        if(p != ch[i].end() && *p <= r) ans++;
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 24324
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define pb              push_back
#define mp              make_pair
#define scan(a, n) 		for(int i = 0; i < n;i++)cin >> a[i];
#define print(a, n) 	for(int i = 0; i < n;i++)cout << a[i] <<' ';cout<<endl;
#define w(x)            int x; cin>>x; while(x--)
#define ms(s, n) 		memset(s, n, sizeof(s))
#define sz(a) 			int((a).size())
#define endl 			'\n'
const int MOD = 		(int) 1e9 + 7;
#define all(v) 			v.begin(),v.end()
#define Sort(v) 		sort(v.begin(), v.end())
#define vi 				vector<int>
#define vs 				vector<string>
#define db(...) 		__f(#__VA_ARGS__, __VA_ARGS__)
#define rep(i, n) 		for (int (i) = 0; (i) < (int)(n); ++(i))
#define prefixsum(a,b)	partial_sum(all(a),b.begin())

 
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
 
template <typename T, typename U> 
inline void chkmax(T& x, U y) {
	if (x < y) x = y;
}
  
template <typename T, typename U>
inline void chkmin(T& x, U y) {
	if (y < x) x = y;
}

void code()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("/home/tushar/Desktop/input.txt", "r", stdin);
    freopen("/home/tushar/Desktop/output.txt", "w", stdout);
#endif
}
// template end here


void solve() 
{
	int i, j, k, q ,n, m, ans = 0, cnt = 0, sum = 0,input;
	cin>>k;
	int a,b;
	cin>>a>>b;

	ans= (a/k)*k;
	// cout<<"a/k: "<<ans<<endl;
	if(ans==a)cout<<"OK"<<endl;
	else
	{
		ans+=k;
		// cout<<ans<<endl;
		if(ans<=b)cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
	}
}
 
int32_t main()
{
    // code();
    solve();
    return 0;
}




Measured memory_bytes: 3588
import itertools as it
import numpy as np
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

rosen = list(it.permutations(range(1, N+1)))

isP = 0
isQ = 0

for i in range (0, len(rosen)):
    if list(rosen[i]) == P:
        isP = i+1
    if list(rosen[i]) == Q:
        isQ = i+1

print(abs(isP-isQ))

Measured memory_bytes: 31804
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char* argv[]) {
  int N, count, min;
  cin >> N;
  vector<int> p(N);

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

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

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		int n = Integer.parseInt(std.next());
		int array[] = new int[n];

		for (int i=0; i<n; i++){
			array[i] = Integer.parseInt(std.next());
		}
		String outsd = "";
		for (int i=1; i<n; i++){
			outsd = Integer.toString(array[0]);
			for(int id=1; id<n; id++){
				outsd += (" "+array[id]);
			}
			System.out.println(outsd);

			int v = array[i];
			int j = i-1;
			while (j>=0 && array[j] > v){
				array[j+1] = array[j];
				j--;
			}
			array[j+1] = v;
		}
		outsd = Integer.toString(array[0]);
		for(int id=1; id<n; id++){
			outsd += (" "+array[id]);
		}
		System.out.println(outsd);
	}
}

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

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

    stack<int> st;
    vector<bool> check;
    for(int i=0;i<=100;i++){
        check.push_back(false);
    }

    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        //stackから取り出して判定
        if(x<0){
            //空じゃなかったら
            if(!st.empty()){
                int top = st.top();
                //topと値が一緒かどうかの判定
                if(top!=abs(x)){
                    cout << i+1 << endl;
                    return 0;
                }else{
                    st.pop();
                    check[abs(x)] = false;
                }
            }else{
                cout << i+1 << endl;
                return 0;
            }
        }else{
            //穴にはいる
            st.push(x);
            if(check[x]){
                cout << i+1 << endl;
                return 0;
            }
            check[x] = true;
        }
    }

    cout << "OK" << endl;
    return 0;
}


Measured memory_bytes: 3156
import java.io.*;
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    if(u.equals(s))
      a--;
    else
      b--;
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 23124
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=1111;
const int maxm=200111;

bitset<maxn> con[maxn];
vector<int> g[maxn];
int n,m,eu[maxm],ev[maxm],piv;
bool can[maxn][maxn],can2[maxn][maxn];

bitset<maxn> use;
void dfs(int x,int tmp=1)
{
	can[piv][x]=1;
	can2[piv][x]|=tmp;
	use.set(x);
	while(true)
	{
		int cur=(con[x]&~use)._Find_first();
		if(cur>=1&&cur<=n)dfs(cur);
		else break;
	}
}

void solve(int x)
{
	piv=x;
	use.reset();use.set(x);
	for(int i=0;i<(int)g[x].size();i++)if(!use[g[x][i]])dfs(g[x][i],0);
	use.reset();use.set(x);
	for(int i=(int)g[x].size()-1;i>=0;i--)if(!use[g[x][i]])dfs(g[x][i],0);
}

int main()
{
	get2(n,m);
	for(int i=1;i<=m;i++)
	{
		get2(eu[i],ev[i]);
		g[eu[i]].pb(ev[i]);
		con[eu[i]].set(ev[i]);
	}
	
	for(int i=1;i<=n;i++)solve(i);
	
	for(int i=1;i<=m;i++)if(can[ev[i]][eu[i]]^can2[eu[i]][ev[i]])puts("diff");else puts("same");
	return 0;
}

Measured memory_bytes: 6912
use std::cmp::{max, min};

fn main() {
  let (a, b, c) = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let a: i64 = ws.next().unwrap().parse().unwrap();
    let b: i64 = ws.next().unwrap().parse().unwrap();
    let c: i64 = ws.next().unwrap().parse().unwrap();
    (a, b, c)
  };

  print!("{}", c - (min(a, b + c) - b));
}


Measured memory_bytes: 4352
// 

// g++ -std=c++11 abc145_c.cc && ./a.out 
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int A, B, M, i, x, y, c;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);


    int a_min = 1000000;
    int b_min = 1000000;

    rep(i, A) {
        int tmp;
        cin >> tmp;
        a[i] = tmp;
        if (tmp < a_min) {
            a_min = tmp;
        }
    }
    rep(i, B) {
        int tmp;
        cin >> tmp;
        b[i] = tmp;
        if (tmp < b_min) {
            b_min = tmp;
        }
    }

    int total_val = 1000000;
    rep(i, M) {
        cin >> x >> y >> c;
        x--;
        y--;
    
        int tmp_val = a[x] + b[y] - c;
        if (tmp_val < total_val) {
            total_val = tmp_val;
        }
    }

    if (a_min + b_min < total_val) {
        total_val = a_min + b_min;
    }

    cout << total_val << endl;
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llnrm=LLONG_MAX;
const int nrm=INT_MAX;
const int nrn=INT_MIN;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int a,b,ans;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>a>>b;
    cout<<2*b-a<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 1073741823;
const ll LINF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll power(ll x, ll y) {
	if (y==0) return 1;
	else if (y==1) return x%MOD;
	else if (y%2==0) { ll pow=power(x,y/2); return (pow*pow)%MOD; } 
	else { ll pow=power(x,y/2); return ((pow*pow)%MOD)*x%MOD; }
}
ll divid(ll x, ll y) {
	return ((x%MOD)*power(y,MOD-2))%MOD;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
	COMinit();
	int n, m, k; cin >> n >> m >> k;
	ll ans=1;
	REP(i,n){
		ans*=m;
		ans%=MOD;
	}
	ll col=m;
	REP(i,n-1-k){
		ll p=COM(n-1,i);
		p*=col; p%=MOD;
		col*=m-1; col%=MOD;
		ans=(ans-p+MOD)%MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll x,a;cin>>x>>a;
	if(x<a)cout<<0;
	else cout<<10;
	
	return 0;
}



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

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

  if (n==1){
    cout << p << endl;
    return 0;
  }

  vector<ll> v(1e6+1,0);
  v[1] = n;
  for (ll i = 2; i*i <= p; i++){
    while(p%i == 0){
      v[i]++;
      p /= i;
    }
  }

  ll ans = 1;
  for(ll i = 0; i <= v.size(); i++){
    ans *= powl((i+1),(ll)(v[i+1]/n));
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    int h,w;
    cin >> h >> w;
    char a[h][w] = {};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    
    set<int> x,y;
    for(int i=0; i<h; i++){
        bool clean = true;
        for(int j=0; j<w; j++){
            if(a[i][j] == '#'){
                clean = false;
                break;
            }
        }
        if(clean) x.insert(i);
    }
    for(int j=0; j<w; j++){
        bool clean = true;
        for(int i=0; i<h; i++){
            if(a[i][j] == '#'){
                clean = false;
                break;
            }
        }
        if(clean) y.insert(j);
    }
    int col = w - y.size();
    for(int i=0; i<h; i++){
        int cy = 0;
        for(int j=0; j<w; j++){
            if(x.count(i) == 0 && y.count(j) == 0){
                cy++;
                cout << a[i][j];
                if(cy == col) cout << "\n";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=r.split("\n"),n=t(e[0].split(" ").map(function(r){return Number(r)}),2),o=n[0],u=n[1],i=(Number(e[1]),e[2].split(" ").map(function(r){return Number(r)})),f=[],l=0;l<o;l++){var a=new Array(u).fill(0);f.push(a)}for(var c=0,p=0,s=0;s<o;s++){if(s%2==0)for(j=0;j<u;j++)f[s][j]=c+1,(p+=1)>=i[c]&&(p=0,c+=1);else for(j=u-1;j>=0;j--)f[s][j]=c+1,(p+=1)>=i[c]&&(p=0,c+=1);console.log(f[s].join(" "))}}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 11468
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  vector <int> dp(8000);
  rep(i, 8000) dp[i] = 0;
  int N, T; cin >> N >> T;
  vector<pair <int, int>>AB;
  rep(i, N){
    int a, b; cin >> a >> b;
    AB.push_back(make_pair(a, b));
  }
  sort(AB.begin(), AB.end());
  
  rep(i,  N){
    vector <int> temp;
    copy(dp.begin(), dp.end(), back_inserter(temp));
    rep(t, T){
      dp[t + AB[i].first] = max(temp[t + AB[i].first], temp[t] + AB[i].second);
    }
  }
  int ans = *max_element(dp.begin(), dp.end());
  cout << ans <<endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = 0; i < n; i++)
using namespace std;


int N;
int A[100001];

int main(void) {
  cin >> N;
  REP(i, 1, N + 1) cin >> A[i];

  long c = 0, s = 0;
  REP(i, 1, N + 1) {
    if(A[i] != 0) s += A[i];
    else {
      c += s / 2;
      s = 0;
    }
  }
  c += s / 2;

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val (a,b) = readLine()!!.split(' ').map { s -> s.toInt() }
    var check = false
    for (num in a..b) {
        if (num % k == 0)
            check = true
    }
    println( if (check) "OK" else "NG" )
}

Measured memory_bytes: 36460
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String a = sc.next(), b = sc.next(), c = sc.next();
        System.out.println(a.charAt(0) + "" +  b.charAt(1)  + "" + c.charAt(2));
    }
}

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

const int N = 800;
int n, m, k;
bool used[N][N];
char p[N][N];
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int d[N][N];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	scanf("%d %d %d\n", &n, &m, &k);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
			p[i][j] = getchar();
		getchar();
	}

	queue <pair <int, int> > Q;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			if (p[i][j] == 'S')
				Q.push({i, j}), used[i][j] = true;
	while (!Q.empty())
	{
		int x = Q.front().first, y = Q.front().second;
		Q.pop();
		for (int i = 0; i < 4; ++i)
		{
			int tox = x + dx[i], toy = y + dy[i];
			if (0 <= tox && tox < n && 0 <= toy && toy < m && !used[tox][toy] && p[tox][toy] != '#')
			{
				used[tox][toy] = true;
				d[tox][toy] = d[x][y] + 1;
				Q.push({tox, toy});
			}
		}
	}

	int ans = 1000000000;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (used[i][j] && d[i][j] <= k)
			{
				ans = min(ans, 1 + (i + k - 1)/k);
				ans = min(ans, 1 + (n - 1 - i + k - 1)/k);
				ans = min(ans, 1 + (j + k - 1)/k);
				ans = min(ans, 1 + (m - 1 - j + k - 1)/k);
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}

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

int main(){
  char s[200001];
  scanf("%s",s);
  
  long long ans=0;
  
  int n[200001];
  for(int i=0;i<=200001;i++){
    if(s[i]<='0'){n[i]=0;}
    if(s[i]=='1'){n[i]=1;}
    if(s[i]=='2'){n[i]=2;}
    if(s[i]=='3'){n[i]=3;}
    if(s[i]=='4'){n[i]=4;}
    if(s[i]=='5'){n[i]=5;}
    if(s[i]=='6'){n[i]=6;}
    if(s[i]=='7'){n[i]=7;}
    if(s[i]=='8'){n[i]=8;}
    if(s[i]>='9'){n[i]=9;}
  }
  
  
  for(int i=0;i<=200001;i++){
    ans+=n[i];
  }
  
  if(ans%9==0){printf("Yes");return 0;}else{printf("No");return 0;}
}



Measured memory_bytes: 3012
#include <cstdio>

using namespace std;

int n;
int a[222222];

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

  bool d = false;
  for (int i = 0; i < n; i++) {
    scanf("%d", a+i);
    if (i > 0 && a[i] - a[i-1] > 1) d = true;
  }
  if (a[0] > 0 || d) {
    puts("-1");
    return 0;
  }

  long long res = 0;
  int pre = 0;
  int st = 0;
  for (int i = 1; i < n; i++) {
    if (st == 0 && a[i - 1] + 1 == a[i]) {
      pre = a[i];
    } else {
      res += pre;
      pre = a[i];
    }
    // printf("%d %d %d %lld\n", i, st, pre, res);
  }
  if (pre >= 0) {
    res += pre;
  }

  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

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


void solve(){
  ll N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  rep(i, N){
    cout << S[i] << T[i];
  }
  cout << endl;
}


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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a*b*c == 175){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
vector<vector<int> >g(100001);
int b[100001],w[100001],m=1e9+7,n,x,y;
void rec(int v){
	b[v]=w[v]=1;
	for(int i=0;i<g[v].size();i++){
		if(b[g[v][i]]!=0)continue;
		rec(g[v][i]);
		b[v]*=w[g[v][i]];
		b[v]%=m;
		w[v]*=w[g[v][i]]+b[g[v][i]];
		w[v]%=m;
	}
}
main(){
	cin>>n;n--;
	while(n--){
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	rec(1);
	cout<<(b[1]+w[1])%m;
}


Measured memory_bytes: 11392
import os
import sys

import numpy as np


def solve(inp):
    SEGTREE_TABLES = []

    def bit_length(n):
        ret = 0
        while n:
            n >>= 1
            ret += 1
        return ret

    def segtree_init(n):
        n2 = 1 << bit_length(n)
        SEGTREE_TABLES.append(np.zeros(n2 << 1, dtype=np.int64))
        return len(SEGTREE_TABLES) - 1

    def segtree_build(ins, arr):
        table = SEGTREE_TABLES[ins]
        offset = table.size >> 1
        table[offset:offset + len(arr)] = arr
        for i in range(offset - 1, 0, -1):
            ch = i << 1
            table[i] = max(table[ch], table[ch + 1])

    def segtree_update(ins, i, x):
        table = SEGTREE_TABLES[ins]
        offset = table.size >> 1
        i += offset
        table[i] = x
        while i > 1:
            ch = i
            i >>= 1
            table[i] = max(table[ch], table[ch ^ 1])

    def segtree_query(ins, l, r):
        """ max [l, r) """
        table = SEGTREE_TABLES[ins]
        offset = table.size >> 1
        l += offset
        r += offset
        res = -1
        while l < r:
            if r & 1:
                res = max(res, table[r - 1])
            if l & 1:
                res = max(res, table[l])
                l += 1
            l >>= 1
            r >>= 1
        return res

    def segtree_search(ins, lo, x):
        """
        Get min i where lo <= i, A[i] >= x.
        Assume that a sentinel larger than x is inserted at the right end.
        """
        table = SEGTREE_TABLES[ins]
        offset = table.size >> 1
        i = lo + offset
        while table[i] < x:
            while i & 1:
                i >>= 1
            i += 1
        while i < offset:
            i <<= 1
            if table[i] < x:
                i += 1
        return i - offset

    def segtree_debug_print(ins):
        table = SEGTREE_TABLES[ins]
        offset = table.size >> 1
        i = 1
        while i <= offset:
            print(table[i:2 * i])
            i <<= 1

    n = inp[0]
    q = inp[1]
    aaa = inp[2:n + 2]
    ttt = inp[n + 2::3]
    xxx = inp[n + 3::3]
    yyy = inp[n + 4::3]
    INF = 1 << 60

    aaa = np.append(aaa, INF)
    ins = segtree_init(n + 1)
    segtree_build(ins, aaa)

    ans = []

    for i in range(q):
        if ttt[i] == 1:
            segtree_update(ins, xxx[i] - 1, yyy[i])
        elif ttt[i] == 2:
            res = segtree_query(ins, xxx[i] - 1, yyy[i])
            ans.append(res)
        else:
            res = segtree_search(ins, xxx[i] - 1, yyy[i])
            ans.append(res + 1)

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 53024
#include <iostream>
using namespace std;
int row[4],col[4][4];
int a[4][4];
int main(){
	int i,j,k,n;
	n=3;
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)cin>>a[i][j];
	for(row[1]=0;row[1]<=100;row[1]++){
		col[1][1]=a[1][1]-row[1];
		col[1][2]=a[1][2]-row[1];
		col[1][3]=a[1][3]-row[1];
		for(row[2]=0;row[2]<=100;row[2]++){
			col[2][1]=a[2][1]-row[2];
			col[2][2]=a[2][2]-row[2];
			col[2][3]=a[2][3]-row[2];
			if(col[1][1]!=col[2][1]||col[1][2]!=col[2][2]||col[1][3]!=col[3][3])continue;
			for(row[3]=0;row[3]<=100;row[3]++){
				col[3][1]=a[3][1]-row[3];
				col[3][2]=a[3][2]-row[3];
				col[3][3]=a[3][3]-row[3];
				if(col[1][1]==col[3][1]&&col[1][2]==col[3][2]&&col[1][3]==col[3][3]){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[50][50];
int c,d,b[55][55];
int main(){
    cin>>c>>d;
    for(int i=0;i<c;i++)
    cin>>a[i];
    for(int i=0;i<c;i++)
    for(int j=0;j<d;j++)
    if(a[i][j]=='#')
    b[i][j]++,b[i][j+1]++,b[i][j+2]++,
    b[i+1][j]++,b[i+1][j+1]++,b[i+1][j+2]++,
    b[i+2][j]++,b[i+2][j+1]++,b[i+2][j+2]++;
    for(int i=0;i<c;i++){
        for(int j=0;j<d;j++)
        if(a[i][j]=='#') cout<<'#';
        else cout<<b[i+1][j+1];
        cout<<endl;
    }
	return 0;
}

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

public class Main {
    public static final long MAX = 10000000000l;
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String o = br.readLine();
            String e = br.readLine();
            boolean oFlag = true;
            boolean endFlag = false;
            int oLength = o.length();
            int eLength = e.length();
            int oCount = 0;
            int eCount = 0;
            while (true) {
                if (oFlag) {
                    if (oLength < oCount + 1) {
                        if (endFlag) {
                            break;
                        }
                        endFlag = true;
                        continue;
                    }
                    System.out.print(o.substring(oCount, oCount + 1));
                    oCount++;
                    oFlag = false;
                } else {
                    if (eLength < eCount + 1) {
                        if (endFlag) {
                            break;
                        }
                        endFlag = true;
                        continue;
                    }
                    System.out.print(e.substring(eCount, eCount + 1));
                    eCount++;
                    oFlag = true;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static int digit(long num) {
        return String.valueOf(num).length();
    }
}

Measured memory_bytes: 23124
package main

import (
  ."fmt"
  "strings"
  )

func main()  {
  var a string
  Scan(&a)
  j := strings.Split(a, "")
  first := j[0]
  if j[0] == j[1] && j[1] == j[2] {
    Println("Yes")
  } else if j[1] == j[2] && j[2] == j[3] {
    Println("Yes")
  } else if first == j[1] && first == j[2] && first == j[3] {
    Println("Yes")
  } else {
    Println("No")
  }
}


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

int main() {

  int x,y;
  while(1){
    cin >> x >> y;

    if(x == 0 && y == 0){
      break;
    }    

    if(x < y)
      cout << x << " " << y << endl;
    else
      cout << y << " " << x << endl;
  }
  
}

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

int main() {
    int K, A, B; cin >> K >> A >> B;
    for(int i=K; i<=B; i += K) {
        if(i >= A) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{
	public static void main(String[] args) {
		try(Scanner sc=new Scanner(System.in)){
			while(true) {
				int n=sc.nextInt();
				if(n==0) {break;}
				int[] scores=new int[n];
				for(int i=0;i<scores.length;i++) {
					scores[i]=sc.nextInt();
				}
				double average=0,variance=0;
				
				for(int i=0;i<scores.length;i++) {
					average+=(double)scores[i]/scores.length;
				}
				for(int i=0;i<scores.length;i++) {
					variance+=((double)scores[i]-average)*((double)scores[i]-average)/scores.length;
				}
				System.out.println(Math.sqrt(variance));
			}
		}
	}
}


Measured memory_bytes: 31292
#include<bits/stdc++.h>
using namespace std;
long inf = 1000000007;

int main() {
    int s; cin >> s;
    int a = s / 100;
    int b = s % 100;

    if ((a == 0 || a >= 13) && (b >= 1 && b <= 12)) {
        cout << "YYMM" << endl;
    }
    if ((a >= 1 && a <= 12) && (b == 0 || b >= 13)) {
        cout << "MMYY" << endl;
    }
    if ((a >= 1 && a <= 12) && (b >= 1 && b <= 12)) {
        cout << "AMBIGUOUS" << endl;
    }
    if ((a == 0 || a >= 13) && (b == 0 || b >= 13)) {
        cout << "NA" << endl;
    }
}





Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    A = int(A)
    B = B.split('.')
    B = int(B[0]) * 100 + int(B[1])
    return (A * B) // 100


def main():
    A, B = read_str_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76916
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = (n - 1) * (m - 1);

        // 出力
        System.out.println(result);
    }
}


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

int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] == '1')
      cout << '9';
    else if (s[i] == '9')
      cout << '1';
    else
      cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256