akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int H, W;
string B[50];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
//---------------------------------------------------------------------------------------------------
int vis[55][55];
int dp[55][55];
int check() {
    queue<pair<int, int>> que;
    que.push({ 0, 0 });
    vis[0][0] = 1;
    while (!que.empty()) {
        auto q = que.front(); que.pop();
        int x, y;
        tie(x, y) = q;

        if (x == W - 1 and y == H - 1) return dp[y][x];

        rep(d, 0, 4) {
            int xx = x + dx[d];
            int yy = y + dy[d];
            if (0 <= xx and xx < W and 0 <= yy and yy < H) {
                if (B[yy][xx] == '.' and vis[yy][xx] == 0) {
                    vis[yy][xx] = 1;
                    dp[yy][xx] = dp[y][x] + 1;
                    que.push({ xx, yy });
                }
            }
        }
    }

    return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W;
    rep(y, 0, H) cin >> B[y];

    int ans, res = check();
    if (!res) ans = -1;
    else {
        ans = H * W - res - 1;
        rep(y, 0, H) rep(x, 0, W) if (B[y][x] == '#') ans--;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  while(true) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m==-1 && f==-1 && r==-1) break;
    char grade;
    int tot = m + f;
    if (m==-1 || f==-1) grade = 'F';
    else if (tot >= 80) grade = 'A';
    else if (tot >= 65) grade = 'B';
    else if (tot >= 50) grade = 'C';
    else if (tot >= 30) {
      if (r < 50) grade = 'D';
      else grade = 'C';
    }
    else grade = 'F';
    printf("%c\n", grade);
  }
  return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    string s, t;
    bool flag = false;
    string ans = "~";
    cin >> s >> t;

    Rep(i, s.size()) {
        if ( s[i] == t[0] || s[i] == '?' ) {
            bool flag2 = true;
            Rep(j, t.size()) {
                if ( i+j >= s.size() ) {
                    flag2 = false; break;
                }
                if ( !(s[i+j] == '?' || s[i+j] == t[j]) ) {
                    flag2 = false; break;
                }
            }
            if ( flag2 ) {
                flag = true;
                ans = s;
                Rep(j, t.size()) {
                    ans[i+j] = t[j];
                }
            }
        }
    }
    if ( flag ) {
        Rep(i, s.size()) {
            if ( ans[i] == '?' ) cout << 'a';
            else cout << ans[i];
        }
        cout << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// atcoder/abc171/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  char c;
  while (cin >> c) {
    if ('A' <= c && c <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
  }

  return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        System.out.println( Math.min(a+b, Math.min(b+c,c+a)));
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
long long int cnt=0;
void Merge(int A[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    int L[n1+1],R[n2+1];
    int i,j;
    for(i=0;i<n1;++i)
    {
        L[i]=A[left+i];
    }
    for(i=0;i<n2;++i)
    {
        R[i]=A[mid+i];
    }
    L[n1] = R[n2] =  INT_MAX;
    i=0;j=0;
    for(int k=left;k<right;k++)
    {
        if(L[i]<=R[j])
        {
            A[k]=L[i++];
        }
        else
        {
            A[k]=R[j++];
            cnt+=n1-i;
        }
    }
}
void mergesort(int A[],int left,int right)
{
    int mid;
    if(left+1<right)
    {
        mid=(left+right)/2;
        mergesort(A,left,mid);
        mergesort(A,mid,right);
        Merge(A,left,mid,right);
    }
}

int main(){
    int A[500000],n,i;
    scanf("%d",&n);
    for(i=0;i<n;++i)
    {
        scanf("%d",&A[i]);
    }
    mergesort(A,0,n);
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 4708
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

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


const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);


#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using Bint = mp::cpp_int;



int main(void){
  int N;                        // Nは「ソースコード」の個数
  // i個目の「ソースコード」の「特徴」は，A_{i0} 〜 A_{i,M-1}で表せる．
  // 例えば，ソースコードS_4の「特徴」はA_{41}からA{4M}で表される．
  // ソースコードはS_0からS_{N-1}までのN個
  // それぞれのソースコードS_iについて，特徴はA_{i0} から A_{i.M-1}まで M個，総計NM個の特徴が存在
  int M;                        // Mは，ソースコード一つあたりの特徴の個数
  int C;                        //
  cin>>N>>M>>C;
  
  vector<int> B(M);
  FOR(i,0,M){
    cin>>B[i];
  }

  vector<vector<int> > A(N,vector<int> (M,0)) ;

  int cnt=0;
  int temp=0;
  
  FOR(i,0,N){
    temp=0;
    FOR(j,0,M){
      cin>>A[i][j];
      temp+=A[i][j]*B[j];
    }
    if(temp>C*(-1)){cnt++;}
    else{}
  }
  cout<<cnt<<endl;
  return 0;
}



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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=(b/c)-(a/c);
    if(a%c==0) ans++;
    ll x=c*d/__gcd(c,d);
    ans-=(b/x)-(a/x);
    if(a%x==0) ans--;
    ans+=(b/d)-(a/d);
    if(a%d==0) ans++;
    cout<<b-a+1-ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N;
    cin>>N;
    vi p(N);
    REP(i,N)cin>>p[i];
    ll cont=0;
    REP(i,N){
        if(p[i]==i+1){
            cont++;
        }else{
            ans+=(cont+1)/2;
            cont=0;
        }
    }
    ans+=(cont+1)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  int n, a, b;
  cin >> n >> a >> b;

  cout << (abs(a - b) % 2 == 0 ? "Alice" : "Borys") << endl;


  
  return 0;
}

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

int main(){
  long int n , answer ;
  cin >> n ;
  int x = sqrt(n)/1 ;
  for(int i=1; i<=x; i++){
    if(n%i==0){
        answer = i+n/i ;
    }
  }
  cout << answer-2 << endl ;
}

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

int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W));
  REP(i, 0, H) REP(j, 0, W) cin >> A[i][j];

  struct op { ll y1, x1, y2, x2; };
  vector<op> ans;
  REP(i, 0, H) {
    REP(j, 0, W - 1) {
      if (A[i][j] % 2 == 1) {
        ans.push_back((op) { i, j, i, j + 1 });
        A[i][j]--;
        A[i][j + 1]++;
      }
    }
  }
  REP(i, 0, H - 1) {
    if (A[i][W - 1] % 2 == 1) {
      ans.push_back((op) { i, W - 1, i + 1, W - 1 });
      A[i][W - 1]--;
      A[i + 1][W - 1]++;
    }
  }

  cout << ans.size() << endl;
  REP(i, 0, ans.size()) {
    cout << ans[i].y1 + 1 << " " << ans[i].x1 + 1 << " " << ans[i].y2 + 1 << " " << ans[i].x2 + 1 << endl;
  }
}

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

