akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
// #define DEBUG 100
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll >;
 
const ll oo = 1e18 + 7;
const ll mod = 1e9 + 7,maxn = 1e5 + 100, maxm = 1e5+100;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    ll n, a, ans = 0;

    cin >> n;
    for (a=1; a<=n; a++){
        ans += (n-1)/a;
    }

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int A[2000000],H=0;
void maxH(int i){
	int l=2*i,r=2*i+1,big;
	if(l<=H && A[l]>A[i]) big = l;
	else big = i;
	if(r<=H && A[r]>A[big]) big = r;
	if(big!=i){
		swap(A[i],A[big]);
		maxH(big);
	}
}
void insert(int key){
	int i = ++H;
	A[H] = key;
	while(i>1 && A[i/2]<A[i]){
		swap(A[i],A[i/2]);
		i /= 2;
	}
}
int ex(){
	int max = A[1];
	A[1] = A[H];
	H--;
	maxH(1);
	return max;
}
int main()
{
	char cmd[10];
	int key;
	while(scanf("%s",cmd)){
		if(cmd[2]=='d') break;
		if(cmd[0]=='i'){
			scanf("%d",&key);
			insert(key);
		}
		else printf("%d\n",ex());
	}
	return 0;
}



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

int main(){
  int a,b;
  cin >> a>>b;
  string s;
  cin >>s;
  if(s.size() != a+b+1){
    cout <<"No" << endl;
    return 0;
  }
  for(int i=0;i < a;i++){
    if(s.at(i) == '-'){
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i=a+1;i < a+b+1;i++){
    if(s.at(i) == '-'){
      cout << "No" << endl;
        return 0;
    }
  }
  if(s.at(a) !='-'){
     cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    int mx = 0, mn = INF;
    rep(i,n) {
        int a;
        cin >> a;
        mx = max(mx, a);
        mn = min(mn, a);
    }
    int ans = mx - mn;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3524
a, b, c, x, y = map(int, input().split())
resa = a*x + b*y
resb = min(x,y)*c*2 + a*(x-min(x,y)) + b*(y-(min(x,y)))
resc = max(x,y)*2 * c
print (min(resa, resb, resc))

Measured memory_bytes: 3060
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    l=""
    for j in range(w):
        if s[i][j]=="#":
            l+="#"
        else:
            l+=str(sum([t[max(0,j-1):min(w,j+2)].count("#") for t in s[max(0,i-1):min(h,i+2)]]))
    print(l)
#コピペです。
  

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

using ll = long long;

const ll MOD = 1000000007;

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

    ll n, k;
    cin >> n >> k;

    vector<ll> vec(n);
    for (ll &x: vec) cin >> x;
    sort(vec.begin(), vec.end());

    ll mindiff = numeric_limits<ll>::max();
    for (int i = 0; i < n-k+1; ++i)
        mindiff = min(mindiff, vec[i+k-1]-vec[i]);

    cout << mindiff <<endl;

    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    int h,w,n;
    cin >> h >> w >> n;
    int k = max(h,w);
    cout << ((n + k - 1) /k) << endl;

}


Measured memory_bytes: 256
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X -(a+b)
            if c > b and c <= N:
                ans += 1
    print(ans)



Measured memory_bytes: 5592
n,m=map(int,input().split())
cs=[[i for i in map(int,input().split())] for j in range(m)]
if n==1:
   for i in range(10):
      tmp=str(i)
      flag = True
      for j in range(m):
         if tmp[cs[j][0]-1] != str(cs[j][1]):
            flag = False
      if flag == True:
         print(i)
         break
   else:
      print(-1)
else:
   for i in range(10**(n-1),10**n-1):
      tmp=str(i)
      flag = True
      for j in range(m):
         if tmp[cs[j][0]-1] != str(cs[j][1]):
            flag = False
      if flag == True:
         print(i)
         break
   else:
      print(-1)
      
         



Measured memory_bytes: 3064
// Problem : B - Strings with the Same Length
// Contest : AtCoder - AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    string a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++) cout<<a[i]<<b[i];
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a;
    cin >> a;
    long long time=0;
    long long sum = 100;
    // time = log(double(a/100.0))/log(1.01);
    while(sum < a){
        sum += sum/100;
        time++;
    }
    cout << time << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<complex>
#include<cmath>
#include<cstdio>
using namespace std;
typedef complex<double> P;
int main(){
	int n;
	double co,si,x,y,z;
	//co=z/x si=y/x
	//x=co*x-si*y
	//y=si*x+co*y

	while(cin>>n,n!=-1){
		n--;	P a=P(1,0);
		while(n-->0){
			z=sqrt(imag(a)*imag(a)+real(a)*real(a));
			x=sqrt(1+z*z);
			co=z/x;
			si=1/x;
			a=P(co*real(a)-si*imag(a),si*real(a)+co*imag(a));
			a/=abs(a);
			a*=x;
		}
		printf("%.2lf\n%.2lf\n",real(a),imag(a));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#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 REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

int main() {
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    COUT(h2*60+m2-h1*60-m1-k);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int x, N;
	cin >> x >> N;
	vector<int> p(N);
	set<int> st;
	for (int i = 0; i < N; ++i) {
		cin >> p[i];
		st.insert(p[i]);
	}

	int ans = 1e8;
	int diff = 1e8;
	for (int i = -10; i <= 110; ++i) {
		if (st.count(i)) { continue; }
		int tmp = abs(i - x);
		if (tmp < diff) {
			ans = i;
			diff = tmp;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll exgcd(ll a,ll b,ll &x,ll &y) {
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	ll d=exgcd(b,a%b,y,x);
	y-=a/b*x;
	return d;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,x,y;
	cin>>a>>b;
	exgcd(a,b,x,y);
	cout<<x<<" "<<y<<endl;
}




Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, k;

    cin >> n >> k;

    ll dp[2019][2019];

    memset(dp, 0, sizeof(dp));

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

    for (int i = 1; i < n + 10; i++)
    {
        for (int j = 1; j < n + 10; j++)
        {
            (dp[i + 1][j] += dp[i][j]) %= MOD;
            (dp[i + 1][j + 1] += dp[i][j]) %= MOD;
        }
    }

    for (int i = 1; i <= k; i++)
    {
        ll res = 0;
        (res += dp[n - k][i]) %= MOD;
        (res += dp[n - k][i]) %= MOD;
        (res += dp[n - k][i - 1]) %= MOD;
        (res += dp[n - k][i + 1]) %= MOD;

        (res *= dp[k][i]) %= MOD;

        cout << res << endl;
    }

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  vector<int> b(n+1);
  for(int j=n;j>=1;j--){
    int sum = 0;
    for(int k=j+j;k<=n;k+=j){
      sum ^= b[k];
    }
    b[j] = sum^a[j];
  }
  vector<int> ans;
  for(int i=1;i<=n;i++){
    if(b[i]) ans.push_back(i);
  }
  
  cout << ans.size() << endl;
  
  rep(i,ans.size()){
    printf("%d%c",ans[i],i+1==ans.size()?'\n':' ');
  }
}
        


Measured memory_bytes: 3064
a = [list(map(int,input().split())) for i in range(3)]
if a[0][0]-a[1][0] == a[0][1]-a[1][1] == a[0][2]-a[1][2] and a[1][0]-a[2][0] == a[1][1]-a[2][1] == a[1][2]-a[2][2]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
	ios;
	int n,ans=0,x,i; 
	cin>>n;
	vector<ll> h(n);
	for(i=0;i<n;i++) cin>>h[i];
	x=0;
	for(i=n-2;i>-1;i--)
	{
		if(h[i]<h[i+1]) {
			ans=max(x,ans); x=0;}
		else x++;
	}
	ans=max(ans,x);
	cout<<ans;
	
	return 0;
}
 

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main()
{string S;
 cin >> S;
 reverse(S.begin(),S.end());
 //Sを逆順にソートした
 //文字列分割がわからない
 string divide[4] = {"maerd","remaerd","esare","resare"};
 bool big_flag = true;
 
 for(int i = 0; i < S.size(); )
 {bool flag = false;
   for(int j = 0; j < 4 ; j++)
    {if(S.substr(i,divide[j].size()) == divide[j])
    {flag = true;
    i += divide[j].size();}}
  if(!flag){big_flag = false;
           break;}}

if(big_flag){cout << "YES"<<endl;}
else{cout << "NO"<<endl;}

return 0;
}
 


Measured memory_bytes: 512
N, K, L = gets.split.map(&:to_i)

road = [*0..N]
road_r = Array.new(N + 1) { 1 }

rail = [*0..N]
rail_r = Array.new(N + 1) { 1 }

def root uf, i
  uf[i] == i ? i : uf[i] = root(uf, uf[i])
end

def set_union_find n, uf, rank
  n.times do
    x, y = gets.split.map(&:to_i)
    x = root(uf, x)
    y = root(uf, y)

    next if x == y

    if rank[x] > rank[y]
      uf[y] = x
    else
      uf[x] = y
      rank[y] += 1 if rank[x] == rank[y]
    end
  end
end

set_union_find K, road, road_r
set_union_find L, rail, rail_r

h = Hash.new {|h, k| h[k] = [] }
(1..N).each do |i|
  h[[root(road, i), root(rail, i)]] << i
end

result = Array.new(N + 1) { 0 }
h.values.each do |arr|
  arr.each do |j|
    result[j] = arr.size
  end
end

puts (1..N).map {|i| result[i] }.join(' ')

Measured memory_bytes: 50592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x,a, b, c;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
N, K, C = map(int, input().split())
S = input()

right, left = [0 for _ in range(N)], [0 for _ in range(N)]

cnt = 0
work = 0
while True:
    if work == K:
        break
    if S[cnt] != "x":
        right[cnt] += 1
        work += 1
        cnt += C+1
    else:
        cnt += 1

S = list(reversed(S))

cnt = 0
work = 0
while True:
    if work == K:
        break
    if S[cnt] != "x":
        left[cnt] += 1
        work += 1
        cnt += C+1
    else:
        cnt += 1

left.reverse()
# print(right)
# print(left)

cnt1 = 0
cnt2 = 0
for i in range(N):
    if right[i] == 1:
        cnt1 += 1
    if left[i] == 1:
        cnt2 += 1
    if right[i] == left[i] == 1 and cnt1 == cnt2:
        print(i+1)

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

using namespace std;

const int MOD = 1e9 + 7;


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

    unsigned long long r, d, x;
    cin >> r >> d >> x;
    for(int i = 0; i < 10; ++i) {
        x = r * x - d;
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(k) for k in input().split()]

#最小の分割数をdpで考える。
dp = (1, 1)#増減　増加
for i in range(1, N):
    if A[i] > A[i-1]:#大きいときは右側更新
        dp = min(dp)+1, min(dp[0]+1, dp[1])
    elif A[i] == A[i-1]:
        pass
    else:#小さいときは左側
        dp = min(dp[0], dp[1]+1), min(dp)+1
    #print(dp)
print(min(dp))

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' ||c == 'e' ||c == 'i' ||c == 'o' ||c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
 
  return 0;
  }


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100000];
    scanf("%s",s);
    long int len=strlen(s);
    long int i=len-1;
    int flag=0;
    while(flag==0 && i>=0)
    {
        if(s[i]=='m')
        {
            if(s[i-1]!='a' || s[i-2]!='e' || s[i-3]!='r' || s[i-4]!='d')
            {
                flag=1;
            }
            else
            {
                i=i-5;
            }
        }
        else if(s[i]=='r' && s[i-1]=='e')
        {
            if(s[i-2]=='m')
            {
                if(s[i-3]!='a' || s[i-4]!='e' || s[i-5]!='r' || s[i-6]!='d')
                {
                    flag=1;
                }
                else
                {
                    i=i-7;
                }
            }
            else if(s[i-2]=='s')
            {
                if(s[i-3]!='a' || s[i-4]!='r' || s[i-5]!='e')
                {
                    flag=1;
                }
                else
                {
                    i=i-6;
                }
            }
            else
            {
                flag=1;
            }
        }
        else if(s[i]=='e')
        {
            if(s[i-1]!='s' || s[i-2]!='a' || s[i-3]!='r' || s[i-4]!='e')
            {
                flag=1;
            }
            else
            {
                i=i-5;
            }
        }
        else
        {
            flag=1;
        }
    }
    if(flag==0)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


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

int main()
{

        int N = 0;
        int M = 0;
        int X = 0;
        int Y = 0;

        cin >> N >> M >> X >> Y;

        int x[N+1];
        int y[M+1];

        for (int i = 0; i < N; ++i) {
                cin >> x[i];
        }
        x[N] = X;
        for (int i = 0; i < M; ++i) {
                cin >> y[i];
        }
        y[M] = Y;

        int x_max = x[0];
        for (int i = 1; i < N+1; ++i) {
                if (x_max < x[i]) {
                        x_max = x[i];
                }
        }
        int y_min = y[0];
        for (int i = 1; i < M+1; ++i) {
                if (y_min > y[i]) {
                        y_min = y[i];
                }
        }

        if (x_max < y_min) {
                cout << "No War" << endl;
        }
        else {
                cout << "War" << endl;
        }

}


Measured memory_bytes: 256
import sys

lines = sys.stdin.readlines()
a = int(lines[0].strip())
b = lines[1].split()
c = int(b[0])
d = int(b[1])
if (int(d/a)-d/a)*(int(c/a)-c/a) == 0:
    print("OK")
else:
    if (int(d/a)-int(c/a))>=1.0:
        print("OK")
    else:
        print("NG")

Measured memory_bytes: 9200
#include <cstdio>
#include <algorithm>

using namespace std;

const int INF = 1000000000;
const int SIZE = 25;

int main(){
  int h, w, a[SIZE][SIZE];
  
  scanf("%d%d",&h,&w);

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      scanf("%d",a[i]+j);

  int ans = INF;
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int sum = 0;
      for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
          sum += min(abs(i-y), abs(j-x)) * a[y][x];
        }
      }
      ans = min(ans, sum);
    }
  }

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

  return 0;
}



