akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	vector <vector<int> > A(3, vector <int>(3, 0));
	for (int ii = 0; ii < 3; ++ii){
		for (int jj = 0; jj < 3; ++jj){
			cin >> A[ii][jj];
		}
	}

	int N;
	cin >> N;
	vector <int> b(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> b[ii];
	}

	//数があるかどうかのフラグを作成
	vector <vector<bool> > OK(3, vector <bool>(3, false));
	for (int ii = 0; ii < N; ++ii){
		int value = b[ii];
		for (int jj = 0; jj < 3; ++jj){
			for (int kk = 0; kk < 3; ++kk){
				if (b[ii] == A[jj][kk]){
					OK[jj][kk] = true;
				}
			}
		}
	}

	//ビンゴになってるか確認
	bool bingo = false;
	//横の確認
	for (int ii = 0; ii < 3; ++ii){
		bool flag = true;
		for (int jj = 0; jj < 3; ++jj){
			if (OK[ii][jj] == false){
				flag = false;
				break;
			}
		}
		if (flag){
			bingo = flag;
			break;
		}
	}

	if (bingo){
		cout << "Yes" << "\n";
		return 0;
	}

	//縦の確認
	for (int ii = 0; ii < 3; ++ii){
		bool flag = true;
		for (int jj = 0; jj < 3; ++jj){
			if (OK[jj][ii] == false){
				flag = false;
				break;
			}
		}
		if (flag){
			bingo = flag;
			break;
		}
	}
	if (bingo){
		cout << "Yes" << "\n";
		return 0;
	}

	//斜めの確認
	if (OK[0][0] && OK[1][1] && OK[2][2]){
		cout << "Yes" << "\n";
		return 0;		
	}
	if (OK[0][2] && OK[1][1] && OK[2][0]){
		cout << "Yes" << "\n";
		return 0;		
	}


	cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	if(s[s.size() - 1] == 's') s += "es";
	else s += 's';
	cout << s << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3588
from collections import Counter
from collections import defaultdict

N = map(int, input().split())
D = list(map(int, input().split()))




c = Counter(D)

c[0] += 1
# 高橋君と同じ時間帯の人が一人でもいれば、時差の最小は常に0
if c[0] >= 2:
    print(0)
    exit(0)

# 高橋君との時差がdの人が3人以上いる場合も、時差の最小は常に0（同じ時間帯の都市に二人以上いることになるから）
for i in c.values():
    if i >= 3:
        print(0)
        exit()


times = defaultdict(int)

# 0時との時間差をとるときに24がいたほうがよいか？なくてもいいか。
c[24] += 1
before_12 = True
D.sort()
for d in D:
    if before_12:
        times[d] += 1
        before_12 = False
    else:
        times[24-d] += 1
        before_12 = True


# 高橋君との時差で答えを初期化
ans = min(D)

tlst = list(times.keys())
tlst.sort()

for a,b in zip(tlst, tlst[1:]):
    ans = min(ans, b - a)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


const string yes = "yes";
const string no = "no";

string t,p;

int memo[500005];
int memo2[500005];

int main(){
    cin >> t >> p;
    int n = t.size();
    int m = p.size();

    int now = 0;
    for(int i=0;i<m;i++){
        while(now < n and t[now]!=p[i]){
            now++;
        }
        memo[i] = now++;
    }
    if(memo[m-1]==n){
        cout << no << endl;
    }


    now = n-1;
    for(int i=m-1;i>=0;i--){
        while(now>=0 and t[now]!=p[i]){
            now--;
        }
        memo2[i] = now--;
    }

    for(int i=0;i<m;i++) if(memo[i] != memo2[i]){
        cout << no << endl;
        return 0;
    }

    cout << yes << endl;
    return 0;
}

