akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int a,b,c;
    while(cin >> a >> b){
        while(1){
            if(a < b){
                c = b % a;
            }
            else if(a > b){
                c = a % b;
            }
            else {
                cout << b << endl;
                break;
            }
            if(c != 0){
                a = b;
                b = c;
            }
            else {
                if(a > b){
                    cout << b << endl;
                    break;
                }
                else {
                    cout << a << endl;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
int N,M;
vector<int> P[100002];
int prt[100002]={};
bool as[100002]={};

void decide_prt(int v,int p)
{
	for(int i=0;i<P[v].size();i++)
	{
		if(prt[P[v][i]]==0){prt[P[v][i]]=p; decide_prt(P[v][i],p);}
	}
	return;
}

int main()
{
 scanf("%d %d",&N,&M);
 for(int i=0;i<M;i++)
 {
	int a,b;
	scanf("%d %d",&a,&b);
	P[a].push_back(b);
	P[b].push_back(a);
 }
 for(int i=1;i<=N;i++)
 {
	if(prt[i]==0){prt[i]=i; decide_prt(i,i);}
 }
 for(int i=1;i<=N;i++)
 {
	as[prt[i]]=true;
 }
 int ans=0;
 for(int i=1;i<=N;i++)
 {
	if(as[i]){ans++;}
 }
 printf("%d",ans-1);
}

Measured memory_bytes: 10664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int f[N], d[N];
int Find(int x) {
    if(f[x] == x) return x;
    int root = Find(f[x]);
    d[x] = d[ f[x] ] + d[x];
    return f[x] = root;
}

int join(int x, int y, int z) {
    int fx = Find(x);
    int fy = Find(y);
    if(fx == fy) return z == d[y] - d[x];
    f[fy] = fx;
    d[fy] = d[x] + z - d[y];
    return 1;
}

int main() {
    int n, m;
    int ok = 1;
    cin >> n >> m;
    for(int i=1; i<=n; ++i) f[i] = i;
    for(int i=1; i<=m; ++i) {
        int x, y, z; cin >> x >> y >> z;
        if(ok) ok = join(x, y, z);
    }
    printf(ok ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int>> adj(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b), --a, --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<int> dist(n, INT_MAX);
  queue<int> q;
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : adj[v])
      if (dist[u] > dist[v] + 1) {
        dist[u] = dist[v] + 1;
        q.push(u);
      }
  }
  if (dist[n - 1] <= 2) printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 13168
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;

    long ans = (n-1 + 1).to!long * (n-1) / 2;
    
    ans.writeln;
}

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

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

int main(int, char**)
{
  int n;
  cin >> n;

  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());

  int index = 0;
  ll ans = 0;
  rep(i,n-1) {
    ans += a[index];
    if ((i&1)==0) index++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4044
#include <stdio.h>
#define H 45


int main(){
  int n,u[H],fib,i;
  scanf("%d",&n);

  if(0<=n && n<=44){
    u[0]=1;
    u[1]=1;
    for(i=2;i<=n;i++){
      u[i]=u[i-1]+u[i-2];
    }
  }
  printf("%d\n",u[n]);
return 0;  
}

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

int main() {
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
}

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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

ll H, W;
vector<vecll> c(10, vecll(10));

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

    rep(y, 10) {
        rep(x, 10) {
            cin >> c[y][x];
        }
    }

    // 書き換え魔力最小値を求める
    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(y, H) {
        rep(x, W) {
            ll a;
            cin >> a;
            if (a == -1) continue;
            
            ans += c[a][1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main() {
	char b;
	cin >> b;
	if (b == 'A')cout << 'T' << endl;
	if (b == 'T')cout << 'A' << endl;
	if (b == 'G')cout << 'C' << endl;
	if (b == 'C')cout << 'G' << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	ll n, x, a[100], ans=0, sum=0;
	cin >> n >> x;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum+=a[i];
	}
	if(x>sum){
		cout << n-1 << endl;
		return 0;
	} else if(x==sum){
		cout << n << endl;
		return 0;
	} else {
		sort(a, a+n);
		for(int i=0; i<n; i++){
			if(x>=a[i]){
				x-=a[i];
				ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;;
#define ato find_by_order
#define of order_of_key
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
int main()
{
    flash
    ll n;ll x;ll m;
    cin>>n>>x>>m;ll cnt=n-1;ll sum=x;
    if(x%m==0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    map<ll,ll> maxu;map<ll,ll> s;s[0]=0;s[1]=x;ll dix=0;ll ins=0;
    for(ll i=1;i<=n-1;i++)
    {
        x=(x*x)%m;
        if(maxu.find(x)!=maxu.end())
        {
            ins=s[i]-s[maxu[x]-1];
            dix=(i+1)-(maxu[x])+1;
            break;
        }
        maxu[x]=i+1;
        cnt--;
       sum=(sum+x);
       s[i+1]=sum;
    }
    ll yo=cnt/(dix-1);yo=yo*ins;
    yo+=(s[maxu[x]-1+cnt%(dix-1)]-s[maxu[x]-1]);
    cout<<yo+sum<<endl;
}

Measured memory_bytes: 9848
#include <algorithm>
#include <iomanip>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <functional>
using namespace std;

class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        vector<int> s;
        in >> n;
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            int tmp;
            in >> tmp;
            ans += tmp;
            s.push_back(tmp);
        }

        sort(s.begin(), s.end());
        int i;
        for (i = 0; i < s.size(); i++)
        {
            if (s[i] % 10 == 0)
            {
                continue;
            }
            if (ans % 10 == 0)
            {
                ans -= s[i];
            }
            else
            {
                break;
            }
        }

        out << (i == s.size() ? 0 : ans);
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> jobs(m);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if (a>m) continue;
        jobs[m-a].push_back(b);
    }
    priority_queue<int> q;
    ll ans=0;
    for(int i=m-1;i>=0;i--){
        for(int b:jobs[i]){
            q.push(b);
        }
        if(!q.empty()){
            ans+=q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, m=0, i;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		if(a&1) m++;
	}
	puts(m&1?"NO":"YES");
}


Measured memory_bytes: 128
#include<stdio.h>

class Dice{
public:
	int num[6];
	char ch;
	void roll(char){
		int tmp=0;
		if(ch=='E'){
			tmp=num[2];
			num[2]=num[0];
			num[0]=num[3];
			num[3]=num[5];
			num[5]=tmp;
		}
		if(ch=='W'){
			tmp=num[3];
			num[3]=num[0];
			num[0]=num[2];
			num[2]=num[5];
			num[5]=tmp;
		}
		if(ch=='N'){
			tmp=num[4];
			num[4]=num[0];
			num[0]=num[1];
			num[1]=num[5];
			num[5]=tmp;
		}
		if(ch=='S'){
			tmp=num[1];
			num[1]=num[0];
			num[0]=num[4];
			num[4]=num[5];
			num[5]=tmp;
		}

	}
};

int main(){
	Dice dice;
	for(int i=0; i<7; i++){
		scanf("%d",&dice.num[i]);
	}
	while((dice.ch=(char)getchar()) !='\n'){
		dice.roll(dice.ch);
	}
	printf("%d\n",dice.num[0]);
	return 0;
}































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

int main()
{
  string s; cin >> s;
  int begin=0;
  int end=0;

  int i = 0;
  while(true) {
    if(s[i] == 'A') {
      begin = i;
      break;
    }
    i++;
  }

  int j = s.size()-1;
  while(true) {
    if(s[j] == 'Z') {
      end = i;
      break;
    }
    j--;
  }
  cout << j-i+1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;

const int N = 1e5 + 5;

int n, ans = 1, a[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	int t = 0;
	for (int i = 2; i <= n; i++) {
		if (t == 0) {
			if (a[i] > a[i - 1]) t = 1;
			if (a[i] < a[i - 1]) t = -1;
		} else 
		if (t == 1) {
			if (a[i] < a[i - 1]) ans++, t = 0;
		} else {
			if (a[i] > a[i - 1]) ans++, t = 0;
		}
	}
	cout << ans;
}

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

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
        int r = 0, cur = 0;
        long long ans = 0;
        for (int l = 0; l < n; l ++) {
                while (r < n && ((a[r] & cur) == 0)) cur |= a[r ++];
                ans += r - l;
                cur &= ~a[l];
        }
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 1024
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
x=i2()
if x[0]==x[1]:
  print(x[2])
if x[0]==x[2]:
  print(x[1])
if x[2]==x[1]:
  print(x[0])

Measured memory_bytes: 38384
n = gets.to_i
h = gets.chomp.split.map(&:to_i)

dp = Array.new(n, 0)
dp[1] = (h[1] - h[0]).abs

2.upto(n - 1) do |i|
  dp[i] = [dp[i - 1] + (h[i] - h[i - 1]).abs, dp[i - 2] + (h[i] - h[i - 2]).abs].min
end
puts dp[n - 1]

Measured memory_bytes: 11780
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	ll ans = k;

	rep(i,n-1){
		ans *= (k-1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		Console.WriteLine("ABC" + GetInt());
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    string[] inputa = Console.ReadLine().Split(' ');
		long a = long.Parse(inputa[0]);
		long b = long.Parse(inputa[1]);

    long answer = h*w - (h/a)*(w/b)*a*b;
    
		Console.WriteLine(answer);
	}
}


Measured memory_bytes: 17920
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;

int top, S[1000];
void push(int x){
    S[++top] = x;
}
int pop(){
    top--;
    return S[top+1];
}

//main
int main(){
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }
        else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(b*a);
        }else{
            push(atoi(s));
        }
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3240
#pragma once

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
int A, B,result;


int main() {
	
	cin >> A>>B;
	result = (A + B) % 24;

	cout <<result << endl;

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, k: usize,
        mut l: [u64;n]
    }
    l.sort();
    l.reverse();
    let mut ret = 0;
    for i in 0..k {
        ret += l[i];
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
n, W = map(int, input().split())
dp = [[0] * (W + 1) for _ in range(n + 1)]

dp[0][W] = 0
for i in range(n):
    w, v = map(int, input().split())
    for j in range(W + 1):
        if j >= w:
            dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[n][W])

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

int main (){

    long long int N,f=0,t=0,A=0;
    cin >> N;
    long long int a[N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(a[i] % 4 == 0) {
            f++;
        }else if(a[i] % 2 == 0) {
            t++;
        }
    }

    N -= t;
    if(t != 0) {
        if (f >= (N + 1) / 2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }else {
        if(f >= N / 2) {
            cout << "Yes" << endl;
        }else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
   string s;
  cin>>s;
  int h[26],i;
  for(i=0;i<26;++i)
       h[i]=0;
  
  for(i=0;i<s.length();++i)
  {
    h[s[i]-97]++;
  }
  
  for(i=0;i<26;++i)
  {
    if(h[i]>1)
         break;
  }
  if(i==26)
      printf("yes");
  
  else
     printf("no");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    string ans = "";
    while(n){
        --n;
        ans += (char)('a' + (n % 26));
        n /= 26;
    }

    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;

    return 0;
    
}

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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int N;
    cin >> N;
    int ans = 0;
    FOR(i,1,N) {
        ans+=i;
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int mod = 1000000007, N = 100;
int n;
int dp[N+1][4][4][4];

int32_t main() {

    cin >> n;

    dp[0][3][3][3] = 1;

    for(int i = 0; i < n; ++i) {
        for(int tago = 0; tago < 4; ++tago) {
            for(int oago = 0; oago < 4; ++oago) {
                for(int last = 0; last < 4; ++last) {
                    int cur = dp[i][tago][oago][last];
                    
                    for(int next = 0; next < 4; ++next) {
                        bool bad_c =
                            (tago == 0 && (oago == 2 || last == 2)) ||
                            (oago == 0 && last == 2) ||
                            (last == 0 && oago == 2);

                        bool bad_g = oago == 0 && last == 1;
                        
                        if(next == 1 && bad_c) continue;
                        if(next == 2 && bad_g) continue;
                        
                        dp[i+1][oago][last][next] = (dp[i+1][oago][last][next] + cur)%mod;
                    }
                }
            }
        }
    }
    
    int ans = 0;
    for(int i = 0; i < 4; ++i) {
        for(int j = 0; j < 4; ++j) {
            for(int k = 0; k < 4; ++k) {
                ans = (ans + dp[n][i][j][k])%mod;
            }
        }
    }

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


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
s = a.inject(:+)
a.map!{|v|v*n}

mini = 10**10
ans = 0
(n-1).downto(0) do |i|
  diff = (a[i] - s).abs
  if diff <= mini
    mini = diff
    ans = i
  end
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll ans = 0;
    if(n%2==0){
        ll k=n/2;
        for(ll i=0;i<k;i++)ans-=2*a[i];
        for(ll i=k;i<2*k;i++)ans+=2*a[i];
        ans+=a[k-1];
        ans-=a[k];
    }
    else{
        ll k=n/2;
        for(ll i=0;i<k;i++)ans-=2*a[i];
        ans+=a[k]+a[k+1];
        for(ll i=k+2;i<2*k+1;i++)ans+=2*a[i];
        ll val=0;
        for(ll i=0;i<k-1;i++)val-=2*a[i];
        val-=a[k-1];
        val-=a[k];
        for(ll i=k+1;i<2*k+1;i++)val+=2*a[i];
        ans=max(ans,val);
    }

    cout<<ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

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

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()


int main() {
	int n, count = 0;
	string s;
	cin >> n >> s;
	stack<char>st, sta;
	for (int i = 0;i < n;i++) {
		if (s[i] == '(') {
			st.push('(');
		}
		else {
			if (st.empty()) {
				cout << '(';
			}
			else st.pop();
		}
	}
	for (int i = n - 1;i >= 0;i--) {
		if (s[i] == '(') {
			if (sta.empty()) {
				count++;
			}
			else sta.pop();
		}
		else sta.push(')');
	}
	cout << s;
	for (int i = 0;i < count;i++)cout << ')';
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  ll n;
  cin >> n;
  ll a[3 * n];
  rep(i, 0, 3 * n) cin >> a[i];
  ll leftSum[n + 1], rightSum[n + 1];
  memset(leftSum, 0, sizeof(leftSum));
  memset(rightSum, 0, sizeof(rightSum));
  priority_queue<ll> leftQ, rightQ;

  rep(i, 0, n) {
    leftSum[0] += a[i];
    leftQ.push(-a[i]);
    rightSum[0] += a[3 * n - 1 - i];
    rightQ.push(a[3 * n - 1 - i]);
  }

  rep(i, n, 2 * n) {
    leftQ.push(-a[i]);
    ll tmpL = leftQ.top(); leftQ.pop();
    leftSum[i - n + 1] = leftSum[i - n] + tmpL + a[i];
    rightQ.push(a[3 * n - 1 - i]);
    ll tmpR = rightQ.top(); rightQ.pop();
    rightSum[i - n + 1] = rightSum[i - n] - tmpR + a[3 * n - 1 - i];
  }

  ll ans = leftSum[0] - rightSum[n];
  rep(i, 1, n + 1) ans = max(ans, leftSum[i] - rightSum[n - i]);
  cout << ans << endl;
}


Measured memory_bytes: 5996
def main():
	A, B, C = [int(_) for _ in input().split()]

	l_max=max(A,B,C)
	l_min=min(A,B,C)
	l_mid=(A+B+C)-(l_max+l_min)

	ans=10*l_max+l_mid+l_min
	print(ans)
    
main()

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

#define int long long int

int32_t main()
{
  int h;
  cin>>h;
  int cnt = 0;
  int val = 1;
  while(h>1)
  {
    cnt = cnt + 2*val;
    val = 2*val;
    h /= 2;
  }
  cout<<cnt+1<<endl;
  return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  map<int, bool> exist;
  for ( int i = 0; i < 150; i++ ) {
    for ( int j = i; j < 150; j++ ) {
      exist[i*i+j*j] = true;      
    }
  }

  int q;
  cin >> q;
  
  while ( q-- ) {
    int m, n;
    cin >> m >> n;

    int cnt = 0;
    int mn = m*m+n*n;    
    for ( int i = -150; i < 150; i++ ) {
      for ( int j = -150; j < 150; j++ ) {
	if ( i == 0 && j == 0 ) continue;	
	int ij = i*i+j*j;	
	int xy = mn/ij;
	if ( ij*xy != mn ) continue;
	if ( exist[xy] ) {
	  bool flag = false;	  
	  for ( int k = -150; k < 150; k++ ) {
	    for ( int l = -150; l < 150; l++ ) {
	      if ( i*k+j*l == m && i*l-j*k == n ) {
		flag = true;
		k = 150;
		break;
	      }
	    }
	  }
	  if ( flag ) cnt++;
	}
      }
    }

    if ( cnt == 8 ) cout << "P" << endl;
    else cout << "C" << endl;
  }
 
  return 0;
}



Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

map<P, bool> mp;
P pos[5000];

int main(){
	int n;
	while(cin >> n && n){
		int res = 0;
		mp.clear();
		rep(i, n){
			cin >> pos[i].first >> pos[i].second;
			mp[pos[i]] = true;
		}
		rep(i, n)rep(j, n){
			if(i == j) continue;
			int dx = pos[i].first - pos[j].first;
			int dy = pos[i].second - pos[j].second;

			int x2 = pos[j].first + dy;
			int y2 = pos[j].second - dx;
			int x3 = x2 + dx;
			int y3 = y2 + dy;
			
			if(mp.find(P(x2, y2)) != mp.end() && mp.find(P(x3, y3)) != mp.end()){
				res = max(res, dx * dx + dy * dy);
			}
		}
		cout <<res << endl;
	}
	return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N;
    cin >> N;
    stack<ll> S;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            S.push(i);
        }
    }
    ll b = N / S.top();
    cout << S.top() + b - 2 << endl;
    return 0;
}

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

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;

lld A, B;

int main() {
  scanf("%lld %lld", &A, &B);
  if(B % A == 0) {
    cout << A + B << endl;
  }
  else {
    cout << B - A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/11.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    long long A,B, K;

    cin>>A>>B>>K;

//    for (int i = 0; i < K; ++i) {
//        if(A>0){
//            A--;
//        }else if(B>0){
//            B--;
//        }else{
//
//        }
//    }

    if(K-A < 0){
        A = A - K;
    }else{
        if(A>0){
            K = K - A;
            A = 0;
        }

        if(K-B < 0){
            B = B - K;
        }else{
            if(B>0){
                B = 0;
            }
        }

    }

    cout<<A<<" "<<B<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n,k;
  while(cin>>n>>k){
    if(!n&&!k) break;
    vector<int> a(k);
    REP(i,k)cin>>a[i];
    sort(a.begin(),a.end());
    int ans = 0;
    int tmp1 = 0;
    int tmp2 = 0;
    bool white = (a[0]==0);
    REP(i,k){
      if(a[i]==0) continue;
      tmp1++;
      if(white&&(i==1||i==k-1)&&(1<a[i]&&a[i]<n)&&tmp2<1) tmp2=1;
      if((i<k-1&&a[i+1]-a[i]!=1)||i==k-1){
        ans = max(ans,tmp2+tmp1);
        tmp2 = (a[i+1]-a[i]==2&&white)?(tmp1+1):0;
        tmp1 = 0;
      }
    }
    cout<<ans<<endl;
  }



  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  string s;
  cin >> n >> s;
  if (s.substr(0, n / 2) == s.substr(n / 2)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            long N = long.Parse (str[0]);
            long K = long.Parse (str[1]);

            long ans = 0;
            if (N >= 0)
            {
                long r = N % K;
                ans = Min (r, K - r);
            }
            else
            {
                ans = Min (N, K - N);
            }

            Console.WriteLine (ans);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<bool>> field(h+2,vector<bool>(w+2,false));
  rep(i,h)rep(j,w) {
    char c;
    cin >> c;
    if(c=='.') field[i+1][j+1] = true;
  }
  int ans = 0;
  for(int i = 1; i<=h; i++) {
    for(int j = 1; j<=w; j++) {
      if(field[i][j]) {
        vector<vector<bool>> searched(h+2,vector<bool>(w+2,false));
        queue<vector<int>> q;
        int tmp = 0;
        searched[i][j] = true;
        q.push({i,j,0});
        while(!q.empty()) {
          vector<int> v = q.front();
          q.pop();
          int y = v[0]; int x = v[1]; int d = v[2];
          tmp = max(tmp,d);
          if(field[y+1][x] && !searched[y+1][x]) {
            searched[y+1][x] = true;
            q.push({y+1,x,d+1});
          }
          if(field[y-1][x] && !searched[y-1][x]) {
            searched[y-1][x] = true;
            q.push({y-1,x,d+1});
          }
          if(field[y][x+1] && !searched[y][x+1]) {
            searched[y][x+1] = true;
            q.push({y,x+1,d+1});
          }
          if(field[y][x-1] && !searched[y][x-1]) {
            searched[y][x-1] = true;
            q.push({y,x-1,d+1});
          }
        }
        ans = max(ans,tmp);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Game {
    private Pebble pebble;
    private Candidate[] candidate;
    private int numOfCandidates;
    private int totalNumOfPebbles;

    public Game(int numOfCandidates, int totalNumOfPebbles) {
        candidate = new Candidate[numOfCandidates];
        for (int i = 0; i < numOfCandidates; i++) {
            candidate[i] = new Candidate();
        }
        pebble = new Pebble(totalNumOfPebbles);

        this.numOfCandidates = numOfCandidates;
        this.totalNumOfPebbles = totalNumOfPebbles;
    }

    public int play() {
        for (int i = 0; i < numOfCandidates; i++) {
            candidate[i].playGame(pebble);
            if (candidate[i].getNumOfPebbles() == totalNumOfPebbles) {
                return i;
            }
        }
        return -1;
    }
}

class Pebble {
    private int numOfPebbles;

    public Pebble(int numOfPebbles) {
        this.numOfPebbles = numOfPebbles;
    }

    public void setNumOfPebbles(int numOfPebbles) {
        this.numOfPebbles = numOfPebbles;
    }

    public void decrementPebbles() {
        this.numOfPebbles--;
    }

    public void addPebbles(int numOfPebbles) {
        this.numOfPebbles += numOfPebbles;
    }

    public int getNumOfPebbles() {
        return this.numOfPebbles;
    }
}

class Candidate {
    private int numOfPebbles;

    public Candidate() {
        this.numOfPebbles = 0;
    }

    public void playGame(Pebble pebble) {
        if (pebble.getNumOfPebbles() != 0) {
            this.numOfPebbles++;
            pebble.decrementPebbles();
        } else {
            pebble.addPebbles(this.numOfPebbles);
            this.numOfPebbles = 0;
        }
    }

    public int getNumOfPebbles() {
        return this.numOfPebbles;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner((System.in));
        int n, p;
        while (true) {
            n = Integer.parseInt(sc.next());
            p = Integer.parseInt(sc.next());
            if (n == 0 && p == 0) break;
            Game game = new Game(n, p);
            while (true) {
                int result = game.play();
                if (result != -1) {
                    System.out.println(result);
                    break;
                }
            }
        }
    }
}



Measured memory_bytes: 27384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

int main(){
	long long int n,sum=0;
	std::cin >> n;

	std::vector<long long int> v(n);
	std::vector<long long int> g(n);
	for (long long int& x : v) {
		std::cin >> x;
	}

	for (int i = 0; i < n; i++) {
		g[i]=v[i] - (i + 1);
	}

	std::sort(g.begin(), g.end());

	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			sum += abs(v[i] - ((g[n / 2 - 1] + g[n / 2]) / 2 + i + 1));
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			sum += abs(v[i] - (g[n / 2]+i+1));
		}
	}

	std::cout << sum << std::endl;

	return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] A = new long[N];
        for(int n=0; n<N; n++) A[n]=sc.nextLong();

        for(int n=K; n<N; n++){
            if(A[n] > A[n-K]) System.out.println("Yes");
            else System.out.println("No");
        }

        
    }
}


Measured memory_bytes: 61188
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int f[N], bad[N];
int64 sum[N];

struct Edge {
  int x, y, z;
  bool operator <(const Edge& rhs) const {
    return z < rhs.z;
  }
};

Edge e[N];

int find(int x) {
  if (f[x] != f[f[x]]) f[x] = find(f[x]);
  return f[x];
}

void join(int x, int y, int z) {
  int rx = find(x), ry = find(y);
  if (rx != ry) {
    f[ry] = rx;
    sum[rx] += sum[ry];
    bad[rx] += bad[ry];
  }
  if (z > sum[rx]) {
    ++bad[rx];
  } else {
    bad[rx] = 0;
  }
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &sum[i]);
    f[i] = i;
    bad[i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].z);
    --e[i].x; --e[i].y;
  }
  sort(e, e + m);
  for (int i = 0; i < m; ++i) {
    join(e[i].x, e[i].y, e[i].z);
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (find(i) == i) ret += bad[i];
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 3456
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

H, W, M = LI()
bomb = defaultdict(lambda : 0)
cnt_h = [0] * (H+1)
cnt_w = [0] * (W+1)
for _ in range(M):
    h, w = LI()
    bomb[(h, w)] = 1
    cnt_h[h] += 1
    cnt_w[w] += 1

max_h = max(cnt_h)
max_w = max(cnt_w)

ans = max_h + max_w

H_list = []
W_list = []
for i in range(1, H+1):
    if cnt_h[i] == max_h:
        H_list.append(i)

for i in range(1, W+1):
    if cnt_w[i] == max_w:
        W_list.append(i)

for w in W_list:
    for h in H_list:
        if bomb[(h, w)] == 0:
            print(ans)
            quit()
print(ans-1)

Measured memory_bytes: 168444
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
int main(){
	int n;
	int a=0,b=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",&t1,&t2);
		if(strcmp(t1,t2)==0) a++,b++;
		if(strcmp(t1,t2)>0) a+=3;
		if(strcmp(t1,t2)<0) b+=3;
	}
	printf("%d %d\n",a,b);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 505
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int H,W;
char s[MAXN][MAXN];
char a[MAXN][MAXN],b[MAXN][MAXN];
void Solve() {
    read(H);read(W);
    for(int i = 1 ; i <= H ; ++i) scanf("%s",s[i] + 1);
    for(int i = 1 ; i <= H ; ++i) {
	for(int j = 1 ; j <= W ; ++j) {
	    a[i][j] = b[i][j] = s[i][j];
	}
    }
    for(int i = 1 ; i <= W ; ++i) {a[1][i] = '#';b[H][i] = '#';}
    for(int j = 1 ; j <= W ; ++j) {
	if(j & 1) {
	    for(int i = 1 ; i < H ; ++i) a[i][j] = '#';
	}
	else {
	    for(int i = 2 ; i <= H ; ++i) b[i][j] = '#';
	}
    }
    for(int i = 1 ; i <= H ; ++i) {
	for(int j = 1 ; j <= W ; ++j) {
	    putchar(a[i][j]);
	}
	enter;
    }
    enter;
    for(int i = 1 ; i <= H ; ++i) {
	for(int j = 1 ; j <= W ; ++j) {
	    putchar(b[i][j]);
	}
	enter;
    }
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<ll> yakusu(ll n){
  vector<ll> ret;
  for(ll p = 1; p*p <= n; p++){
    if(n%p == 0){
      ret.push_back(p);
      if(p*p != n){
        ret.push_back(n/p);
      }
    }
  }
  sort(all(ret));
  return ret;
}

map<ll,ll> soinsu(ll n){
  map<ll,ll> mp;
  for(ll p = 2; p*p <= n; p++){
    if(n%p == 0){
      mp[p]++;
      n /= p;
      p--;
    }
  }
  if(n > 1){
    mp[n]++;
  }
  return mp;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int k;cin>>k;
  rep(i,k){
    cout<<"ACL";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3656
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    ll n, k, r;
    cin >> n >> k;
    r = n % k;
    if(r > k / 2){
        r = k - r;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int a = 0, b = 0, c = 0, d = 0;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	//�����Z�؂��グ�̌v�Z�̍H�v
	int dta = (c + b - 1) / b;	// dead time aoki
	int dtt = (a + d - 1) / d;	// dead time takahashi
	if (dta <= dtt) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
int fact[MAX_P];
int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

int euler_phi(int n){
  int res=n;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

int euler[MAX_N];

void euler_phi2(){
  for(int i=0;i<MAX_N;i++) euler[i]=i;
  for(int i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}

int mod_pow(int x,int n,int mod){
  int res=1;
  while(n>0){
    if(n&1) (res*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return res;
}

void init(int p){
  fact[0]=1;
  for(int i=1;i<MAX_P;i++) fact[i]=(fact[i-1]*i)%p;
}

int mod_fact(int n,int p,int& e){
  e=0;
  if(n==0) return 1;
  int res=mod_fact(n/p,p,e);
  e+=n/p;
  if(n/p%2!=0)return res*(p-fact[n%p]) %p;
  return res*fact[n%p]%p;
} 
int mod_comb(int n,int k,int p){
  if(n==k||k==0) return 1;
  int e1,e2,e3;
  int a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%p,p)%p;
}

signed main(){
  int n,m;
  cin>>m>>n;
  cout<<mod_pow(m,n,MOD)<<endl;
  return 0;
}

Measured memory_bytes: 3100