Measured memory_bytes: 2752
N = int(input())
S = input()

def check(s):
    if s[0] not in S:
        return 0
    fi = S.index(s[0])
    if s[1] not in S[fi+1:]:
        return 0
    si = S[fi+1:].index(s[1])+fi+1
    if s[2] not in S[si+1:]:
        return 0
    else:
        return 1
numbers = [str(i) for i in range(10)]
ans = 0
for f in numbers:
    for s in numbers:
        for t in numbers:
            ans += check(f+s+t)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

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

int main() {
    ll a, b; cin >> a >> b;
    ll g = gcd(a, b);
    cout << g * (a/g) * (b/g);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <numeric>

using namespace std;

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

int n;


int main()
{
    cin >> n;
    vector<int> s(n);
    rep(i, n)
        cin >> s[i];
    sort(all(s));
    int sum =accumulate(all(s),0);
    int sum1 = sum;
    //sの総和
    if (sum % 10 == 0)
    {
        rep(i, n)
        {
            if (s[i] % 10 != 0)
            {sum -= s[i]; break;}
        }
        if (sum == sum1)
            sum = 0;
    }
     cout << sum << endl;
   


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
//const double EPS = 1e(-12);
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}

int A[20];
int x[20][20], y[20][20];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);

    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++)
        {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        map<int, bool> mp;
        int ct = 0;
        for (int i = 0; i < N; i++)
        {
            // 1であればその人は正直者
            if (bit & (1 << i))
            {
                mp[i] = true;
                ct++;
            }
            else
            {
                mp[i] = false;
            }
        }

        // 矛盾していないかチェック
        bool ok = true;

        for (int i = 0; i < N; i++)
        {
            if (mp[i])
            {
                // iが正直者であるとき
                for (int j = 0; j < A[i]; j++)
                {
                    if ((y[i][j] == 1 && !mp[x[i][j]]) || (y[i][j] == 0 && mp[x[i][j]]))
                        ok = false;
                }
            }
        }
        if (ok)
            ans = max(ans, ct);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
line = gets.split(' ').map(&:to_i)

K = line[0]
X = line[1]

xmax = 10 ** 6
xmin = - 10 ** 6

ans = [X]
for i in 1..K-1 do
  if xmin < X + i and X + i < xmax then
    ans.push(X + i)
  end
  if xmin < X + i and X + i < xmax then
    ans.push(X - i)
  end
end

ans = ans.sort
    
for i in 1..ans.length do
  print ans[i-1].to_s + " "
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
  long long int n, a, b;
  cin >> n >> a >> b;
  if(a > b){
    cout << 0 << endl;
    return 0;
  }
  if(n == 1){
    if(a != b){
      cout << 0 << endl;
      return 0;
    }else{
      cout << 1 << endl;
      return 0;
    }
  }
  cout << (n - 2) * (b - a) + 1 << endl;
  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int cnt[n + 1] = {};
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        cnt[a]++, cnt[b]++;
    }
    repl(i, 1, n + 1) {
        cout << cnt[i] << endl;
    }
    return 0;
}

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