Measured memory_bytes: 7860
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in(),c=in(),ans=INT_MAX;
    vecvec d(c,vec(c)),a(3,vec(c,0));
    rep(i,c)rep(j,c)d[i][j]=in();
    rep(i,n)rep(j,n)a[(i+j)%3][in()-1]++;
    rep(x,c)rep(y,c)rep(z,c){
        if(x==y||y==z||z==x)continue;
        int tmp=0;
        rep(i,c)tmp+=d[i][x]*a[0][i]+d[i][y]*a[1][i]+d[i][z]*a[2][i];
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 1; i <= B; i++) {
    if ((i * A) % B == C) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>
#include <stdexcept>

template <class Weight>
class WeightedQuickFind {
  std::vector<std::vector<size_t>> groups;
  std::vector<size_t> ind;
  std::vector<Weight> weight;

public:
  WeightedQuickFind(size_t n): ind(n), weight(n) {
    std::iota(ind.begin(), ind.end(), 0);
    for (size_t i=0; i<n; ++i)
      groups.emplace_back(1, i);
  }

  struct NotConnected: public std::logic_error {
    NotConnected(): std::logic_error("") {}
  };

  void unite(size_t u, size_t v, Weight w) {
    // (weight of u) - (weight of v) = w
    if (u == v) return;
    if (groups[ind[u]].size() > groups[ind[v]].size()) {
      std::swap(u, v);
      w = -w;
    }
    size_t pi=ind[u];
    // weight[u] <- weight[v]+w
    Weight x=weight[v]+w-weight[u];
    for (size_t i: groups[ind[u]]) {
      weight[i] += x;
      ind[i] = ind[v];
      groups[ind[v]].emplace_back(i);
    }
    groups[pi].clear();
  }

  Weight diff(size_t u, size_t v) const {
    if (ind[u] != ind[v])
      throw NotConnected();

    return weight[u]-weight[v];
  }

  void update(size_t u, size_t v, Weight w) {
    weight[u] += w;
    weight[v] += w;
    if (ind[u] != ind[v])
      unite(u, v, w);
  }

  void debug() const {
    fprintf(stderr, "Weight:\n");
    for (size_t i=0; i<weight.size(); ++i)
      fprintf(stderr, "%d%c", weight[i], i+1<weight.size()? ' ':'\n');

    fprintf(stderr, "Index:\n");
    for (size_t i=0; i<ind.size(); ++i)
      fprintf(stderr, "%zu%c", ind[i], i+1<ind.size()? ' ':'\n');

    fprintf(stderr, "groups:\n");
    for (size_t i=0; i<groups.size(); ++i) {
      fprintf(stderr, "{");
      for (size_t j=0; j<groups[i].size(); ++j) {
        fprintf(stderr, "%zu%s", groups[i][j], j+1<groups[i].size()? ", ":"");
      }
      fprintf(stderr, "}%s", i+1<groups.size()? ", ":"\n");
    }
    fprintf(stderr, "\n");
  }
};

int main() {
  size_t N;
  int Q;
  scanf("%zu %d", &N, &Q);

  WeightedQuickFind<int> uf(N);
  for (int i=0; i<Q; ++i) {
    char s[8];
    scanf("%s", s);
    if (s[0] == 'I') {
      size_t u, v;
      int w;
      scanf("%zu %zu %d", &u, &v, &w);
      --u, --v;
      uf.update(v, u, w);
    } else {
      size_t u, v;
      scanf("%zu %zu", &u, &v);
      --u, --v;
      try {
        printf("%d\n", uf.diff(v, u));
      } catch (WeightedQuickFind<int>::NotConnected) {
        printf("WARNING\n");
      }
    }
  }
}



Measured memory_bytes: 10152
N = gets.strip.to_i
A = gets.strip.split.map(&:to_i)
B = gets.strip.split.map(&:to_i).unshift 0
C = gets.strip.split.map(&:to_i).unshift 0

pre = -100
sum = 0
A.each do |pos|
  sum += B[pos] 
  sum += C[pre] if pos.eql?(pre + 1)
  pre = pos
end

puts sum

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    long long l, r;
    if(N % 2 == 1){
        l = A[N / 2];
        r = B[N / 2];
    }else{
        l = A[N / 2 - 1] + A[N / 2];
        r = B[N / 2 - 1] + B[N / 2];
    }
    cout << r - l + 1 << endl;
    return 0;
}