const int N = 100 * 1000 + 5;

vector <int> adj[N];
vector <int> ans1;
vector <int> ans2;
bool mark[N];
void ad1(int v) {
	mark[v] = true;
	ans1.push_back(v);
	for (auto u : adj[v]) {
		if (!mark[u]) {
			ad1(u);
			return ;
		}
	}
}
void ad2(int v) {
	mark[v] = true;
	ans2.push_back(v);
	for (auto u : adj[v]) {
		if (!mark[u]) {
			ad2(u);
			return ;
		}
	}
}
int main() {
	int n, m, u, v;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	mark[u] = mark[v] = true;
	ad1(u);
	ad2(v);
	cout << ans1.size() + ans2.size() << endl;
	for (int i = (int) ans1.size() - 1; i >= 0; i--) {
		cout << ans1[i] << " ";
	}
	for (int i = 0; i < ans2.size(); i++) {
		cout << ans2[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 9336
#include<stdio.h>
using namespace std;

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

	for(int i=1;i<=n;i++){
		if(i%3 == 0){
			printf(" %d", i);  //3の倍数を出力
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d", i);
					break;
				}
				x /= 10;
			}while(x);
		}
	}printf("\n");
}


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

#define MAX_N 100000

int N;
int h[MAX_N];
int dp[MAX_N+1];