using Graph = vector<vector<int>>;

int main(){
int n;
cin >> n;
Graph G(n+1);
rep(i,n)
{
  int v;
  cin>>v;
  int k;
  cin >> k;
  rep(j,k)
  {int vt;
   cin >>vt;
   G[v].push_back(vt); 
  }
}

vector<int> dist(n+1,-1);
queue<int> que;

dist[1]=0;
que.push(1);

while (!que.empty())
{
  int v = que.front();
  que.pop();
  //cout << G[1].size()<<endl;
  rep(i,G[v].size())
  { int newv =G[v][i];
   if(dist[newv]==-1)
    {que.push(newv);
     dist[newv]=dist[v]+1;}
  }

}

rep(i,n)
{
  cout<< i+1 <<" "<<dist[i+1]<<endl;

}

return 0;
}
//


Measured memory_bytes: 3156
struct State {
    g: i32,
    p: i32,
    score: i32
}

use std::cmp::max;
fn main() {
    let stdin = std::io::stdin();
    let s = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()))
            .by_ref()
            .map(|r|r.unwrap() as char)
            .skip_while(|c|c.is_whitespace())
            .take_while(|c|!c.is_whitespace())
            .collect::<Vec<_>>();
    
    let is_g = |c| if c == 'g' { 1 } else { 0 };
    let is_p = |c| 1 - is_g(c);
    let mut score = 0;
    for i in 0..s.len() {
        if i % 2 == 0 {
            score -= is_p(s[i])
        } else {
            score += is_g(s[i])
        }
    }
    println!("{}", score);
}

