akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    int N;
    cin >> N;
    double jpy = 0;
    double btc = 0;
    rep(i, 0, N) {
        double a;
        string s;
        cin >> a;
        cin >> s;
        if (s == "JPY") {
            jpy += a;
        } else {
            btc += a;
        }
    }
    cout << fixed << setprecision(6);
    cout << (jpy + (380000.0*btc)) << endl;
    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;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    string s; cin >> s;
    int n = s.size() + 1;
    vector<int> a(n, 0);
    
    rep(i, n-1) {
        if (s[i] == '<') {
            a[i+1] = a[i] + 1;
        }
    }
    for (int i = n-2; i >= 0; i--) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i+1] + 1);
        }
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


    


Measured memory_bytes: 2820
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int x,a,b;
    while(~scanf("%d%d%d",&x,&a,&b))
    {
        if(abs(x-a)<abs(x-b))
            printf("A\n");
        else
            printf("B\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m; cin>>n>>m;
    vi v(n);
    vi maxi(n,0);
    vi u(m);
    rep(i,n)cin>>v[i];
    rep(i,m)cin>>u[i];
    rep(i,m){
        for(int j=0;j<n; j++){
            if(v[j]<=u[i]){
                maxi[j]++;
                break;
            }
        }
    }
    int ans=0;
    int hoge= -INF;
    rep(i,n){
        if(hoge<maxi[i]){
            hoge=maxi[i];
            ans=i+1;
        }
    }
    //rep(i,n)cout<<i<<" "<<maxi[i]<<endl;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3124
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main(){
  int X;
  cin>>X;
  
  for(int i=-sqrt(sqrt(X))-10;i<sqrt(sqrt(X))+10;i++){
    for(int j=-sqrt(sqrt(X))-10;j<sqrt(sqrt(X))+10;j++){
      if(pow(i,5)-pow(j,5)==X){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
    
  
  
}

Measured memory_bytes: 3940
public class Hello {
    public static void Main(){
        // 1行に複数の入力値がある場合の例
        string [] inputs = System.Console.ReadLine().Split(' ');
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int c = (a * b);
        int d = (a + b) * 2;
        System.Console.WriteLine(c + " " + d);
    }
}



Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1000000000 + 7;
unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod) {
   unsigned long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v,unsigned long long mod) {
  //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
    }
  }
}



int main() {
  unsigned long long N, K;
 
  cin >> N >> K;
  unsigned long long C=0;
  unsigned long long Ci=0;
  vector<vector<long long int> > v(N + 1, vector<long long int>(N + 1, 0));
  comb(v,mod);
  for(int i=1;i<K+1;i++){
    C=v[K-1][i-1]%mod;
    Ci=v[N-K+1][i]%mod;
    cout<<C*Ci%mod<<endl;
  }
  
  //modinv(N, mod,inv);
    
  return 0;
}


Measured memory_bytes: 31616
R, G, B, N = map(int, input().split())
ans = 0
zi = N // B
ans = 0
for b in range(zi + 1):
    y = (N - B * b)
    gi = y // G
    for g in range(gi + 1):
        x = y - G * g
        if x % R == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef unsigned long long int ulld;

//const lld mod = 1e9+7;
//const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	ulld x,y;

	cin >> x >> y;
	string sol;

	if (x > y)
	{
		ulld temp = x;
		x = y;
		y = temp;
	}

	if (x == y)
	{
		sol = "Brown";
	}else if (y - x == 1)
	{
		sol = "Brown";
	}else if (x == 0)
	{
		sol = "Alice";
	}else
	{
		sol = "Alice";
		// if ((x%2 + y%2)%2 == 0)
		// {
		// 	sol = "Alice";
		// }else
		// {
		// 	sol = "Brown";
		// }
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        String s = sc.next();
        
        int count=0;
        
        for(int i = 0; i < n-2;i++){
            if(s.substring(i,i+3).equals("ABC")){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
ll f[N],size[N];
ll find(ll x) 
{
	if(f[x]==x) return x;
	else return f[x]=find(f[x]);
}
void merge(ll a,ll b)
{
	ll fa=find(a);
	ll fb=find(b);
	if(fa!=fb) f[fa]=fb;
}
int main()
{
  
  ll  n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
  f[i]=i;
  for(int i=0;i<m;i++)
  {
  	 int a,b;
  	 cin>>a>>b;
  	 merge(a,b);
  }
  ll ans=0;
  for(int i=1;i<=n;i++)
  {
  	if(find(i)==i) ans++;
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int H,W,N; cin >> H >> W >> N;
	if(H>=W){
		for(int i = 1; i <= W; ++i){
			corner(i*H>=N,i);
		}
	}
	else{
		for(int i = 1; i <= H; ++i){
			corner(i*W>=N,i);
		}
	}


    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ll n , m  , k, x;
    vector<ll>v1 , v2;
    cin >> n >> m >> k;
    for(ll i = 0 ; i < n ;i++)
    {
        cin >> x;
        if(i==0)
            v1.push_back(x);
        else
        {
            v1.push_back(v1[i-1]+x);
        }
    }
    ll ans=0;
    for(ll i = 0 ; i < m ;i++)
    {
        cin >> x;
        if(i==0)
            v2.push_back(x);
        else
        {
            v2.push_back(v2[i-1]+x);
        }
        x=upper_bound(v1.begin(),v1.end(), k-v2[i] )-v1.begin()-1;
        if(v2[i]<=k)
        {
            ans=max(ans , x+1+i+1 );
        }
        else break;
    }
    for(ll i = 0 ; i < n ;i++)
    {
        x=upper_bound(v2.begin(),v2.end(), k-v1[i] )-v2.begin()-1;
        if(v1[i]<=k)
        {
            ans=max(ans , x+1+i+1 );
        }
        else break;
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 7992
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで


using namespace std;
int c[10];
int a1,a2,a3,b1,b2,b3;

int main(){
  string ans = "Yes";
  FOR(i,9)cin >> c[i];
  a1 = 0;
  b1 = c[1];
  b2 = c[2];
  b3 = c[3];
  a2 = c[4]-b1;
  a3 = c[7] -b1;
  if(c[5]!=b2+a2||c[6]!=a2+b3||c[8]!=a3+b2||c[9]!=a3+b3) ans = "No";
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <functional>
#include <cmath>
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 1e5 + 4;

int A, B, a[MAX], b[MAX], M, mn1 = 2e5, mn2=2e5;

int main() {
	FAST; cin >> A >> B >> M;
	for (int i = 1; i <= A; i++) {
		cin >> a[i];
		mn1 = min(mn1, a[i]);
	}
	for (int i = 1; i <= B; i++) {
		cin >> b[i];
		mn2 = min(mn2, b[i]);
	}
	int ans = mn1 + mn2;

	for (int i = 0, u, v,w; i < M; i++) {
		cin >> u >> v >>w;
		ans = min(ans, a[u] + b[v] - w);
	}
	cout << ans << '\n';
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x = d - b;
    int y = c - a;
    printf("%d %d %d %d",c-x,d+y,a-x,b+y);
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
int sex[100000];
bool check(int l, int r) {
	int len = r - l + 1;
	if (len % 2) {
		return sex[l] != sex[r];
	} else {
		return sex[l] == sex[r];
	}
}
int main() {
	int N;
	cin >> N;
	string ans;
	cout << 0 << endl;
	cin >> ans;
	if (ans == "Vacant") {
		return 0;
	} else if (ans == "Male") {
		sex[0] = 1;
	}
	cout << N - 1 << endl;
	cin >> ans;
	if (ans == "Vacant") {
		return 0;
	} else if (ans == "Male") {
		sex[N - 1] = 1;
	}
	int l = 0, r = N - 1;
	while (r - l >= 4) {
		int m = (l + r) / 2;
		cout << m << endl;
		cin >> ans;
		if (ans == "Vacant") {
			return 0;
		} else if (ans == "Male") {
			sex[m] = 1;
		}
		int len = r - l + 1;
		sex[m - 1] = sex[m + 1] = !sex[m];
		if (check(l, m - 1)) {
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	for (int i = l; i <= r; i++) {
		cout << i << endl;
		cin >> ans;
		if (ans == "Vacant") return 0;
	}
}

Measured memory_bytes: 852
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, x, a[N];


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    cin>>x>>n;
    foo(i,1,n){
        cin>>a[i];
        vis[a[i]]=1;
    }
    ll res =INF, ans=INF;
    foo(i,-100,200){
        if(vis[i]==0) 
            res=min(res, abs(x-i));
    }
    foo(i,-100,200){
        if(vis[i]==0 && abs(x-i)==res){
            cout<<i;
            break;
        }
    }


}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8348
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int cnt=0,cnt2=0;
  bool b=false;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    b=true;
  }
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C') cnt2++;
  }
  if(!b && cnt2!=1){
    cout<<"WA"<<endl;
    b=true;
  }
  for(int i=0;i<s.size();i++){
    if(s[i]>=97 && s[i]<=122) cnt++;
  }
  if(!b && cnt!=s.size()-2) cout<<"WA"<<endl;
  else if(!b) cout<<"AC"<<endl;



  return 0;
}


Measured memory_bytes: 256
indices = Hash.new

readlines.each do |l|
	word, page = l.chomp.split
	if indices.has_key?(word)
		indices[word] << page.to_i
	else
		indices[word] = [page.to_i]
	end
end

indices.sort.each do |word,pages| 
	puts word
	puts pages.sort.join(' ')
end

Measured memory_bytes: 6096
N,M=map(int,input().split())
import sys
S=sys.stdin.readlines()
A=set()
WA=[0]*N
B=[0]*N
for i in range(M):
  p,t=S[i].split()
  p=int(p)
  if p not in A and t=="AC":
    A.add(p)
    B[p-1]+=WA[p-1]
  elif p not in A and t=="WA":
    WA[p-1]+=1
print(len(A))
print(sum(B))

Measured memory_bytes: 26104
W, H, N = map(int, input().split())
D = [0, W, 0, H]
#D={0:max 1:min 2:max 3:min}

for _ in range(N):
    x, y, a = map(int, input().split())
    if a==1:
        if x > D[0]:
            D[0] = x
    if a==2:
        if x < D[1]:
            D[1] = x
    if a==3:
        if y > D[2]:
            D[2] = y
    if a==4:
        if y < D[3]:
            D[3] = y
ANS = (D[1] - D[0])*(D[3] - D[2])
if (D[1] - D[0] < 0) | (D[3] - D[2] < 0):
    ANS = 0
print(ANS)

Measured memory_bytes: 3064
program ABC075B
    implicit none
    integer(8)::H,W,i,j,k
    integer(8),allocatable,dimension(:,:)::O
    integer(8),dimension(8)::dx=(/-1,0,1,-1,1,-1,0,1/)
    integer(8),dimension(8)::dy=(/-1,-1,-1,0,0,1,1,1/)
    character(50)::S
    read(5,*)H,W
    allocate(O(W,H))
    O=0

    do i=1,H
        read(5,*)S
        do j=1,W
            if(S(j:j)=='#')then
                O(j,i)=-1
                do k=1,8
                    if(j+dx(k)>=1 .and. j+dx(k)<=W .and. i+dy(k)>=1 .and. i+dy(k)<=H .and. O(j+dx(k),i+dy(k))/=-1)then
                        O(j+dx(k),i+dy(k))=O(j+dx(k),i+dy(k))+1
                    end if
                end do
            end if
        end do
    end do

    do i=1,H
        do j=1,W
            if(O(j,i)==-1)then
                write(*,fmt='(a)',advance='no') "#"
            else
                write(*,fmt='(i0)',advance='no') O(j,i)
            end if
        end do
        write(*,fmt='(a)') ""
    end do

end program ABC075B

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

ll solve() {
    ll N;
    cin >> N;
    ll a;
    deque<ll> q;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        if ( i & 1 ) q.push_front(a);
        else q.push_back(a);
    }
    for ( int i = 0; i < N; i++ ) {
        int j = i;
        if ( N & 1 ) j = N - 1 - i;
        cout << q[j] << " ";
    }
    cout << "\n";
    return 0;
}

int main() {
    solve();
    return 0;
}

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

main(){
     ios_base::sync_with_stdio(false);
     cin.tie(nullptr);
     int N, K; string s;
     cin >> K >> s; N = s.size();
     if(N <= K){
          cout << s;
     } else{
          cout << s.substr(0, K) + "...";
     }
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		for (int i=A;i<=B;i++) {
			if (i%K == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}

Measured memory_bytes: 35784
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a[200005];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] = a[i] - (i + 1);
	}
	sort(a, a + n);
	int memo = a[n / 2], ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(memo - a[i]);
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void){
  char s[128];
  int k, ans;
  cin >> s >> k;
  
  ans = 1;
  for (int i=0; i<k; i++){
    int cn;
    cn = s[i]-'0';
    if (cn!=1){
      ans = cn;
      break;
    }
  }
  cout << ans << endl;
  
  return 0;
}
  

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

map<int,int> m1; //A^-1

int main(){
    int N; cin >> N;
    int P[200200];
    for(int i=0; i<N; i++){
        cin >> P[i+1];
        m1[P[i+1]]=i+1;
    }

    int num_left[200200], num_right[200200]; 
    num_left[1]=0; num_right[N]=0;
    for(int i=2; i<=N; i++){
        if(m1[i] > m1[i-1]) num_left[i] = num_left[i-1]+1;
        else num_left[i] = 0;
    }
    for(int i=N-1; i>=1; i--){
        if(m1[i] < m1[i+1]) num_right[i] = num_right[i+1]+1;
        else num_right[i]=0;
    }
    int ans=N;
    for(int i=1; i<=N; i++){ //大きさiのものをfixする
        ans = min(ans, N-1-num_left[i]-num_right[i]);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 11904
n,m,x,y=map(int,input().split())
X= list(map(int,input().split()))
Y= list(map(int,input().split()))
maxx = max(X)
miny = min(Y)
frag = 0
for i in range(x+1,y+1):
    if i >maxx and i <=miny :
        frag = 1
        break
if frag == 1:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll froms[100005],fromt[100005],disfroms[100005],disfromt[100005],p=1e9+7;
vector<pair<int,ll> >adj[100005];
int n,m,s,t;
int main(){
    cin>>n>>m>>s>>t;
    for(int i=0;i<m;++i){
        int u,v,d;
        scanf("%d%d%d",&u,&v,&d);
        adj[u].push_back({v,d});
        adj[v].push_back({u,d});
    }
    priority_queue<pair<ll,int> >pq;
    memset(disfroms,-1,sizeof disfroms);
    disfroms[s]=0;
    pq.push({0,s});
    froms[s]=1;
    while(!pq.empty()){
        int x=pq.top().second;ll w=-pq.top().first;
        pq.pop();
        if(disfroms[x]<w)continue;
        froms[x]%=p;
        for(auto y:adj[x]){
            int nxt=y.first;ll nw=w+y.second;
            if(disfroms[nxt]==-1||disfroms[nxt]>nw){
                disfroms[nxt]=nw;
                froms[nxt]=froms[x];
                pq.push({-nw,nxt});
                continue;
            }
            if(disfroms[nxt]<nw)continue;
            froms[nxt]+=froms[x];
            froms[nxt]%=p;
        }
    }

    memset(disfromt,-1,sizeof disfromt);
    disfromt[t]=0;
    pq.push({0,t});
    fromt[t]=1;
    while(!pq.empty()){
        int x=pq.top().second;ll w=-pq.top().first;
        pq.pop();
        if(disfromt[x]<w)continue;
        fromt[x]%=p;
        for(auto y:adj[x]){
            int nxt=y.first;ll nw=w+y.second;
            if(disfromt[nxt]==-1||disfromt[nxt]>nw){
                disfromt[nxt]=nw;
                fromt[nxt]=fromt[x];
                pq.push({-nw,nxt});
                continue;
            }
            if(disfromt[nxt]<nw)continue;
            fromt[nxt]+=fromt[x];
            fromt[nxt]%=p;
        }
    }

    long long ans=froms[t]*froms[t];
    ans%=p;
//    cout<<ans<<endl;
    for(int i=1;i<=n;++i){
        froms[i]%=p;
        fromt[i]%=p;
        if(disfroms[i]+disfromt[i]!=disfroms[t])continue;
        if(2*disfroms[i]!=disfroms[t])continue;
        ans%=p;if(ans<0)ans+=p;
        ans-=(((froms[i]*froms[i])%p)*((fromt[i]*fromt[i])%p))%p;
        if(ans<0)ans+=p;
    }
//    cout<<ans<<endl;
    for(int i=1;i<=n;++i){
        for(auto x:adj[i]){
            int j=x.first;ll d=x.second;
            if(disfroms[i]+disfromt[j]+d!=disfroms[t])continue;
//            cout<<i<<" "<<j<<endl;
            if(disfromt[j]<disfroms[j]&&disfroms[i]<disfromt[i]){
                ans%=p;if(ans<0)ans+=p;
                ans-=(((froms[i]*froms[i])%p)*((fromt[j]*fromt[j])%p))%p;
                if(ans<0)ans+=p;
            }
        }
    }
    cout<<ans<<endl;

}


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

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

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if(s=="RRR") cout << "3" << "\n";
    else if(s=="RRS"||s=="SRR") cout << "2" << "\n";
    else if(s=="SSS") cout << "0" << "\n";
    else cout << "1" << "\n";
    return 0;
}

Measured memory_bytes: 3532
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
			int a =sc.nextInt();
			int b =sc.nextInt();
			int c =sc.nextInt();
						
			int d;
			d=100*a+10*b+c;
			
			if(d%4==0){
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
}

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

void solve(void)
{
  int N;
  cin >> N;
  vector<int> vec(N, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> vec[i];
  }
  auto d0 = divisor(vec[0]);
  auto d1 = divisor(vec[1]);
  map<int, int> mp;
  vector<int> l;
  for (auto &&x : d0)
  {
    mp[x]++;
  }
  for (auto &&x : d1)
  {
    mp[x]++;
  }
  for (auto &&x : mp)
  {
    l.push_back(x.first);
  }
  for (int i = 2; i < N; i++)
  {
    // auto d = divisor(vec[i]);
    // for (auto &&x : mp)
    // {
    //   if (find(ALL(d), x.first) != d.end())
    //   {
    //     x.second++;
    //   }
    // }
    int V = vec[i];
    for (auto &&x : mp)
    {
      if(V%x.first == 0)
      x.second++;
    }
    
  }

  int res = 1;
  for (auto &&x : mp)
  {
    if (x.second >= N - 1)
    {
      chmax(res, x.first);
    }
  }
  cout << res << endl;

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();
		System.out.println(process(n, a, b));
	}

	private static long process(long n, long a, long b) {
		long diff = b - a;
		if (diff % 2 == 0) {
			return diff / 2;
		}
		long stepToBorder = Math.min(a - 1, n - b);
		return stepToBorder + 1 + (diff - 1) / 2;
	}
}


Measured memory_bytes: 23124
n = input()
ans = 1
s = list(map(int, input().strip().split()))
if 0 in s:
    print(0)
    exit()
for i in s:
    if ans>10**18:
        print(-1)
        exit()
    ans = ans*i

if ans>10**18:
        print(-1)
        exit()
        
print(ans)

Measured memory_bytes: 21632
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let (n, t): (usize, usize) = read();
    let a: Vec<i32> = readnc();

    let mut best = 0;
    let mut min_price = 1000000000;
    for i in 0..n {
        let profit = a[i] - min_price;
        best = max(best, profit);
        min_price = min(min_price, a[i]);
    }

    let mut ans = 0;
    let mut head = 0;
    while head < n {
        let mut min_price = a[head];
        let mut min_price_count = 0;
        let mut max_price_count = 0;
        while head < n && min_price <= a[head] {
            if a[head] == min_price {
                min_price_count += 1;
            }
            if a[head] == min_price + best {
                max_price_count += 1;
            }
            head += 1;
        }
        ans += min(min_price_count, max_price_count);
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		double denominator = 0;
		for ( int i = 0; i < n; i++ ) {
			double temp = (double)in.nextInt();
			denominator += 1.0/temp;
		}
		
		System.out.println(1.0/denominator);

		in.close();
	}
}

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

int main(){
    ll N; cin >> N;
    string S = "";
    while(N > 0){
        ll rem = N % 26;
        if(rem == 0) rem = 26;
        char ch = rem + 96;
        S += ch;
        N = (N-rem)/26;
    }
    reverse(S.begin(), S.end());
    cout << S << endl;
}

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

int main()
{
    int i, j, k;
    int n, t, m;
    int h , w;
    cin >> n >> m;
    int ans = 0;
    if(n >= 2) {
        ans += n*(n-1)/2;
    }
    if(m >= 2) {
        ans += m*(m-1)/2;
    }
    cout << ans <<endl;
    return 0;
}


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

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

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

int main(){
  int N; cin >> N;
  int ans = 0;
  int num_A = 0;
  int num_B = 0;
  int num_AB = 0;
  rep(i, N){
    string s; cin >> s;
    rep(j, s.size()-1){
      if (s[j] == 'A' && s[j+1] == 'B')ans++;
    }
    if (s[0] == 'B') num_B++;
    if (s[s.size()-1] == 'A') num_A++;
    if (s[0] == 'B' && s[s.size()-1] == 'A') num_AB++;
  }
  int sub;
  if (num_A <= num_AB && num_B <= num_AB && num_AB > 0)sub = 1;
  else sub = 0;
  cout << ans + min(num_A, num_B)-sub << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if (flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a,d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n;
    inputv(A, n);
    inputv(B, n);

    bitset<33> b[MAX_N],c[MAX_N];
    rep(i, n) {
        b[i] = bitset<33>(A[i]);
        c[i] = bitset<33>(B[i]);
    }

    vl C;
    ll kuri = 0;

    rep(i, 31) {
        a = 0;
      p=0;
      q=0;
        rep(j, n) {
            p+= (b[j][i] ? 1 : 0);
            q += (c[j][i] ? 1 : 0);
        }
        a = n*(p+q) + kuri;
        ans += abs(a % 2) * (1 << i);

        kuri = 0;
      C.clear();

        rep(j, n) {
            C.push_back( A[j]%(1<<(i+1)));
        }

        sort(all(C));
      

        rep(j, n) {
            kuri += lower_bound(all(C), (1<<(i+1))-(B[j])%(1<<(i+1)))-C.begin();
        }
      kuri=n-kuri;
    }

    cout << ans << endl;
}


Measured memory_bytes: 14192
def main():
    import itertools
    n,m,q = map(int,input().split(" "))
    ops = []
    for i in range(q):
        ops.append(list(map(int,input().split(" "))))
    
    ans = 0
    for A in itertools.combinations_with_replacement(range(1,m+1),n):
        temp = 0
        for op in ops:
            if A[op[1]-1] - A[op[0]-1] == op[2]:
                temp+=op[3]
        ans = max(ans,temp)
    
    print(ans)
main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a, b;
    cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000000
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
typedef long long int lli;
using namespace std;

int main()
{
  int N;
  int Cx,Cy;
  int H;

  int flag_notinit;
  int flag_determined = 0;
  
  int upb;
  
  

  scanf("%d",&N);


  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);

  REP(i,N)
    {

      scanf("%d%d%d",&x[i],&y[i],&h[i]);

    }
  
  for( Cx = 0 ; Cx <= 100 ; ++ Cx )
    {

      for( Cy = 0 ; Cy <= 100 ; ++ Cy )
	{

	  flag_notinit = 1;
	  upb = INF + 201;
	  
	  REP(i,N)
	    {
	      if( flag_notinit )
		{

		  if( h[i] == 0 )
		    {
		      if( upb > abs(x[i] - Cx) + abs(y[i] - Cy) )
			{
			  upb = abs(x[i] - Cx) + abs(y[i] - Cy);
			  
			}
		    }
		  else
		    {
		      H = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy);
		      flag_notinit = 0;

		      if( H > upb )
			{
			  break;
			  
			}
		      
		    }
		  
		}
	      else
		{
		  
		  if( h[i] != max( H - abs(x[i] - Cx) - abs(y[i] - Cy) , 0 ) )
		    {
		      break;
		      
		    }

		  if( i == N - 1 )
		    {

		      printf("%d %d %d\n",Cx,Cy,H);
		      flag_determined = 1;
		      break;
		      
		      
		  
		    }
	      

	      
		}
	  

	  
	  
	    }

	  if(flag_determined)
	    {
	      break;
	      
	    }

	}


      if(flag_determined)
	{
	  break;
	  
	}

    }


  
}



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

int n, p[50];

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> p[i];
  
  int cnt = 0;
  for(int i=0;i<n;i++) if (p[i] != i+1) cnt++;
  
  cout << (cnt<=2 ? "YES" : "NO") << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N = 1e6 + 700;
const int mod = 1e9 + 7;
int a , b , k , n;
string lim;
int dp[10005][101][2];

int cntDigit(int n){
  if(!n) return 0;
  return 1 + cntDigit(n / 10);
}

int add(int x , int y){
  return ((x % mod) + (y % mod)) % mod;
}
int sub(int x , int y){
  return ((x % mod) - (y % mod) + mod) % mod;
}
int solve(int i , int mod , int flag){
  if(i == n) {
    if(!mod) return 1 ;
    return 0;
  }
  if(dp[i][mod][flag] != -1) return dp[i][mod][flag] ;
  int ans = 0;
  int limit = 9;
  if(!flag){
    limit = lim[i] - '0';
  }
  for(int j = 0 ; j <= limit ; j++){
    int f1 = flag;
    if(!f1 and j < limit) f1 = 1;
    ans = add(ans ,solve(i + 1 , (mod + j) % k , f1));
  }
  dp[i][mod][flag] = ans;
  return ans;
}
 
int32_t main() {    
 L_T_S_K;
 int t = 1; 
// cin >> t;
 while(t--){
  cin >> lim >> k;
  memset(dp , -1 , sizeof dp);
  n = lim.size();
  int p = solve(0 , 0 , 0);
  cout << sub(p , 1) << "\n"; 
 } 
  return 0;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t = 0;
  int h = 0;
  for (int i = 0; i < n; i++){
    string T;
    string H;
    cin >> T >> H;
    if (T > H){
      t += 3;
    } else if (T < H){
      h += 3;
    } else {
      t++;
      h++;
    }
  }
  cout << t << ' ' << h << endl;
}


Measured memory_bytes: 3204
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String A = sc.next();
		String B = sc.next();
		if(A.charAt(0)==B.charAt(2) &&A.charAt(1)==B.charAt(1) &&A.charAt(2)==B.charAt(0))
			System.out.println("YES");
		else
			System.out.println("NO");

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22996
d = []
5.times do
  d << gets.to_i
end

dsum = []
5.times do |i|
  sum = d[i]
  dc = d.dup
  dc.slice!(i)
  dc.each do |data|
    n = data / 10 * 10
    n += 10 if data % 10 != 0
    sum += n
  end
  dsum << sum
end

puts dsum.min

Measured memory_bytes: 1788
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;
typedef pair<int, int> P;

/** Problem2197 : Sum of Consecutive Integers **/
int main()
{
	int N;
	while (cin>>N, N) {
		int ans=0, sum;
		REP(i, 1, 1000) {
			sum=i;
			REP(j, i+1, 1000) {
				sum += j;
				if (sum == N) {
					ans++;
					break;
				} else if (sum > N)
					break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
 using namespace std;
 int main(){
     char b;
     cin>>b;
     if(b=='A')cout<<'T'<<endl;
     else if(b=='G')cout<<'C'<<endl;
     else if(b=='T')cout<<'A'<<endl;
     else cout<<'G'<<endl;
 }

Measured memory_bytes: 256
<?php
list($N, $X, $Y) = ints();
createG($N);
for($i = 1; $i <= $N-1; $i++)connect2($i, $i+1);
connect2($X, $Y);
$dMap = array_fill(1, $N-1, 0);
for($i = 1; $i <= $N; $i++)
  foreach(bfs($i) as $d)
    if(isset($dMap[$d]))
      $dMap[$d]+=0.5;
echo implode("\n", $dMap);

function connect2($a, $b){global $G;$G[$a][] = $b;$G[$b][] = $a;}
function connect($a, $b){global $G;$G[$a][] = $b;}
function createG($n){
  global $G, $distance;
  $distance = array_fill(1, $n, PHP_INT_MAX);
  $G = array_fill(1, $n, []);
}
function bfs($current, $G = false){
  if($G === false)$G = $GLOBALS['G'];
  $distance = array_fill(1, count($G), PHP_INT_MAX);
  if(!is_array($current))$current = [$current];
  foreach($current as $c)$distance[$c] = 0;
  for($dist = 1; $current; $dist++){
    $nextArray = [];
    foreach($current as $c){
      foreach($G[$c] as $next){
        if($distance[$next] == PHP_INT_MAX){
          $distance[$next] = $dist;
          $nextArray[] = $next;
        }
      }
    }
    $current = $nextArray;
  }
  return $distance;
}

function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}


Measured memory_bytes: 5112