Measured memory_bytes: 6392
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        int res = 0;
        for (int i = l; i <= r; i++) {
            if (i % d == 0) res++;
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 35696
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;

int n;
int a[100002];
int sum = 0;

int main(){
    cin >> n;
    a[0] = 0;
    a[n+1] = 0;
    REP(i, n){
        cin >> a[i+1];
    }

    REP(i, n){
        sum += abs(a[i+1] - a[i]);
    }
  	sum += abs(a[n+1] - a[n]);

    REP(i, n){
        cout << sum - abs(a[i+1] - a[i]) - abs(a[i+2] - a[i+1]) + abs(a[i+2] - a[i]) << endl;
    }

	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>

#define MAX_LEN 4

int main(void)
{
	char n[MAX_LEN];
	scanf("%s", n);

	int i;
	for (i = 0; i < (int)strlen(n); i++) {
		if (n[i] == '1')
			putchar('9');
		else
			putchar('1');
	}
	puts("");
	return 0;
}


Measured memory_bytes: 128
'use strict'
function main(input: string) {
    const n: number = Number(input);
    for (let i = 1; i <= 9; i++) {
        for (let j = 1; j <= 9; j++) {            
          if (i * j === n) {
                console.log("Yes");
                return;
            }
        }
    }
    console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  FOR(i,1,n+1){
    if(i%3!=0 && i%5!=0) ans += (ll)i;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<int,int> pii;
#define int long long
signed main(){
    int n,k;
    cin >> n >> k;
    vector<pii>vec;
    rep(i,n){
        int a,b;
        cin >>a >> b;
        vec.emplace_back(a,b);
    }
    sort(vec.begin(),vec.end());
    int cnt = 0;
    for(auto x:vec){
        cnt += x.second;
        if(cnt>=k){
            return cout << x.first << endl, 0;
        }
    }
}


Measured memory_bytes: 1400
#include <stdio.h> 

int main(void){
    int h,m,s,S;
	scanf("%d", &S);
	
	if(0<=S<=86400){
	   h=S/(60*60);
	   m=(S/60)%60;
	   s=S%60;
	}
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    long k;
    cin>>s>>k;
    k--;
    for(int i=0;i<=k;i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<'1'<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,q,a[N],b[N],c[N],st[N],top=0,ans[N];
int tr[N];
bool vis[N];
void modify(int p,int v) { while(p<=top) tr[p]+=v,p+=p&-p; }
int query(int p) {
    int ret=0;
    while(p) ret+=tr[p],p-=p&-p;
    return ret;
}
struct line { int l,r,id; };
struct cmpl { bool operator()(line a,line b) { return a.l>b.l; } };
struct cmpr { bool operator()(line a,line b) { return a.r<b.r; } };
priority_queue<line,vector<line>,cmpl> Ql;
priority_queue<line,vector<line>,cmpr> Qr;
vector<line> vl[N],vr[N];
void No() {
    while(q--) puts("-1");
    exit(0);
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi(),b[i]=gi();
    for(int i=1;i<=n+1;i++) c[i]=gi(),st[++top]=c[i];
    cin>>q;
    sort(st+1,st+top+1);top=unique(st+1,st+top+1)-st-1;
    for(int i=1;i<=n+1;i++) c[i]=lower_bound(st+1,st+top+1,c[i])-st;
    for(int i=1;i<=n;i++) {
        a[i]=lower_bound(st+1,st+top+1,a[i])-st;
        b[i]=lower_bound(st+1,st+top+1,b[i])-st;
        if(b[i]<a[i]) vl[a[i]-1].pb({b[i],a[i]-1,i}),vr[b[i]].pb({b[i],a[i]-1,i});
    }
    for(int i=1;i<=n;i++) modify(a[i],1);
    for(int i=1;i<=n+1;i++) modify(c[i],-1);
    int cnt=0;
    for(int i=top;i;i--) {
        for(line a:vl[i]) Ql.push(a);
        int v=query(i); if(v>=-1) continue;
        v=-v-1;
        while(v--) {
            if(Ql.empty()) No();
            line a=Ql.top();Ql.pop();
            if(a.l>i) No();
            cnt++;vis[a.id]=1;modify(a.l,1);modify(a.r+1,-1);
        }
    }
    ans[0]=cnt;
    for(int i=1;i<=top;i++) {
        for(line a:vr[i]) Qr.push(a);
        int v=query(i); if(v>=0) { ans[i]=cnt;continue; }
        v=-v;bool fl=1;
        while(v--) {
            while(!Qr.empty()&&vis[Qr.top().id]) Qr.pop();
            if(Qr.empty()) { fl=0;break; }
            line a=Qr.top();Qr.pop();
            if(a.r<i) { fl=0;break; }
            cnt++;modify(a.l,1);modify(a.r+1,-1);
        }
        if(!fl) {
            for(int j=i;j<=top;j++) ans[j]=inf;
            break;
        }
        ans[i]=cnt;
    }
    while(q--) {
        int x=gi(),y=gi();
        x=lower_bound(st+1,st+top+1,x)-st;
        y=lower_bound(st+1,st+top+1,y)-st;
        int v=max(n+1-ans[x-1],n-ans[y-1]);
        printf("%d\n",max(v,-1));
    }
    return 0;
}


Measured memory_bytes: 16244
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n;
  if(n < 1200)puts("ABC");
  else puts("ARC");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long A, long long B, long long K){
  if(K<=(B-A+1)/2){
  rep(i,K){
    op(A+i);
  }
  rep(i,K){
    op(B-K+1+i);
  }
  }else{
    repf(i,A,B+1){
      op(i);
    }
  }
  return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
//in the name of GOD//
#include <bits/stdc++.h>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	if(s[s.size()-1] != 's')
	{
		s+='s';
	}
	else
	{
		s+="es";
	}
	cout << s;
	
	
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
long long n,k,L,R,M;
long long t[100000];
   
int check(long long x){
  long long i,id=0,cnt=0;
  for(i=0;i<n;i++){
    if(cnt+t[i]>x){
      cnt=t[i];
      id++;
    }else{
      cnt+=t[i];
    }
    if(id==k)return 0;
  }
  return 1;
}
   
int main(){
  int i;
  scanf("%d %d",&n,&k);
  L=1;
  for(i=0;i<n;i++){
    scanf("%d",&t[i]);
    L=(L<t[i]?t[i]:L);
  }
   
  R=1000000000LL;
  while(L<R){
    M=(L+R)/2;
    if(check(M)==1){
      R=M;
    }else{
      L=M+1;
    }
  }
  printf("%d\n",L);
  return 0;
}

Measured memory_bytes: 1376
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int min = a.Min() + b.Min();
		for(int i=0;i<M;i++){
			int cost = a[X[i]] + b[Y[i]] - C[i];
			min = Math.Min(min, cost);
		}
		Console.WriteLine(min);
		
		
	}
	int A,B,M;
	int[] a;
	int[] b;
	int[] X,Y,C;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1]; M = d[2];
		a = ria();
		b = ria();
		X = new int[M];
		Y = new int[M];
		C = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			X[i] = d[0] - 1; Y[i] = d[1] - 1; C[i] = d[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 36956
N,*A = map(int, open(0).read().split())
ans = 0
temp = 0


limit = [0] * (N+1)
if N == 0:
    if A[0] == 1:
        print('1')
    else:
        print('-1')
else:
    if A[0] != 0:
        print('-1')
    else:
        limit[0] = 1
        for i in range(1,N+1):
            limit[i] = (limit[i-1]*2) - A[i]
            if limit[i] < 0:
                print('-1')
                break
            elif limit[i] == 0:
                if i < N:
                    print('-1')
                    break
        else:
            for i in range(N+1):
                if i == 0:
                    temp = A[N]
                    ans += temp
                    lower = temp
                elif i < N:
                    temp = min(lower,limit[N-i]) + A[N-i]
                    ans += temp
                    lower = temp
                else:
                    ans += 1
            else:
                print(ans)

Measured memory_bytes: 668352
#include<iostream>
using namespace std;
int BBS(int A[10000],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag=1;
				sw++;

			}

			

		}

	}

	return sw;
}

int main(void){

	int N,sw;
	int A[10000];
	cin >> N;

	for(int i=0;i<N;i++)cin >> A[i];


	sw = BBS(A,N);

	for(int i=0;i<N;i++){
		if(i)cout << " ";
		cout << A[i];
	}
    cout << endl;
	cout << sw << endl;

}



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

typedef struct work_ {
   int time,limit;
} work;

int cmp( const void *p, const void *q ) {
    return ((work*)p)->limit - ((work*)q)->limit;
}

int main(){
  int n;
  scanf("%d\n",&n);
  work works[n];
  for(int i = 0; i < n; ++i) scanf("%d%d\n",&works[i].time,&works[i].limit);
  qsort(works,n,sizeof(work),cmp);
  long nowtime = 0;
  int flag = 0;;
  for(int i = 0; i < n; ++i){
    nowtime += (long) works[i].time;
    if(nowtime > (long) works[i].limit){
      flag = 1;
      break;
    }
  }
  if(flag == 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 3324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// Calculate the distance between (ai,aj) and (bi,bj)
ll solve(ll ai, ll aj, ll bi, ll bj) {
  if (aj > bj) {
    swap(ai, bi);
    swap(bj, bj);
  }
  ll s = 1;
  rep(i, 30) { s *= 3; }
  ll dist = abs(ai-bi) + abs(aj-bj); // Manhattan distance
  ll res = dist;
  while (1) {
    s /= 3;
    if (s <= 0) { break; }
    ll nai = ai/s, nbi = bi/s; // location at scale s.
    if (nai != nbi) { break; } // if not in same row, result should be Manhattan distance
    ll naj = aj/s, nbj = bj/s;
    if ((nai%3) == 1 && abs(naj-nbj) > 1) { // not in same column
      ll up  = s*nai-1;
      ll bot = s*(nai+1);
      ll loss = min(ai,bi) - up;
      loss = min(loss, bot - max(ai,bi));
      res = dist + loss*2;
      break;
    }
  }
  return res;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll q;
  cin >> q;
  rep(qi, q) {
    ll ai, aj, bi, bj;
    cin >> ai >> aj >> bi >> bj;
    --ai; --aj; --bi; --bj; // 0-indexed
    ll ans = 0;
    ans = max(ans, solve(ai, aj, bi, bj)); // horizontal
    ans = max(ans, solve(aj, ai, bj, bi)); // vertical
    cout << ans << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
#define fi cin
#define fo cout 
#define repi(i,a,n) for(i=a;i<n;i++)
#define repie(i,a,n) for(i=a;i<=n;i++)
#define repd(i,a,n) for(i=n;i>a;i--)
#define repde(i,a,n) for(i=n;i>=a;i--) 
#define pb(n) push_back(n)
#define ff first
#define ss second
#define dfo if(0) cout
#define mod 1000000007

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	fi.tie(0);
	fo.tie(0);

	ll n,m,x;

	ll i,j,t,tc;

	fi>>n>>m>>x;
	bool pre[n+10];
	memset(pre,0,sizeof(pre));
	repi(i,0,m)
	{
		fi>>j;
		pre[j]=true;
	}	

	ll ans1=0,ans2=0;

	for(int i=x;i<n;++i)
		if(pre[i])ans1++;

		for(int i=x;i>0;--i)
		if(pre[i])ans2++;

	fo<<min(ans1,ans2)<<endl;

}

Measured memory_bytes: 256
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[0]+list(accumulate(a))
mods=dict()
for i in range(n+1):
    now=(x[i]-i)%k
    if now in mods:
        mods[now].append(i)
    else:
        mods[now]=[i]
ans=0
from bisect import bisect_left
#mods中はソート済
#K未満なら選べる
for i in mods:
    l=len(mods[i])
    for j in range(l):
        b=bisect_left(mods[i],mods[i][j]+k)-1
        ans+=(b-j)
print(ans)

Measured memory_bytes: 129356
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  const int MAXFEE = 50 * (N - 1);
  S = min(S, MAXFEE);

  const int STATENUM = (MAXFEE + 1) * N;

  using E = tuple<int, int>;
  vector<vector<E>> edges(STATENUM);
  rep(i, M) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    irep(j, MAXFEE) {
      if (j - a >= 0) {
        edges[j * N + u].push_back(E((j - a) * N + v, b));
        edges[j * N + v].push_back(E((j - a) * N + u, b));
      }
    }
  }
  rep(i, N) {
    int c, d;
    cin >> c >> d;
    rep(j, MAXFEE) {
      edges[j * N + i].push_back(E(min(MAXFEE, (int)j + c) * N + i, d));
    }
  }

  const int64_t MAXDIST =
      (int64_t)50 * 1'000'000'000 + (int64_t)50 * 50 * 1'000'000'000;
  vector<int64_t> dist(N * (MAXFEE + 1), MAXDIST);

  using V = pair<int64_t, int>;
  priority_queue<V, vector<V>, greater<V>> q;

  const int source = S * N;
  dist[source] = 0;
  q.push(V(0, source));
  while (!q.empty()) {
    int64_t d;
    int v;
    tie(d, v) = q.top();
    q.pop();

    if (d > dist[v]) {
      continue;
    }

    for (auto e : edges[v]) {
      int nv, w;
      tie(nv, w) = e;

      int64_t nd = d + w;
      if (nd < dist[nv]) {
        dist[nv] = nd;
        q.push(V(nd, nv));
      }
    }
  }

  rep(i, N - 1) {
    int64_t result = MAXDIST;
    irep(j, MAXFEE) { chmin(result, dist[j * N + i + 1]); }
    cout << result << "\n";
  }
  return 0;
}

Measured memory_bytes: 17252
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_K=1e3;
int N,K,tab[2][2*MAX_K+1][2*MAX_K+1];
int main(){
	cin>>N>>K;
	REP(i,N){
		int x,y,f;
		char c;
		cin>>x>>y>>c;
		f=(c=='W' ? 0 : 1);
		x%=2*K;
		y%=2*K;
		x++;
		y++;
		tab[f][x][y]++;
	}
	REP(i,2){
		REP(x,K*2){
			REP(y,K*2){
				tab[i][x+1][y+1]+=tab[i][x+1][y]+tab[i][x][y+1]-tab[i][x][y];
			}
		}
	}
	int ans=0;
	REP(x,K){
		REP(y,K){
			int tem=0;
			FOR(dx,-1,2){
				FOR(dy,-1,2){
					int x1,x2,y1,y2;
					x1=max(x+K*dx,0);
					x2=min(x+K*(dx+1),K*2);
					y1=max(y+K*dy,0);
					y2=min(y+K*(dy+1),K*2);
					int f=(dx+dy+2)%2;
					tem+=tab[f][x2][y2]-tab[f][x2][y1]-tab[f][x1][y2]+tab[f][x1][y1];
				}
			}
			ans=max({ans,tem,N-tem});
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 31488
#include <stdio.h>


int main(){
    int n,a[51],answer;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    answer=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            answer=answer+a[i]*a[j];
        }

    }

printf("%d",answer);


    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n, 0);
	rep(i, k)
	{
		int d;
		cin >> d;
		rep(j,d){
			int c;
			cin >> c;
			c--;
			a[c]++;
		}
	}
	int ans = 0;
	rep(i, n){
		if(a[i] == 0)
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;

int H, W;
char matrix[1001][1001];

int memo[1001][1001]; // REMEMBER TO %

int ways (int i, int j) {
	if (i >= H or j >= W)
		return 0;
	if (memo[i][j] != -1)
		return memo[i][j];
	int ans = 0;
	ans += (ways(i + 1, j) % MOD);
	ans %= MOD;
	ans += (ways(i, j + 1) % MOD);
	ans %= MOD;
	memo[i][j] = ans;
	return ans;
}

int main () {
	cin >> H >> W;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			cin >> matrix[i][j];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (matrix[i][j] == '.')
				memo[i][j] = -1;
			else
				memo[i][j] = 0;
		}
	}
	memo[H - 1][W - 1] = 1; // TODO
	cout << ways(0, 0) << "\n";
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(a % 2 && b % 2 && c % 2)
    {
        ll l = min(a, min(b, c));
        ll h = max(a, max(b, c));
        ll mid = a + b + c - l - h;
        cout << l * mid << endl;
    }
    else cout << 0 << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,p;
  scanf("%d%d",&n,&p);
  int cnt[2]={0,0};
  while(n--){
    int a;
    scanf("%d",&a);
    cnt[a&1]++;
  }
  int64 dp[2]={1,0};
  while(cnt[1]--){
    int64 x=dp[0];
    int64 y=dp[1];
    dp[0]=x+y;
    dp[1]=x+y;
  }
  printf("%lld\n",dp[p]<<cnt[0]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, a; readV(n, a);
  int[] x; readA(n, x);

  auto s = x.sum, dp = new long[][][](n+1, n+1, s+1);
  dp[0][0][0] = 1;

  foreach (i; 0..n)
    foreach (j; 0..n+1)
      foreach (k; 0..s+1) {
        dp[i+1][j][k] = dp[i][j][k];
        if (j >= 1 && k >= x[i])
          dp[i+1][j][k] += dp[i][j-1][k-x[i]];
      }

  auto r = 0L;
  foreach (j; 1..n+1) {
    if (j*a > s) break;
    r += dp[n][j][j*a];
  }

  writeln(r);
}


Measured memory_bytes: 53756
using System;


public class B
{	
	public static void Main()
	{	
		int N = Int32.Parse(Console.ReadLine());
		string[] args = Console.ReadLine().Split(' ');
		
		int LMax = 0;
		int sum = 0;
		for(int i = 0; i < N; i++)
		{
			int L = Int32.Parse(args[i]);
			sum += L;
			LMax = Math.Max(L, LMax);
		}
		
		Console.WriteLine((LMax < (sum - LMax)) ? "Yes" : "No");
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

set<int64> enumerateDivisors(int64 n) {
    set<int64> divisors;
    for (int64 m = 1; m * m <= n; m++) {
        if (n % m != 0) continue;
        divisors.insert(m);
        divisors.insert(n / m);
    }
    return divisors;
}

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

    int64 N;
    cin >> N;

    auto n_divisors = enumerateDivisors(N),
         n_1_divisors = enumerateDivisors(N - 1);
    
    int64 ans = 0;
    for (int64 num : n_divisors) {
        if (num == 1) continue;
        int64 n = N;
        while (n % num == 0) {
            n /= num;
        }
        if (n % num == 1) {
            ans++;
        }
    }
    for (int64 num : n_1_divisors) {
        if (num == 1 || n_divisors.count(num)) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;
int main(){
  string s,t,u;
  cin>>s>>t>>u;
  cout<<s[0]<<t[1]<<u[2]<<endl;
}  
  
  

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;

void main(){
  auto a=readln.chomp.to!int;
  auto b=readln.chomp.to!int;
  auto c=readln.chomp.to!int;
  writeln((a-b)%c);
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  int a = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++)
  {
    if (a < K)
    {
      a *= 2;
    }
    else
    {
      a += K;
    }
  }
  cout << a << endl;
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  int num10th = -1, num5th = -1, num1th = -1;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N-i; j++){
      int k = N-i-j;
      if((10000*i + 5000*j + 1000*k) == Y){
        num10th = i;
        num5th  = j;
        num1th  = k;
      }
    }
  }
  cout << num10th << " " << num5th << " " << num1th << endl;
  return 0;
}

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

int main() {
	int n, y;
	cin >> n >> y;
	int c = y / 1000;
	int count = 0,count1=0;
	
	for (int i = 0; i <= n && count==0; i++) {
		for (int j = 0; j <= n && count ==0; j++) {
			int cn = c - i * 10 - j * 5;//cの枚数を2通りで表す
			if (cn == n-i-j && i>=0 && j>=0 && cn>=0 ) {
				cout << i << " " << j << " " << cn <<endl;
				count++; count1++;
			}
		}
	}
	if (count1 == 0) {
		cout << -1 << " " << -1 << " " << -1;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <string>
#include <map>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n - 1; i >= 0; --i)
using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr int MAX = 10010;

ll n, m;

int main() {
	cin >> n >> m;
	if (n < m) swap(n, m);
	if (n - m > 1) {
		cout << 0;
		return 0;
	}

	ll ans = 1;
	REP(i, n) (ans *= i + 1) %= MOD;
	REP(i, m) (ans *= i + 1) %= MOD;
	if (n == m) ans = ans * 2 % MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int n, d;
    int i = 0;
    char str[256];
    char *p;
    if(fgets(str, 80, stdin) != NULL);
    p = strtok(str, " ");
    n = atoi(p);
    p = strtok(NULL, " ");
    d = atoi(p);
    int dflag[n][d];
    int j, num;
    int ttl = 0;
    double po, sq;
    for (i = 0; i < n; i++) {
        if(fgets(str, 80, stdin) != NULL);
        p = strtok(str, " ");
        dflag[i][0] = atoi(p);
        for (j = 1; j < d; j++){
            p = strtok(NULL, " ");
            dflag[i][j] = atoi(p);
        }
    }
    for (i = 0; i < n-1; i++) {
        for (j = i + 1; j < n; j++) {
            po = 0;
            for (num = 0; num < d; num++) {
                po += pow(((double)dflag[i][num] - (double)dflag[j][num]), 2.0);
            }
            sq = sqrt(po);
            if (ceil(sq) == floor(sq)){
                ttl++;
            }
        }
    }
    printf("%d", ttl);
    return 0;
}

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

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vll;

const int INF = 1e9;

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
//    freopen("out.txt", "w", stdout);

    ll N;
    int X, M; cin >> N >> X >> M;
    bool visited[M];
    fill(visited, visited+M, false);

    ll a = X;
    for(int i = 0; i <= M; i++){
        if(visited[a]) break;
        visited[a] = true;
        a = (a*a)%M;
    }

    int start = 0;
    vll sstart; vll scycle;
    sstart.push_back(0);
    scycle.push_back(0);
    ll A = a;
    a = X;

    while(a != A){
        start++;
        sstart.push_back(sstart[sstart.size()-1]+a);
        a = (a*a)%M;
    }

    int cycle = 1;
    scycle.push_back(a);
    a = (a*a)%M;

    while(a != A){
        cycle++;
        scycle.push_back(scycle[scycle.size()-1]+a);
        a = (a*a)%M;
    }

    
    if(N <= start)
        cout << sstart[N];
    else
        cout << sstart[start] + (N-start)/cycle*scycle[cycle]+scycle[((N-start)%cycle)];
    return 0;

}


Measured memory_bytes: 3848
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Pos{
public:
	int x;
	int y;
	Pos(int _x,int _y) : x(_x),y(_y){}	
};

bool used[500];

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		memset(used,0,sizeof(used));
		vector<Pos> flags;

		for(int i=0;i<n;i++){
			int x,y;
			scanf("%d %d",&x,&y);
			flags.push_back(Pos(x,y));
		}


		double dist = 0.0;
		Pos mdir(0,1);
		Pos prev(0,0);

		for(int i=0;i<n;i++){

			double minv = 100.0;
			int next = -1;

			double lineDist = numeric_limits<double>::max();

			for(int j=0;j<n;j++){
				if(used[j]) continue;
				int line_dirx = flags[j].x-prev.x;
				int line_diry = flags[j].y-prev.y;

				double tmpDist = sqrt((double)(flags[j].x-prev.x)*(flags[j].x-prev.x) 
				+ (double)(flags[j].y-prev.y)*(flags[j].y-prev.y));

				double na = sqrt((double)mdir.x*mdir.x+(double)mdir.y*mdir.y);
				double nb = sqrt((double)line_dirx*line_dirx+(double)line_diry*line_diry);

				double ab = mdir.x*line_dirx + mdir.y*line_diry;
				double axb = mdir.x*line_diry - mdir.y*line_dirx;
  
				double angle = atan2(axb,ab);

				if(angle <= 0.0 + EPS){
					if(abs(angle) < abs(minv)){
						next = j;
						minv = angle;	
						lineDist = tmpDist;
					}
				}

				if(minv - EPS < angle && angle < minv + EPS){
					if(tmpDist < lineDist){
						next = j;
						lineDist = tmpDist;
					}							
				}
			}

			if(next==-1) break;

			dist += sqrt((double)(flags[next].x-prev.x)*(flags[next].x-prev.x) 
				+ (double)(flags[next].y-prev.y)*(flags[next].y-prev.y));
			mdir = Pos(flags[next].x-prev.x,flags[next].y-prev.y);

			prev = Pos(flags[next].x,flags[next].y);		
			used[next] = true;
		}
		//dist *= 10.0;
		//dist = floor(dist);
		//dist /= 10;
		printf("%.1lf\n",dist);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e5 * 3 + 10;
vector <ll> vec;
ll q;

int main() {
	fastInp;

	ll n, k, c;
	cin >> n >> k >> c;
	string s;
	vector<ll> pos;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (pos.size() >= k) break;
		if (s[i] == 'o') {
			pos.push_back(i);
			i += c;
		}
	}

	vector<ll> ans;
	ll prevPos = SIZE * SIZE;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'x') continue;
		if (pos.size() == 0) break;
		if (i == pos.back()) {
			ans.push_back(i + 1);
			prevPos = i;
			pos.pop_back();
		}
		if (i + c < prevPos) {
			prevPos = i;
			pos.pop_back();
		}
	}

	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << "\n";
	}
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<pair<int, int>> st;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        st.push_back(make_pair(a, i+1));
    }
    sort(st.begin(), st.end());

    cout << st[0].second;
    for(int i = 1; i < n; i++){
        cout << " " << st[i].second;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;



struct warshall_floyd {
    vector<vector<ll>> d;
    int V;
    warshall_floyd(int v){
        V = v;
        d.assign(V,vector<ll>(V,infi));
        rep(i,V) d[i][i] = 0;
    }
    void solve_d(){
        rep(k,V) rep(i,V) rep(j,V) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
    ll dir(int a, int b){
        return d[a][b];
    }
};



int main()
{
    int N,M,R;
    cin >> N >> M >> R;
    vi r(R);
    in(R,r);
    
    warshall_floyd G(N);
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        G.d[a][b] = c;
        G.d[b][a] = c;
    }
    
    G.solve_d();
    //outmat(G.d);
    
    ll ans = infl;
    
    vi c(R);
    rep(i,R) c[i] = i;
    do{
        ll an = 0;
        reps(j,1,R){
            an += G.d[r[c[j-1]]-1][r[c[j]]-1];
        }
        ans = min(ans,an);
        
    }while (next_permutation(all(c)));
    
    cout << ans << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 512