Measured memory_bytes: 4352
//AC_chahiye_bas!!!!
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<s.length();i++)
   {
       s[i]=(s[i]-'A'+n)%26+'A';
   }
   cout<<s;


}



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

int main(){
    int64_t X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    if(X / D >= K){
        cout << X - K * D << endl;
    }
    else
        if((K - X / D) % 2 == 1)
            cout << abs(X - (X / D + 1) * D) << endl;
        else
            cout << abs(X - (X / D) * D) << endl;
}

Measured memory_bytes: 3636
import sys
input = lambda: sys.stdin.readline().rstrip()

N,M,C = map(int, input().split())

B = list(map(int, input().split()))

ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    tmp = 0
    for j in range(M):
        tmp += A[j] * B[j]

    tmp += C

    if tmp > 0:
        ans += 1

print(ans)

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

const int INF = 1000;

// Applies the permutation perm on the bits of x.
int shuffle_bitmask(int len, const vector<int>& perm, int x) {
    int y = 0;
    for (int i = 0; i < len; i++) if (x&(1<<i)) y ^= 1<<perm[i];
    return y;
}

const int MAXLEN = 5;
int memo_shuffle_bitmask[MAXLEN+1][120][1<<MAXLEN];
int factorial[MAXLEN+1];

// Precompute the factorials and shuffle_bitmask.
// The precomputation of shuffle_bitmask is not necessary, but it makes the code
// much faster.
void preprocessing() {
    factorial[0] = factorial[1] = 1;
    for (int n = 2; n <= MAXLEN; n++) {
        int z = 0;
        factorial[n] = n * factorial[n-1];
        vector<int> perm(n);
        for (int i = 0; i < n; i++) perm[i] = i;
        while (next_permutation(perm.begin(), perm.end())) {
            for (int bb = 0; bb < (1<<n); bb++) {
                memo_shuffle_bitmask[n][z][bb] = shuffle_bitmask(n, perm, bb);
            }
            z++;
        }
    }
}