int main(){
    cin >> N;
    rep(i, N){
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]); 
    for(int i=2;i<N;i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

ans = reduce(gcd, A)
print(ans)


Measured memory_bytes: 28232
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
struct edge {int /*from,*/to,cost;};

main(){
    int h,w,d;
    cin >> h >> w >> d;

    int field[314][314];
    int are[114514]={};
    P num[114514];
    REP(i,h) REP(j,w){
        scanf("%d",&field[i][j]);
        num[field[i][j]].FI=i;
        num[field[i][j]].SE=j;
    }

    REP1(i,d){
        are[i] = 0;
        int a = i + d;
        int x = num[i].FI;
        int y = num[i].SE;
        while(a<=h*w){
            int nx,ny;
            nx = num[a].FI;
            ny = num[a].SE;
            int cost = abs(nx-x) + abs(ny-y);
            are[a] = are[a-d] + cost;
            a += d;
            x = nx;
            y = ny;
        }
    }

    int q;
    cin >> q;
    REP(i,q){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",are[r]-are[l]);
    }


    return 0;
}


Measured memory_bytes: 2816
a,b,c=map(int,input().split())

abc=[a,b,c]
abc.sort()
if a%2==1 and b%2==1 and c%2==1:
  print((abc[0]*abc[1]*(abc[2]//2+1))-(abc[0]*abc[1]*(abc[2]//2)))
else:
  print(0)

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n;
    cin>>n;
    vector<vector<bool>> graph(n,vector<bool>(n));
    rep(i,0,n){
        int u,k;
        cin>>u>>k;
        u--;
        rep(j,0,k){
            int v;
            cin>>v;
            v--;
            graph[u][v]=true;
        }
    }
    vector<int> d(n,-1);
    queue<int> q;
    q.push(0);
    d[0]=0;
    while(!q.empty()){
        int now=q.front();q.pop();
        for(int i=0;i<n;i++){
            if(graph[now][i] && d[i]==-1){
                q.push(i);
                d[i]=d[now]+1;
            }
        }
    }
    rep(i,0,n){
        cout<<i+1<< " "<< d[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll a[n], tmp, bi[n];
  REP(i, n){
    cin >> a[i];
    tmp = a[i];
    bi[i] = 0;
    while(tmp % 2 == 0){
      bi[i]++;
      if(bi[i] == 2) break;
      tmp /= 2;
    }
  }
  map<ll, ll> mp;
  REP(i, n) mp[bi[i]]++;
  ll rec = 1;
  if(mp[0] == 0) cout << "Yes";
  else{
    ll p = 0;
    mp[0]--;
    REP(i, n - 1){
      if(p == 0){
        p = 2;
        mp[2]--;
      }
      else if(p == 1){
        if(mp[1]){
          p = 1;
          mp[1]--;
        }
        else{
          p = 2;
          mp[2]--;
        }
      }
      else{
        if(mp[0]){
          p = 0;
          mp[0]--;
        }
        else if(mp[1]){
          p = 1;
          mp[1]--;
        }
        else{
          p = 2;
          mp[2]--;
        }
      }
      if(mp[0] < 0 || mp[1] < 0 || mp[2] < 0){
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
    return 0;
  }
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<List<Integer>> l = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            l.add(Arrays.asList(Integer.parseInt(sc.next()), Integer.parseInt(sc.next())));
        }

        l.sort(Comparator.comparingInt(o -> o.get(1)));

        int time = 0;
        for (List<Integer> list : l) {
            time += list.get(0);
            if (time > list.get(1)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 88720
import math

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

def main(): 

    n,d=map(int, input().split())

    x=[list(map(int, input().split())) for _ in range(n)]

    cnt = 0
    for i in range(n):
        for j in range(i + 1, n):
            result = 0
            for k in range(d):
                result += abs(x[i][k] - x[j][k])**2

            if is_integer_num(math.sqrt(result)):
                cnt += 1

    print(cnt)




if __name__ == "__main__":
    main() 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n, k;
llong ans = 0;
llong a[maxn];

bool read()
{
	if (scanf("%d %d", &n, &k) != 2)
		return false;

	forn (i, n)
		scanf("%lld", a + i);

	return true;
}

void calc(int l, int r)
{
	if (l == r)
	{
		ans += a[l] >= 0;
		return ;
	}

	int m = (l + r) / 2;
	calc(l, m);
	calc(m + 1, r);
	vector<llong> ps;
	llong cur = 0;

	for (int i = m; i >= l; --i)
	{
		cur += a[i];
		ps.push_back(cur);
	}

	cur = 0;
	sort(ps.begin(), ps.end());

	for (int i = m + 1; i <= r; ++i)
	{
		cur += a[i];
		int cnt = lower_bound(ps.begin(), ps.end(), -cur) - ps.begin();
		ans += size(ps) - cnt;
	}
}

void solve()
{
	forn (i, n)
		a[i] -= k;

	calc(0, n - 1);
	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 3348
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5+5;

ll n, a[N], s[N], ans;

int main() {
	scanf("%lld", &n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld", &a[i]);
		s[i] = max(s[i-1], a[i]);
		ans += s[i] - a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n;cin>>n;
  int mn=1000000;
  int ans=0;
  for(int i=0;i<n;i++){
    int t;cin>>t;
    if(t<mn)ans++;
    mn = min(mn, t);
  }
  cout<<ans<<endl;
  
  return 0;
}


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

using namespace std;

class UnionFind {
public:
    explicit UnionFind(int N) : root(N, -1), size(N, 1) {}
    int getRoot(int u){ return root[u] == -1 ? u : root[u] = getRoot(root[u]); }
    int getSize(int u){ return size[getRoot(u)]; }
    int same(int a, int b){
        return getRoot(a) == getRoot(b);
    }
    int merge(int a, int b){
        int u = getRoot(a);
        int v = getRoot(b);
        if(u != v){
            root[u] = v;
            size[v] += size[u];
        }
    }
private:
    vector<int> root;
    vector<int> size;
};

void dfs(const vector<vector<int>>& g, int pos, int prev, vector<int>& deg){
    for(auto& t : g[pos]){
        if(t == prev) continue;
        dfs(g, t, pos, deg);
    }
    if(prev == -1) return;
    if(deg[pos]%2 == 0){
        cout << prev << " " << pos << endl;
        deg[prev]++;
    } else {
        cout << pos << " " << prev << endl;
        deg[pos]++;
    }
}

int main(){
    int N, M;
    while(cin >> N >> M){
        if(M%2 == 1){
            cout << -1 << endl;
            for(int i=0;i<M;i++){
                int a, b; cin >> a >> b;
            }
            continue;
        }
        vector<vector<int>> g(N+1);
        UnionFind uf(N+1);
        vector<int> deg(N+1, 0);
        for(int i=0;i<M;i++){
            int a, b; cin >> a >> b;
            int u = uf.getRoot(a);
            int v = uf.getRoot(b);
            if(u == v){
                cout << a << " " << b << endl;
                deg[a]++;
            } else {
                uf.merge(a, b);
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
        dfs(g, 1, -1, deg);
    }
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int x;
    cin >> x;
    
    int tmp = 0;
    tmp = x % 100;
    
    if(tmp > 5*(x/100)){
        cout << 0;
        return 0;
    }
    
    cout << 1;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define NMAX 100

int main(){

	int n;
	int ah[NMAX];
	int d;
	int b;
	bool f;
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n+1;i++){
			cin>>ah[i];
		}
		for(int i=0;i<n+1;i++){
			f=true;
			if(i==0) d=ah[2]-ah[1];
			else if(i==1) d=ah[2]-ah[0];
			else d=ah[1]-ah[0];
			if(i==0) b=1;
			else b=0;
			for(int j=(i==0)?2:1;j<n+1;j++){
				if(i==j) continue;
				if(j-1==i){
					if(ah[j]-ah[j-2]!=d) f=false;
				}
				else{
					if(ah[j]-ah[j-1]!=d) f=false;
				}
			}
			if(f){
				cout<<ah[i]<<endl;
				break;
			}
		}
	}

}

Measured memory_bytes: 1160
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

use std::collections::HashSet;

fn main() {
   input! {
      x:isize,n:usize,
      p:[isize;n]
   }
   let s = p.iter().map(|x| *x).collect::<HashSet<_>>();

   if n == 0 {
      println!("{}", x);
      return;
   }
   let mut a = 999;
   let mut b = -999;
   for i in x..200 {
      if !s.contains(&i) {
         a = i;
         break;
      }
   }
   for i in (-100..=x).rev() {
      if !s.contains(&i) {
         b = i;
         break;
      }
   }
   if (a - x).abs() < (b - x).abs() {
      println!("{}", a);
   } else {
      println!("{}", b);
   }
}


Measured memory_bytes: 2172
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){

  double x1,y1,x2,y2;

  cin >> x1>>y1>>x2>>y2;

  cout << setprecision(15) << sqrt(pow(x2-x1,2)+pow(y2-y1,2)) << endl;

}





Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int x=0;
  string S;
  cin >> N >> S;
  
  for (int i=0; i<N; i++) {
    if (S[i] == 'A') {
      if (S[i+1] == 'B' ) {
        if (S[i+2] == 'C') x++;
      }
    }
  }
  
  cout << x << endl;
  return 0;
  
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

x1,y1,x2,y2 = II()


x3=x2+(y1-y2)
y3=y2-(x1-x2)
x4=x1+(y1-y2)
y4=y1-(x1-x2)

print(x3,y3,x4,y4)

Measured memory_bytes: 12504
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<tuple>
#include<vector>
#include<map>
#include<numeric>
#include<limits>
#include<type_traits>
using namespace std;

int main(void){
  long long int R, G, B, N;
  long long int ans = 0;
  cin >> R >> G >> B >> N;
  for(long long int r = 0; r <= N / R; r++){
    for(long long int g = 0; g <= N / G; g++){
      long long int temp = N - R*r - G*g;
      if(temp >= 0 && temp % B == 0){
        ans++;
       // cout << r << " " << g << " " << temp / B << endl;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int n, m;
bool edge[5000][5000];
vector<int> G[5000];

bool used[5000];
vector<int> order;

void dfs(int v){
  if(used[v])return;
  used[v] = true;
  for(int u : G[v]){
    dfs(u);
  }
  order.push_back(v);
}

int main(){
  cin >> n >> m;
  for(int t=0;t<m;t++){
    int i, j;
    cin >> i >> j;
    --i;
    --j;
    edge[i][j] = true;
    G[i].push_back(j);
  }
  for(int i=0;i<n;i++)dfs(i);
  reverse(order.begin(), order.end());
  bool hasHamiltonianPath = true;
  for(int i=0;i+1<n;i++){
    hasHamiltonianPath &= edge[order[i]][order[i+1]];
  }
  for(int i : order)cout << i + 1 << endl;
  cout << (hasHamiltonianPath ? 0 : 1) << endl;
  return 0;
}

Measured memory_bytes: 28220
N, M = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(M))

MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
  if i in a:
    continue
  x = dp[i - 1]
  if i > 1:
    x += dp[i - 2]
  dp[i] = x % MOD

ans = dp[N]
print(ans)

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s;
	cin >>n >>s >>q;
	
	vector<deque<int>> zt(26);
	rep(i, n) zt[s[i]-'a'].push_back(i);
	
	rep(zq,q){
		int x; cin >>x;
		if(x==1){
			int y; char z; cin >>y >>z;
			y--;
			if(s[y]==z) continue;
			auto it = lower_bound(all(zt[s[y]-'a']), y);
			//assert(it != zt[s[y]-'a'].end());
			zt[s[y]-'a'].erase(it);
			auto it2 = lower_bound(all(zt[z-'a']), y);
			zt[z-'a'].insert(it2, y);
			s[y] = z;
		}else{
			int l,r; cin >>l >>r;
			l--; r--;
			ll ans = 0;
			rep(j ,26){
				int sm = upper_bound(all(zt[j]), r) -lower_bound(all(zt[j]), l);
				if (sm > 0) ans++;
			}
			cout << ans <<"\n";
		}
	
	
	
	}

	return 0;
}


Measured memory_bytes: 2972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int haku = sc.nextInt();
        int fs = sc.nextInt();
        int fsm = sc.nextInt();
        int nxm = sc.nextInt();
        
        int money = 0;
        
        for(int i=1;i<=haku;i++){
            if(i <= fs){
                money += fsm;
            }else{
                money += nxm;
            }
        }
        System.out.println(money);
    }
}

Measured memory_bytes: 35824
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    ll modpow(ll x, ll n){
        ll res = 1;
        ll mul = x;
        while(n){
            if(n % 2) res = res * mul % MOD;
            mul = mul * mul % MOD;
            n /= 2;
        }
        return res;
    }

    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    if(a < b) swap(a, b);
    if(b == 0){
        cout << n * 100 * modpow(a, MOD - 2) % MOD << endl;
        return 0;
    }
    Combination com(200000);
    ll ra = a * modpow(a + b, MOD - 2) % MOD;
    ll rb = b * modpow(a + b, MOD - 2) % MOD;
    ll s = 100 * modpow(a + b, MOD - 2) % MOD;
    ll ans = 0;
    ll p = 1;
    for(int i = 0; i < n; i++) p = p * ra % MOD;
    ll m = s * n % MOD;
    for(int i = 0; i < n; i++){
        ans = (ans + com.com(n + i - 1, i) * p % MOD * m % MOD) % MOD;
        p = p * rb % MOD;
        m = (m + s) % MOD;
    }
    p = 1;
    for(int i = 0; i < n; i++) p = p * rb % MOD;
    m = s * n % MOD;
    for(int i = 0; i < n; i++){
        ans = (ans + com.com(n + i - 1, i) * p % MOD * m % MOD) % MOD;
        p = p * ra % MOD;
        m = (m + s) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
int M;

struct edge{
  int to;
  i64 cost;
};

vector<vector<edge>> edges;

vector<i64> dist;

int main(){
  cin >> N >> M;

  edges.resize(N);
  dist.resize(N,1e12);
  rep(i,0,M - 1){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    edges[a].push_back({b,-c});
  }

  dist[0] = 0;

  rep(i,0,N){
    rep(v,0,N - 1){
      for(auto & e : edges[v]){
        dist[e.to] = min(dist[e.to] , dist[v] + e.cost);
      }
    }
  }

  vector<bool> ne(N,false);

  rep(i,0,N){
    rep(v,0,N - 1){
      for(auto & e : edges[v]){
        if(dist[e.to] > dist[v] + e.cost){
          dist[e.to] = dist[v] + e.cost;
          ne[e.to] = true;
        }
        ne[e.to] = ne[e.to] || ne[v];
      }
    }
  }

  if(ne[N - 1]){
    cout << "inf" << endl;
  }
  else{
    cout << dist[N - 1] * -1 << endl;
  }

}



Measured memory_bytes: 384
#include <stdio.h>
int main(void){    
    int n,x,i,j,k,count=0;

    while(scanf("%d %d", &n,&x)){
        if(n==0 && x==0)
        break;
        for(i=1;i<=n-1;i++){
            for(j=i+1;j<n;j++){
                for(k=j+1;k<n+1;k++){
                    if((i+j+k)==x)
                        count++;
                }
            }
        }
    printf("%d\n",count);
    count=0;
    }
    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
typedef long long ll;

int main()
{
	int A, B;
	int num;
	int ans = 0;

	cin >> A >> B;

	rep1(i, 1, 9) {
		rep(j, 10) {
			rep(k, 10) {
				num = i * 10000 + j * 1000 + k * 100 + j * 10 + i;
				if (num >= A && num <= B) ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

bool check (string s){
    if(s.at(0)!='A')
        return false;
    int cnt = 0;
    for (int i = 2; i < s.length() - 1; i++){
        if(s.at(i)=='C'){
            cnt++;
        }
    }
    if(cnt!=1)
        return false;
    int upper = 0;
    for (int i = 0; i < s.length(); i++){
        if (s.at(i) >= 'A' && s.at(i) <= 'Z'){
            upper++;
        }
    }
    if(upper !=2) return false;
    return true;
}

int main(){
    string s;
    cin >> s;
    if(check(s)){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
        return 0;
}

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

class Program
{
  static void Main(string[] args)
  {
    var N = Int32.Parse(Console.ReadLine());
    var taLine = Console.ReadLine().Split(' ').Select(s => Int64.Parse(s)).ToArray();
    var T = taLine[0];
    var A = taLine[1];
    var Hs = Console.ReadLine().Split(' ').Select(s => Int64.Parse(s)).ToArray();

    var minDiff = Double.MaxValue;
    var minDiffPos = -1;
    for (var i = 0; i < Hs.Length; i++)
    {
      var H = Hs[i];

      var value = T - H * 0.006;
      var diff = Math.Abs(A - value);
      if (diff < minDiff)
      {
        minDiff = diff;
        minDiffPos = i + 1;
      }
    }

    Console.WriteLine(minDiffPos);
  }
}


Measured memory_bytes: 13328
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int H, W, V;
	cin >> H >> W;
	V = W * H;
	vector<vector<int>> weight(V, vector<int>(V, INF));
	vector<string> s(H);
	rep(i, 0, H) {
		cin >> s[i];
	}
	const int dx[4] = { 1, -1, 0, 0 }, dy[4] = {0, 0, 1, -1};
	rep(y, 0, H) {
		rep(x, 0, W) {
			weight[y * W + x][y * W + x] = 0;
			if (s[y][x] == '#')continue;
			rep(i, 0, 4) {
				int tx = x + dx[i], ty = y + dy[i];
				if (0 <= tx && tx <= W - 1 && 0 <= ty && ty <= H - 1 && s[ty][tx] == '.') {
					weight[ty * W + tx][y * W + x] = 1;
					weight[y * W + x][ty * W + tx] = 1;
				}
			}
		}
	}
	rep(k, 0, V) {
		rep(s, 0, V) {
			if (weight[s][k] == INF)continue;
			rep(e, 0, V) {
				if (weight[k][e] == INF)continue;
				weight[s][e] = min(weight[s][e], weight[s][k] + weight[k][e]);
			}
		}
	}
	int M = 0;
	rep(s, 0, V) {
		rep(e, 0, V) {
			if (weight[s][e] == INF)continue;
			M = max(M, weight[s][e]);
		}
	}
	printf("%d\n", M);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long 
using namespace std;

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

  
  int ans = N/11*2;
  if( N%11 > 0 && N%11 <= 6 ) ans++;
  else if( N%11 > 6 ) ans+= 2;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, C;
int main () {
  cin >> N >> C;
  vector<vector<pair<int,int>>> tr(C + 1);
  for(int i = 0; i < N; ++i) {
    int s, t, c;
    cin >> s >> t >> c;
    s *= 2;
    t *= 2;
    tr[c].push_back({s - 1, t});
  }
  vector<pair<int,int>> tot;
  
  map<int,int> aug;
  for(int i = 1; i <= C; ++i) {
    vector<pair<int,int>> nv;
    sort(tr[i].begin(), tr[i].end());
    for(auto p: tr[i]) {
      if (nv.size() == 0 || nv.back().second < p.first) {
        nv.push_back(p);
      } else {
        nv.back().second = max(nv.back().second, p.second);
      }
    }
    for(auto p: nv) {
      // cout << i << ' ' << p.first << ' ' << p.second << endl;
      aug[p.first]++;
      aug[p.second]--;
    }
  }

  int val = 0;
  int ret = 0;
  for(auto it = aug.begin(); it != aug.end(); ++it) {
    // cout << it->first << ' ' << it->second << endl;
    val += it->second;
    ret = max(ret, val);
  }
  cout << ret << endl;


}

Measured memory_bytes: 7424
N = int(input())
arr = sorted(list(map(int, input().split())), reverse=True)
alice_total, bob_total = 0, 0

for i in range(len(arr)):
    if i % 2 == 0:
        alice_total += arr[i]
    else:
        bob_total += arr[i]
print(alice_total - bob_total)


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n, m;
inline bool ok(li x) {
    if (m % x != 0) {
        return false;
    }
    if (m / x < n) {
        return false;
    }
    return true;
}


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

    li res = 1;
    for (li i = m / n; i > 1; --i) {
        if (m % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define inf (1<<29)
using namespace std;

typedef vector<pair<int, int> > vpii;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool isSame(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }

};


int main() {
  int N, M;
  int a, b, c;
  while(1) {
    cin >> N >> M;
    if(N == 0 && M == 0)
      break;
    vpii hlist(N);
    vector<pair<int, pair<int, int> > > edges(M);
    bool used[200];
    int h;
    int count = 0;
    UnionFind *uf = new UnionFind(N);
    rep(i, N) {
      cin >> h;
      hlist[i] = make_pair(h, i);
      used[i] = false;
    }
    sort(hlist.begin(), hlist.end());
    reverse(hlist.begin(), hlist.end());
    rep(i, M) {
      cin >> a >> b >> c;
      edges[i] = make_pair(c, make_pair(a - 1, b - 1));
    }
    sort(edges.begin(), edges.end());
    rep(i, N) {
      used[hlist[i].second] = true;
      if(i < N - 1 && hlist[i].first == hlist[i+1].first) {
        continue;
      }
      rep(j, M) {
        a = edges[j].second.first;
        b = edges[j].second.second;
        if(used[a] && used[b] && !uf->isSame(a, b)) {
            uf->unite(a, b);
            count += edges[j].first;
        }
      }
      rep(j, N) {
        if(used[j] && uf->size(j)  != i + 1) {
          delete uf;
          uf = new UnionFind(N);
          count = 0;
          break;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1460