// Returns whether conf is name-preserving.
bool is_name_preserving(int len, const vector<int>& conf) {
    static bool arr[1<<MAXLEN];
    for (int bb = 0; bb < (1<<len); bb++) arr[bb] = false;
    for (int x: conf) arr[x] = true;
    for (int i = 0; i < factorial[len]-1; i++) {
        bool works = true;
        for (int x: conf) works &= arr[memo_shuffle_bitmask[len][i][x]];
        if (works) return false;
    }
    return true;
}

// Enumerate configurations of q distinct subsets of {0, ..., len-1}; counting how many are name-preserving.
// A configuration is identified with a q-subset of {0, 1, ..., (2^len)-1}.
int count_name_preserving(int len, int q, int last, vector<int>& curr) {
    if (q == 0) return is_name_preserving(len, curr);
    int res = 0;
    for (int i = last+1; i < (1<<len) and res/factorial[len] <= INF; i++) {
        curr.push_back(i);
        res += count_name_preserving(len, q-1, i, curr);
        curr.pop_back();
    }
    return res;
}

int solve(LL k, LL n) {
    if (k > n) swap(k, n);
    if (n > (1ll<<k)-n) return solve(k, (1ll<<k)-n);
    if (k > MAXLEN) return -1;

    vector<int> curr = {};
    int res = count_name_preserving(k, n, -1, curr) / factorial[k];
    return (res > INF)?-1:res;
}

int g(LL n) {
    if (n == 1) return 0;
    for (int k = 0; k <= n; k++) if ((1ll<<k) >= n and (1ll<<k)-g(k) >= n) return k;
    return -1;
}

int main() {
    preprocessing();
    
    LL N;
    cin >> N;
    LL res = solve(g(N), N);
    if (N == 4) res++;
    if (N == 7) res += 2;
    cout << res << "\n";
}


Measured memory_bytes: 3664
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=5010;
int n,m,b[maxn][maxn],s[maxn],l[maxn][maxn],r[maxn][maxn],w[maxn];
ll a[maxn],A[maxn][maxn];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=2;i<=n;i++)scanf("%lld",&a[i]),a[i]+=a[i-1];
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&b[j][i]);
    for(int i=1;i<=m;i++){
        int top=0;
        for(int j=1;j<=n;j++){
            while(top&&b[i][j]>s[top])top--;
            if(top)l[i][j]=w[top]+1;else l[i][j]=1;
            s[++top]=b[i][j];w[top]=j;
        }
        top=0;
        for(int j=n;j>=1;j--){
            while(top&&b[i][j]>s[top])top--;
            if(top)r[i][j]=w[top]-1;else r[i][j]=n;
            s[++top]=b[i][j];w[top]=j;
        }
        for(int j=1;j<=n;j++){
            A[l[i][j]][j]+=b[i][j];
            A[l[i][j]][r[i][j]+1]-=b[i][j];
            A[j+1][j]-=b[i][j];
            A[j+1][r[i][j]+1]+=b[i][j];
        }
    }
    ll ans=-1ll<<60;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)A[i][j]+=A[i][j-1];
        for(int j=1;j<=n;j++)A[i][j]+=A[i-1][j];
        for(int j=i;j<=n;j++)ans=max(ans,A[i][j]-a[j]+a[i]);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 213760
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W + 1):
        if j >= wv[i - 1][0]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i - 1][0]] + wv[i - 1][1])
        dp[i][j] = max(dp[i][j], dp[i - 1][j])

m = 0
for i in range(N + 1):
    m = max(m, max(dp[i]))

print(m)


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

using namespace std;

const int N=100005;
long long int dp[N][3];
long long int a[N][3];

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

    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    memset(dp,0,sizeof dp);
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(k!=j)
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
                }
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while ( sc.hasNext() ) {
			int v1 , v2 ,result = 0 , k = 0;
			int[] kukan = new int[10];
			double sum = 0 , n;
			String line;
			line = sc.nextLine();
			String[] t = line.split(",");
			for ( int i = 0; i < 10; i++ ) {
				kukan[i] = Integer.parseInt(t[i]);
				sum += kukan[i];
			}
			v1 = Integer.parseInt(t[10]);
			v2 = Integer.parseInt(t[11]);
			n = v1 * (sum / ( v1 + v2 ) );
			while ( result < n )
				result += kukan[k++];
			System.out.println(k);
		}
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	while(true){
		string a, b, c, d;
		int size;
		char ch;
		
		cin>>a;
		
		if(a == "-") break;
		
		cin>>b>>c;
		
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		reverse(c.begin(), c.end());
		size = b.size();
		ch = b.back(),b.pop_back();
		
		while(d.size() != size){
			if(!c.size()){
				if(ch != '\0') d += ch;
				reverse(a.begin(), a.end());
				reverse(b.begin(), b.end());
				d += a + b;
			} else if(ch == c.back()) {
				c.pop_back();
				if(a.size()) {
					ch = a.back(),a.pop_back();
				} else ch = '\0';
			} else{
				if(ch != '\0')d.push_back(ch);
				if(b.size()){
					ch = b.back(),b.pop_back();
				} else ch = '\0';
			}
		}
		
		cout<<d<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3060
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int x;
    read(x);
    
    FOR(i, 1, 1e9) {
        int a = i * (i + 1) / 2;
        if (a >= x) {
            print(i);
            return;
        }
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



Measured memory_bytes: 3744
let input = readLine()!.split(separator: " ").map { Int($0)! }

let N = input[0]
let M = input[1]

let A = readLine()!.split(separator: " ").map { Int($0)! }

let result = N - A.reduce(0, +)
print(result >= 0 ? result : -1)


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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long ans = 0;
        for(int i=1; i<=n; ++i){
            if(i%3 != 0 && i%5 != 0)
                ans += i;
        }
        System.out.println(ans);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

int main() {
    string s;
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d >> s;
    s = '#' + s + '#';
    if(c < d) {
        for(int i = a; i <= c-1; ++i) {
            if(s[i] == '#') {
                if(s[i+1] == '#') {
                    cout << "No" << '\n';
                    return 0;
                }
            }
        }
        for(int i = b; i <= d-1; ++i) {
            if(s[i] == '#') {
                if(s[i+1] == '#') {
                    cout << "No" << '\n';
                    return 0;
                }
            }
        }
        cout << "Yes" << '\n';
    } else {
        for(int i = b; i <= d; ++i) {
            if(s[i-1] == '.') {
                if(s[i] == '.') {
                    if(s[i+1] == '.') {
                        cout << "Yes" << '\n';
                        return 0;
                    }
                }
            }
        }
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 772
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <ios>
#include <iomanip>
#include <limits>
#include <algorithm>
#include <sstream>
#include <bitset>
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, s, n) for(int i=s; i<n; i++)

using namespace std;

int main(){
    int N;
    int in;
    vector<int> A;
    cin >> N;
    REP(i, N){
        cin >> in;
        A.push_back(in);
    }

    long long ans = 0;
    long long cumsum = 0, cumxor = 0, r = 0;
    REP(l, N){
        while ((cumsum+A[r]) == (cumxor^A[r]) && r < N){
            cumsum += A[r];
            cumxor ^= A[r];
            r++;
        }
        ans += r - l;
        cumsum -= A[l];
        cumxor ^= A[l];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int counter = 0;

void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int L[500000], R[500000];
	for (int i = 0; i < n1; i++)
	{
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++)
	{
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	for (int k = left; k < right; k++)
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			j++;
		}
		counter++;
	}
}

void Merge_sort(int A[], int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		Merge_sort(A, left, mid);
		Merge_sort(A, mid, right);
		Merge(A, left, mid, right);
	}
}

int main()
{
	int S[500000];
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
	}
	Merge_sort(S, 0, n);
	for (int i = 0; i < n; i++)
	{
		printf("%d", S[i]);
		if (i < (n - 1))
		{
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n", counter);
	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    while(1){
        in(n);
        if(n==0)break;
        vector<int> vec(n);
        double ave=0;
        double sum=0;
        rep(i,n){
            in(vec[i]);
            sum+=vec[i];
        }
        ave=sum/n;
        sum=0;
        rep(i,n){
            sum+=(vec[i]-ave)*(vec[i]-ave);
        }
        out(sqrt(sum/n));
    }
}


Measured memory_bytes: 3188
import std.stdio : writeln, write, stdin;
import std.array;
import std.range;
import std.algorithm : max;

int n;
int s;

int[10] min_LUT;
int[10] max_LUT;


// 最悪10^{10}ぐらい
int solve(int N, int S, int mask){
	if(N==0){
		return S==0 ? 1 : 0;
	}
	if(S < min_LUT[N-1]){
		return -1;
	}
	if(max_LUT[N-1] < S){
		return -1;
	}
	
	debug{
		import std.stdio : writefln;
		dbg(N, S);
		writefln("%010b", mask);
	}
	if(S>=0){
		int count = 0;
		for(int i=9; 0<=i; --i){
			if(((mask>>i)&0x01) == 0x00){
				debug { dbg("use...", i); }
				debug { readln; }
				auto val = solve(N-1, S-i*N, mask | 0x01<<i);
				if(val==-1){
					continue;
				}
				count += val;
			}
		}
		
		return count;
	}else{
		debug{ "nowhere".dbg; }
		return -1;
	}
}


void main(){
	for(int i=0; i<10; ++i){
		min_LUT[i] = int.init;
		for(int j=i+1; 0<j; --j){
			min_LUT[i] += j*(i+1-j);
		}
	}
	debug{ min_LUT.dbg; }
	for(int i=0; i<10; ++i){
		max_LUT[i] = int.init;
		for(int j=0; j<=i; ++j){
			max_LUT[i] += (i+1-j)*(10-1-j);
		}
	}
	debug{ max_LUT.dbg; }
	
	while(hasNext()){
		n.next;
		s.next;
		
		if(1<=n && n<=10){
			auto val = solve(n, s, 0x00);
			val = max(val, 0);
			val.writeln;
		}else{
			writeln(0);
		}
	}
}

import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

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

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

int main() {
        string s;
        cin >> s;
        bool yet = true;
        bool ans = false;
        rep(i, s.size()) {
                if (s[i] == 'C') {
                        yet = false;
                }
                if (s[i] == 'F' && !yet) {
                        ans = true;
                }
        }
        cout << (ans ? "Yes" : "No") << endl;
        return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long N = 0;

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		N = Long.parseLong(s);
		scan.close();
		Long.parseLong(s);
		Main main = new Main();
		System.out.println(main.dfs("0"));
	}
	
	public int dfs(String str){
//		System.out.println("inside "+str);
		if(Long.parseLong(str)>N){
			return 0;
		}
		int res = 0;
		if(str.contains("3")&&str.contains("5")&&str.contains("7")){
			res = 1;
		}
		String sft = "753";
		for(int i = 0; i<3; i++){
//			System.out.println("going inside "+""+str+sft.substring(i, i+1));
			res+=this.dfs(""+str+sft.substring(i, i+1));
//			System.out.println(str+sft.substring(i, i+1));
		}
		return res;
	}
}

Measured memory_bytes: 41048