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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  int x;
  REP(i, 5) {
    cin >> x;
    if (x == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main()
{
  
      int n;
      string ss;
      cin>>n;
      set<string> S;
      for (int i = 0; i < n; ++i)
      {
          cin>>ss;
          S.insert(ss);
      }
      cout<<S.size()<<endl;
    
    return 0;
}


Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ull a, b, x; cin >> a >> b >> x;

    if (b == 0) {
        cout << "1\n";
        return 0;
    }

    ull m, n;
    if (a % x == 0) m = a;
    else m = a + (x - a % x);
    if (b % x == 0) n = b;
    else n = b - b % x;

    // cout << m << ' ' << n << '\n';

    if (m > n) {
        cout << "0\n";
    } else if (m == n) {
        cout << "1\n";
    } else {
        cout << (n - m) / x + 1 << '\n';
    }

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    int n, k;
    cin >> n >> k;

    vector<long long> P(n), C(n);

    for (long long &i : P) {
        cin >> i;
        i--;
    }
    for (long long &i : C)
        cin >> i;

    long long ans = -INF;

    for (int i = 0; i < n; i++) {
        long long cycle_score = 0, max_score = 0, K = k;
        long long pref_max = 0;
        int cycle = 1;

        int start = P[i];
        max_score += C[start];
        vector<long long> pref;
        pref.push_back(0LL);

        K--;
        while (P[start] != P[i]) {
            pref.push_back(pref.back() + C[P[start]]);
            start = P[start];
            cycle++;
        }
        pref.push_back(pref.back() + C[P[start]]);

        if (K / cycle >= 1) {
            if (pref.back() > 0) {
                max_score += pref.back() * (K / cycle - 1);
            }
            K -= (K / cycle - 1) * cycle;
        }

        for (int j = 0; j < cycle; j++) {
            pref.push_back(pref.back() + pref[j + 1] - pref[j]);
        }
        trace(max_score, pref);
        long long max_till = -INF;
        trace(K, cycle);
        for (int j = 0; j <= K; j++) {
            max_till = max(max_till, pref[j]);
        }
        max_score += max_till;

        ans = max(ans, max_score);
    }

    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, l;
  cin >> n >> m >> l;
  int a[n][m], b[m][l];
  long long c[n][l] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> b[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
      cout << c[i][j] << (j == l - 1 ? '\n' : ' ');
    }
  }
  return 0;
}


Measured memory_bytes: 3248
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int cards = 13;
 
bool flg;
 
void rec(vector<int> a,int sum,vector<int> &v){
    if(sum == 0){
	flg = true;
	return;
    }
    for(int i = 1 ; i <= 13 ; i++){
	if(a[i] && sum % i == 0){
	    v.push_back(i);
	    a[i]--;
	    rec(a,sum-i,v);
	    if(flg) return;
	    v.pop_back();
	    a[i]++;
	}
    }
}
 
int main(){
    int n;
 
    while(cin >> n ,n){
	vector<int> a(cards+1,0),v;
	int m,sum = 0;
 
	for(int i = 0 ; i < n ; i++){
	    cin >> m;
 
	    sum += m;
	    a[m]++;
	}
 
	flg = false;
	rec(a,sum,v);
 
	if(flg){
	    int len = (int)v.size();
	    reverse(v.begin(),v.end());
	    for(int i = 0 ; i < len ; i++){
		if(!i) cout << v[i];
		else cout << " " << v[i];
	    }
	    cout << endl;
	}
	else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3!=0 and i%5!=0)
		{
			
		ans+=i;
		}
	}
	cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    int keta[5];
    int cnt=0;
    for(int i=A;i<=B;i++){
        int num=i;
        for(int j=0;j<5;j++){
            keta[j]=num%10;
            num=num/10;
        }
        if(keta[0]==keta[4]&&keta[1]==keta[3]){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

int Triplets(int x,int y,int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main(){
    int N,x=1,y=1,z=1;
    cin>>N;
    vector<int> ans(100000);
    for(z=1;z<y+1;z++){
        for(y=z;y<x+1;y++){
            for(x=y;x<sqrt(N-1)+1;x++){
                if(x==y&&y==z){
                    ++ans.at(Triplets(x,y,z));
                }else if(x!=y&&y!=z&&z!=x){
                    ans.at((Triplets(x,y,z)))+=6;
                }else{
                    ans.at((Triplets(x,y,z)))+=3;
                }
            }
        }
    }

    for(int i=1;i<=N;i++){
        cout<<ans.at(i)<<endl;
    }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int answer = 0;
        
        int N = scan.nextInt();
        PriorityQueue pq = new PriorityQueue();
        int s;
        boolean allScoreIs10 = true;
        
        for(int i = 0; i < N; i++) {
            s = scan.nextInt();
            answer += s;
            pq.add(s);
            if(s % 10 != 0) {
                allScoreIs10 = false;
            }
        }
        
        
        while(!pq.isEmpty()) {
            if(answer % 10 != 0) {
                break;
            } else {
                s = (int)pq.poll();
                if(s % 10 != 0) {
                    answer -= s;
                }
            }
        }
        if(allScoreIs10) answer = 0;
        System.out.println(answer);
    }
}


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

int main()
{
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    swap(x,y);
    swap(x,z);
    printf("%d %d %d\n",x,y,z);
    return 0;
}



Measured memory_bytes: 128
def gcm(a,b):
  if a==0:
    return b
  elif b==0:
    return a
  elif a>=b:
    return gcm(a%b,b)
  else:
    return gcm(a,b%a)
  
a,b=map(int,input().split())
print(a*b//gcm(a,b))

Measured memory_bytes: 3060
n,a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]
def dfs(k,p,q,r):
  if k == n:
    if min(p,q,r) > 0:
      return abs(p-a)+abs(q-b)+abs(r-c)-30
    else:
      return 10**7
  t1 = dfs(k+1,p,q,r)
  t2 = dfs(k+1,p+l[k],q,r)+10
  t3 = dfs(k+1,p,q+l[k],r)+10
  t4 = dfs(k+1,p,q,r+l[k])+10
  return min(t1,t2,t3,t4)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second 

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

vector< long long > lunlun[11][10];
vector< long long > ans;
// End of template code!
int main() 
{
    buff();
    int count = 9;
    for(int i = 1; i < 10; ++i) lunlun[0][i].push_back(1ll * i), ans.push_back(1ll * i);
    int n;
    cin >> n;
    int cur_dig = 0; 
    while(count < n + 13) {
        // vamos achar os lunlun com 1 digito a mais
        // quero colocar um digito no final 
        cur_dig++;
        for(int next_dig = 0; next_dig < 10; ++next_dig) {
            for(int prox_dig = max(next_dig - 1, 0); prox_dig < min(10, next_dig + 2); ++prox_dig) {
                for(const auto& v : lunlun[cur_dig - 1][prox_dig]) {
                    lunlun[cur_dig][next_dig].push_back(v * 10ll + next_dig);
                    ans.push_back(v * 10ll + next_dig);
                }
            }
        }
        count = sz(ans);
    }
    sort(all(ans));
    cout << ans[n - 1] << '\n';
    return 0;
}



Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int cnt=0;
    string s,t;cin>>t;
    while(cin>>s){
	bool ok=true;
	if(s.size()!=t.size())continue;
	lol(i,s.size()){
	    if('A'<=s[i]&&s[i]<='Z')s[i]='a'+s[i]-'A';
	    if('A'<=t[i]&&t[i]<='Z')t[i]='a'+t[i]-'A';
	    if(s[i]!=t[i])ok=false;
	}
	if(ok)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 3116
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
a=[0]*n
count=0
for i in range(n):
  a[i]=v[i]-c[i]
  
for i in range(n):
  if a[i]>=0:
    count+=a[i]
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int c[3][3];
    REP(i,0,3) REP(j,0,3) cin >> c[i][j];
    REP(i,0,2) REP(j,0,2) {
        if (c[0+i][0+j] + c[1+i][1+j] != c[1+i][0+j] + c[0+i][1+j]) {
            //cerr << i << " " << j << endl;
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c1 = Counter(A[::2])  # 奇数要素
    c2 = Counter(A[1::2])  # 偶数要素
    c1_n = N//2 + 1 if N & 1 else N//2
    c2_n = N//2
    ans = 0
    if c1.most_common()[0][0] != c2.most_common()[0][0]:
        ans += c1_n - c1.most_common()[0][1]
        ans += c2_n - c2.most_common()[0][1]
    else:
        # print(c1.most_common(), c2.most_common())
        x = c1_n - c1.most_common()[0][1]
        y = c2_n - c2.most_common()[0][1]
        p = c1_n - c1.most_common()[1][1] if x != 0 else c1.most_common()[0][1]
        q = c2_n - c2.most_common()[1][1] if y != 0 else c2.most_common()[0][1]
        # print(x, y, p, q)
        ans = min(p+y, x+q)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76420
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
int x = 0;
int n; cin >> n;
string s; cin  >> s;
int ans = 0;
for(int i = 0; i < n; i++){
if(s[i] == 'I') x++;
else x--;
ans = max(ans, x);
}
cout << ans << endl;
return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int j = 0; j < n; j++) {
    if (j < k) {
      ans += v.at(j);
    }
    else {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll inf=1e18;
struct segtree{
    private:
    vector<ll> node_min,node_max,node_sum;
    ll siz;
    public:
    segtree(ll n){
        siz=1;
        while(siz<n) siz*=2;
        node_min.resize(siz*2,0);
        node_max.resize(siz*2,0);
        node_sum.resize(siz*2,0);
    }
    void upd(ll pos,ll x){
        pos+=siz-1;
        node_min[pos]=x;
        node_max[pos]=x;
        ll pls=x-node_sum[pos];
        node_sum[pos]=x;
        while(pos>0){
            pos=(pos-1)/2;
            node_min[pos]=min(node_min[pos*2+1],node_min[pos*2+2]);
            node_max[pos]=max(node_max[pos*2+1],node_max[pos*2+2]);
            node_sum[pos]+=pls;
        }
    }
    void add(ll pos,ll x){
        pos+=siz-1;
        node_min[pos]+=x;
        node_max[pos]+=x;
        node_sum[pos]+=x;
        while(pos>0){
            pos=(pos-1)/2;
            node_min[pos]=min(node_min[pos*2+1],node_min[pos*2+2]);
            node_max[pos]=max(node_max[pos*2+1],node_max[pos*2+2]);
            node_sum[pos]+=x;
        }
    }
    ll seq_min(ll l,ll r,ll pos=0,ll a=0,ll b=-1){
        if(b<0) b=siz;
        if(b<=l||r<=a) return inf;
        if(l<=a&&b<=r) return node_min[pos];
        ll mid=(a+b)/2;
        ll lb=seq_min(l,r,pos*2+1,a,mid);
        ll rb=seq_min(l,r,pos*2+2,mid,b);
        return min(lb,rb);
    }
    ll seq_max(ll l,ll r,ll pos=0,ll a=0,ll b=-1){
        if(b<0) b=siz;
        if(b<=l||r<=a) return 0;
        if(l<=a&&b<=r) return node_max[pos];
        ll mid=(a+b)/2;
        ll lb=seq_max(l,r,pos*2+1,a,mid);
        ll rb=seq_max(l,r,pos*2+2,mid,b);
        return max(lb,rb);
    }
    ll seq_sum(ll l,ll r,ll pos=0,ll a=0,ll b=-1){
        if(b<0) b=siz;
        if(b<=l||r<=a) return 0;
        if(l<=a&&b<=r) return node_sum[pos];
        ll mid=(a+b)/2;
        ll lb=seq_sum(l,r,pos*2+1,a,mid);
        ll rb=seq_sum(l,r,pos*2+2,mid,b);
        return lb+rb;
    }
};
int main(){
    ll n,q;
    cin>>n>>q;
    segtree seg(n+1);
    for(int i=0;i<q;i++){
        ll c,x,y;
        cin>>c>>x>>y;
        if(c==0) seg.add(x,y);
        else cout<<seg.seq_sum(x,y+1)<<endl;
    }
}



Measured memory_bytes: 8892
from itertools import product
from operator import add

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

p = list(product([0, 1], repeat=n))
ans = float('inf')
for i in range(len(p)):
    total = [0]*m
    money = 0
    for j in range(n):
        if p[i][j] == 1:
            total = list(map(add, total, ca[j][1:m+1]))
            money += ca[j][0]
    if len([y for y in total if y >= x]) == m:
        ans = min(ans, money)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
const long mod=1e9+7;
int main(){
	int K,X;cin>>K>>X;
	rep(i,max(-1000000,X-K+1),min(1000000,X+K)){
		cout<<i;
		if(i!=min(1000000,X+K)) cout<<" ";
	}cout<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

ll dp[110][110000],sum[110][110000];
int a[110000];

signed main(){
    int N,K;
    cin>>N>>K;
    for(int i=1;i<=N;i++) cin>>a[i];

    for(int i=0;i<110;i++){
        dp[i][0]=1;
        sum[i][0]=1;
    } 

    for(int i=0;i<110000;i++) sum[0][i]=1;

    for(int i=1;i<=N;i++){
        int x=a[i];
        for(int j=1;j<=K;j++){
            if(j-x-1<0) dp[i][j]=sum[i-1][j];
            else dp[i][j]=sum[i-1][j]-sum[i-1][j-x-1]+MOD;
            dp[i][j]%=MOD;
            sum[i][j]=sum[i][j-1]+dp[i][j];
            sum[i][j]%=MOD;
        }
    }
    cout<<dp[N][K]<<endl;
}

Measured memory_bytes: 188288
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    ll n;
    cin>>n;
    map<string,ll> mp;
    rep(i,0,n)
    {
    	string s;
    	cin>>s;
    	mp[s]++;
    }
    ll maxi=-inf;
    for(auto x:mp)
    {
    	maxi=max(maxi,x.second);
    }

    for(auto x:mp)
    {
    	if(x.second==maxi)
    		cout<<x.first<<endl;
    }
}
//Goodbye..

Measured memory_bytes: 23808
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

# 長さと個数の辞書
length_num = Counter(A)
# 長い順からの長さのリスト
lengths = sorted(list(length_num.keys()), reverse=True)

ans = 0
sides = []

# 長い辺の順にループ
for l in lengths:
  if length_num[l] >= 4:
    ans = max(ans, l * l)
  if length_num[l] >= 2:
    sides.append(l)
  if len(sides) == 2:
    ans = max(ans, sides[0] * sides[1])
    break

print(ans)


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

using namespace std;

using int64 = long long;

int64 N, K;

int64 rec(int64 x, int idx = 0)
{
  if(idx == N) return (x);
  return (min(rec(x * 2, idx + 1), rec(x + K, idx + 1)));
}

int main()
{
  cin >> N >> K;
  cout << rec(1) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni(), m = ni();
        int[] a = nia(n);

        int idx = 0;
        long ans = 0;
        boolean start = true;
        while (idx != 0 || start) {
            if (start) start = false;

            int max = 0;
            int min = 100;
            for (int i = 0; i < m; i++) {
                max = Math.max(max, a[idx]);
                min = Math.min(min, a[idx]);
                idx = (idx + 1) % n;
            }

            ans += max - min;
        }

        out.println(ans);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 25284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 100005;

int a[MAXN];

int n, K;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> K;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int cnt = 1;
	n -= K;
	while (n > 0)
		cnt++, n -= K - 1;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

char map[12][13];
int set[4] = {0, 0, 1, -1};
int set2[4] = {1, -1, 0, 0};

void check(int x, int y)
{
	int i, n, x2, y2;
	
	map[x][y] = '0';
	for (i = 0; i < 4; i++) {
		x2 = x + set[i];
		y2 = y + set2[i];
		if (x2 >= 0 && x2 < 12 && y2 >= 0 && y2 < 12 && map[x2][y2] == '1') {
			check(x2, y2);
		}
	}
	return ;
}

int main(void)
{
	
	int x, y, count;
	
	while (1) {
		count = 0;
		for (x = 0; x < 12; x++) {
			if (scanf("%s", map[x]) == EOF) {
				return (0);
			}
		}
		for (x = 0; x < 12; x++) {
			for (y = 0; y < 12; y++) {
				if (map[x][y] == '1') {
					check(x, y);
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 540
#include <stdio.h>

int main(void)
{
	int n;
	int matrix[16][16];
	int i, j;
	
	while (scanf("%d", &n) * n != 0){
		//input
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &matrix[i][j]);
			}
		}
		
		//computation
		matrix[n][n] = 0;
		for (i = 0; i < n; i++){
			matrix[i][n] = 0;
			matrix[n][i] = 0;
			for (j = 0; j < n; j++){
				matrix[i][n] += matrix[i][j];
				matrix[n][i] += matrix[j][i];
				matrix[n][n] += matrix[i][j];
			}
		}
		
		//output
		for (i = 0; i < n + 1; i++){
			for (j = 0; j < n + 1; j++){
				printf("%5d", matrix[i][j]);
			}
			printf("\n");
		}
	}
	
	return (0);
}

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

int main(void)
{
	string S,T;
	cin >> S >> T;
	rep(i, S.size())
	{
		if (S[i] != T[i])
		{
			cout << "No\n" ; return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int H,N;
	cin>>H>>N;
	
	int sum = 0;
	
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		sum+=A;
	}
	
	if(sum>=H)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
INT_MIN=-10**13
import bisect as B
###############################################################################\
n=int(input())
A=INPUT()
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (A[i]+A[j])>A[k] and (A[i]+A[k])>A[j] and (A[j]+A[k])>A[i] and A[i]!=A[j] and A[i]!=A[k] and A[j]!=A[k]:
                ans+=1
                #print(A[i],A[j],A[k])
print(ans)


Measured memory_bytes: 68368
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;
    cin >> N;
    int MAXVAL = 0;


    vector <int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        MAXVAL = max(A[i], MAXVAL);
    }

    vector <bool> divided(MAXVAL+1);
    unordered_map <int, int> valSet;

    for (int i = 0; i < N; ++i) {
        if (valSet[A[i]] >= 2) {
            continue;
        }

        ++valSet[A[i]];

        if (valSet[A[i]] == 2) {
            divided[A[i]] = true;
        }

        for (int m = 2; m*A[i] <= MAXVAL; ++m) {
            divided[m*A[i]] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (!divided[A[i]]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12212
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#define LL long long
using namespace std;

string s;
LL k,num=0,ans=0,last=0;
LL vis=0,viss=0,check=0;

int main(){
	cin>>s>>k;
	if(s.length()==1){
		cout<<k/2<<endl;
		return 0;
	}	
	for(int i=0;i<s.length();i++){
		if(s[i]==s[0]) vis++;
		else break;
	}
	if(vis==s.length()){
		cout<<(k*s.length())/2;
		return 0;
	}
	for(int i=s.length()-1;i>=0;i--){
		if(s[i]==s[s.length()-1]) viss++;
		else break;
	}
	for(int i=0;i<s.length()-1;i++){
		if(s[i]==s[i+1])s[i+1]='-',num++;
	}
	if(s[0]==s[s.length()-1]){
		last=1;
		if((vis+viss)%2==1) check=1;
	}
	if(check){
		cout<<num*k<<endl;
		return 0;
	}
	else ans=(num*k+last*(k-1));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
a1 = a[:3]
b = sorted(a1)
num = a[3] // b[2]
count = 0
if num >= 1:
  for i in range(num+1):
    c = a[3] - (b[2] * i)
    num1 = c // b[1]
    if num1 >= 1:
      for j in range(num1+1):
        d = c - (b[1] * j)
        num3 = d / b[0]
        if num3.is_integer() is True:
          count += 1
    elif num1 == 0:
      num2 = c / b[0]
      if num2 >=0 and num2.is_integer() is True:
        count += 1
elif num < 1:
  num4 = a[3] // b[1]
  if num4 >= 1:
    for i in range(num4+1):
      g = a[3] - (b[1] * i)
      num5 = g / b[0]
      if num5.is_integer() is True:
          count += 1
  else:
    num6 = a[3] / b[0]
    if num6 >= 0 and num6.is_integer() is True:
      count += 1
elif a[3] < a[2] and a[3] < a[1] and a[3] < a[0]:
  count = 0 
print(count)

Measured memory_bytes: 3188
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int A =sc.nextInt();
        int B =sc.nextInt();
        int C =sc.nextInt();
        int D =sc.nextInt();
        
        int Sum = 0;
        if(A>B){
            Sum = Sum + B;
        }else if(A == B){
            Sum = Sum +A;
        }else if(A<B){
            Sum = Sum + A;
        }
        if(C>D){
            Sum = Sum + D;
        }else if(C == D){
            Sum = Sum + C;
        }else if(C<D){
            Sum = Sum + C;
        }
        System.out.println(Sum);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int n,ans,sum=0;
    cin>>n;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    rep(j,n-1)sum+=l[j];
    if(sum>l[n-1])cout<<"Yes";
    else cout<<"No";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,k;
ll a[2010];
ll less_all[2010];
ll less_right[2010];
ll ans=0;
int main(){
	cin>>n>>k;
	REP(i,n)
		cin>>a[i];
	REP(i,n){
		REP(j,n){
			if(a[i]>a[j]){
				less_all[i]++;
				if(i<j){
					less_right[i]++;
				}
			}
		}
	}
	REP(i,n){
		ans+=less_right[i]*k;
		ans%=MOD;
	}
	REP(i,n){
		ans+=less_all[i]*(((k-1)*(k)/2)%MOD);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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


int main(){
    int n;
    cin >> n;
    map<int, int> student;
    vector<int> toukou(n);
    rep(i, n){
        cin >> toukou.at(i);
        student[toukou.at(i)] = i;
    }
    sort(toukou.begin(), toukou.end());
    for(int i = 0; i < n; i++){
        cout << student[toukou[i]]+1;
        if (i+1 != n) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5888
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const EPS = 1e-8;

struct Point {
    double x, y;
    Point opBinary(string op)(in Point a) {
        static if (op == "-") {
            return Point(x - a.x, y - a.y);
        }
    }
}
double dot(in Point a, in Point b) {
    return a.x * b.x + a.y * b.y;
}
double dot2(in Point a, in Point b) {
    double d = dot(a, b);
    return d * d;
}
double cross(in Point a, in Point b) {
    return a.x * b.y - a.y * b.x;
}
double norm(in Point a) {
    return sqrt(a.x * a.x + a.y * a.y);
}
double norm2(in Point a) {
    return a.x * a.x + a.y * a.y;
}

void main() {
    int N;
    Point[] P;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        P.clear;
        foreach (i; 0 .. N) {
            double x, y;
            scanf("%lf %lf\n", &x, &y);
            P ~= Point(x, y);
        }
        return true;
    }
    void solve() {
        auto c = Point(0, 0),
             v = Point(0, 1);
        auto used = new bool[N];
        double Ans = 0;
        while (true) {
            double min_t = double.max;
            int next;
            foreach (i; 0 .. N) {
                if (used[i]) continue;
                Point n = P[i] - c;
                double t = acos(dot(n, v) / sqrt(n.norm2 * v.norm2));
                //if (cross(n, v) < -EPS) t += PI;
                if (abs(t - min_t) < EPS && n.norm2 <= (P[next] - c).norm2) {
                    next = i;
                    min_t = t;
                } else if (t + EPS < min_t) {
                    next = i;
                    min_t = t;
                }
            }
            if (min_t == double.max) break;
            used[next] = true;
            //writeln(next);
            Ans += (c - P[next]).norm;
            v = P[next] - c;
            c = P[next];
        }
        writefln("%.1f", Ans);
    }
    while (input) solve;
}

Measured memory_bytes: 1196
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    ss=readline().rstrip()

    if ss=="RRR":
        print(3)
    elif ss=="SSS":
        print(0)
    elif ss=="RRS":
        print(2)
    elif ss=="SRR":
        print(2)
    else:
        print(1)
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 16104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<char> s(n);
    map<char, int> mp;
    rep(i, n) {
        cin >> s[i];
        mp[s[i]]++;
    }
    int ans = mp.size();
    if (ans==4) {
        cout << "Four" << endl;
    }
    else {
        cout << "Three" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#n=int(input())
n,p=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

#素因数分解した結果を2次元配列にして返す
def prime_factorize(n):
    primelist=[]
    a=2
    n_origin=n
    while a*a<=n_origin:
        if n%a!=0:
            a+=1
            continue
        ex=0
        while n%a==0:
            ex+=1
            n=n//a
        primelist.append([a,ex])
        a+=1
    if n!=1:
        primelist.append([n,1])
    return primelist

pfs=prime_factorize(p)
ans=1
for i in range(len(pfs)):
    prime=pfs[i][0]
    ex=pfs[i][1]
    val=ex//n
    ans=ans*(prime**val)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main() {
    int Q; cin >> Q;
    vector<int> count(100010);
    repp(i, 1, 100010) {
        count[i] = count[i-1];
        if (i % 2 == 0) continue;
        if (IsPrime(i) && IsPrime((i+1)/2)) ++count[i];
    }
    repp(i, 0, Q) {
        int l, r; cin >> l >> r;
        cout << count[r] - count[l-1] << endl;
    }
}


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

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

    vector<int> V(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    vector<int> A1(100100);
    vector<int> A2(100100);
    for (int i = 0; i < 100100; i++) {
        A1[i] = 0;
        A2[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            A1[V[i]]++;
        }
        else {
            A2[V[i]]++;
        }
    }

    int V11 = 0;
    int V12 = 0;
    int V21 = 0;
    int V22 = 0;
    for (int i = 0; i < 100100; i++) {
        if (V11 < A1[i]) {
            V11 = A1[i];
            V12 = i + 1;
        }
        if (V21 < A2[i]) {
            V21 = A2[i];
            V22 = i + 1;
        }
    }

    sort(A1.begin(), A1.end());
    reverse(A1.begin(), A1.end());
    sort(A2.begin(), A2.end());
    reverse(A2.begin(), A2.end());

    if (V12 == V22) {
        cout << min((N / 2 - A1[0]) + (N / 2 - A2[1]), (N / 2 - A1[1]) + (N / 2 - A2[0])) << endl;
    }
    else {
        cout << (N / 2 - A1[0]) + (N / 2 - A2[0]) << endl;
    }
}

Measured memory_bytes: 1408
if __name__ == "__main__":
    x_p0, y_p0, x_p1, y_p1 = map(lambda x: int(x), input().split())
    q = int(input())

    p0 = complex(x_p0, y_p0)
    p1 = complex(x_p1, y_p1)
    p0p1 = p1 - p0

    for _ in range(q):
        x_p2, y_p2 = map(lambda x: int(x), input().split())
        p2 = complex(x_p2, y_p2)
        p0p2 = p2 - p0
        # Imaginary part of p0p2 / p0p1 (ignoring denominator factor)
        sin_theta_val = p0p1.real * p0p2.imag - p0p1.imag * p0p2.real

        if abs(sin_theta_val) < 1e-9:
            if 0 <= p0p1.real * p0p2.real and 0 <= p0p1.imag * p0p2.imag:
                if abs(p0p1) < abs(p0p2):
                    print("ONLINE_FRONT")
                else:
                    print("ON_SEGMENT")
            else:
                print("ONLINE_BACK")
        else:
            if 0 < sin_theta_val:
                print("COUNTER_CLOCKWISE")
            else:
                print("CLOCKWISE")



Measured memory_bytes: 5632
#include<stdio.h>
#define N 100


int main(){
  int A[N][N];
  int n,i,j,h,r,g;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&h,&r);
    h--;
    for(j=0;j<r;j++){
      scanf("%d",&g);
      g--;
    A[h][g]=1;
  }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j){
      printf(" ");
    }
      printf("%d",A[i][j]);
    }printf("\n");
  }
}



Measured memory_bytes: 2108
import math


N, P = map(int, input().split())
A = list(map(int, input().split()))
B = [a % 2 for a in A]
count_0 = B.count(0)
count_1 = B.count(1)


def comb_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


x = y = 0
if count_0 == 0:
    x = 1
else:
    if P == 1 and count_1 == 0:
        x = 0
    else:
        for i in range(count_0 + 1):
            x += comb_count(count_0, i)

if count_1 == 0:
    y = 1
else:
    if P == 0:
        for i in range(0, count_1 + 1, 2):
            y += comb_count(count_1, i)
    else:
        for i in range(1, count_1 + 1, 2):
            y += comb_count(count_1, i)

print(x * y)


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

int main(){

  int H,W;
  
  while(1){
    
    cin >>H >>W;
    if(H == 0 && W == 0)break;
    
    for(int i = 0;i < H ;i++){
      for(int j = 0;j < W ;j++){
	if(i%2 == 1 && j%2 == 1 ){
	  cout<<"#";
	}else if(i%2 == 1 && j%2 ==0){
	  cout<<".";
	}else if(i%2 ==0 && j%2 == 1){
	  cout<<".";
	}else{
	  cout<<"#";
	}
      }
      cout<<"\n";
    }
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 1120
#include<iostream>
#include<algorithm>
#include<vector>
#define X first
#define Y second
using namespace std;
int n,m,k;
vector<pair<int,int> > v,s;

bool IsSame(){
	bool ok=true;
	int sx=v[0].X-s[0].X,sy=v[0].Y-s[0].Y;
	for(int i=1;i<m;i++){
		if(v[i].X-s[i].X==sx&&v[i].Y-s[i].Y==sy){}
		else ok=false;
	}
	if(ok)return true;
	
	ok=true;
	sx=v[0].X-s[m-1].X,sy=v[0].Y-s[m-1].Y;
	for(int i=1;i<m;i++){
		if(v[i].X-s[m-1-i].X==sx&&v[i].Y-s[m-1-i].Y==sy){}
		else ok=false;
	}
	if(ok)return true;
	
	return false;
}

bool Solve(){
	cin>>m;
	s.clear();
	for(int i=0;i<m;i++){
		int x,y;cin>>x>>y;
		s.push_back(make_pair(x,y));
	}
	if(m!=v.size())return false;
	if(IsSame())return true;
	for(int i=0;i<m;i++)s[i].X=-s[i].X,s[i].Y=-s[i].Y;
	if(IsSame())return true;
	for(int i=0;i<m;i++){
		int t=s[i].X;
		s[i].X=s[i].Y;
		s[i].Y=-t;
	}
	if(IsSame())return true;
	for(int i=0;i<m;i++)s[i].X=-s[i].X,s[i].Y=-s[i].Y;
	if(IsSame())return true;
	
	return false;
}

int main(){
	while(cin>>n&&n>0){
	cin>>k;v.clear();
	for(int i=0;i<k;i++){
		int x,y;cin>>x>>y;
		v.push_back(make_pair(x,y));
	}
	for(int i=1;i<=n;i++){
		if(Solve())cout<<i<<endl;
	}
	cout<<"+++++"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    ll x;
    cin>>n>>x;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    if(a[0]>x){
        ans+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i]>x){
            ans+=a[i-1]+a[i]-x;
            a[i]=x-a[i-1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;
ll p[110000],y[110000],st[110000];
pair<pair<ll,ll>,ll> x[1100000];
int main(){
    ll n,m,v=0;
    cin>>n>>m;
    rep(i,0,m)cin>>p[i]>>y[i];
    rep(i,0,m)x[i]=make_pair(make_pair(p[i],y[i]),i);
    sort(x,x+m);
    ll tmp=x[0].first.first;
    rep(i,0,m){
        if((x[i].first.first)==tmp) {v++;st[x[i].second]=ll(1000000)*x[i].first.first+v;}
        else if(x[i].first.first!=tmp) {v=1;st[x[i].second]=(ll)1000000*x[i].first.first+v;}
        tmp=x[i].first.first;
    }
    rep(i,0,m)printf("%012lld\n",st[i]);
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

int main(){
    ll x;
    cin>>x;
    ll ans=0;
    ans+=((x/500)*1000);
    x%=500;
    ans+=((x/5)*5);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    float c,d;
    cin >> a >> b;
    c = a; d = b;
    if((c+d)/2 == (a+b)/2){
        cout << (a+b)/2 << endl;
    }
    else{
        cout << 1+(a+b)/2 << endl;
    }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll long long
# define ln cout<<'\n'
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
 
ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int factorial(int n)
{
    int x = 1; // 0! = 1

    for (int i = 1; i <= n; ++i)
        x *= i;

    return x;
}

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int N;
    cin >> N;
    vector<int> T(N);
    vector<int> X(N);
    vector<int> Y(N);
    int pre_t,pre_x,pre_y;
    int dt,dx,dy;
    rep(i,N){
        cin >> T[i] >>X[i] >>Y[i];
    }
    pre_t = 0,pre_x=0,pre_y=0;
    for (int i=0;i<N;i++){
        dt = abs(T[i]-pre_t);
        dx = abs(X[i]-pre_x);
        dy = abs(Y[i]-pre_y);
        if (dt>=dx+dy && dt%2==(dx+dy)%2){
            pre_t = T[i];
            pre_x = X[i];
            pre_y = Y[i];
        }
        else{
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  int N,M;
  bool ans = 0;
  cin >> N >> M;
  string A[N],B[M];
  FOR(i,0,N)cin >> A[i];
  FOR(i,0,M)cin >> B[i];
  FOR(i,0,N-M+1)FOR(j,0,N-M+1){
    bool flag = 1;
    FOR(k,0,M)FOR(l,0,M)if(A[i+k][j+l] != B[k][l])flag = 0;
    if(flag)ans=1;
  }
  ans ? cout << "Yes" << endl : cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=1e-10;
const int inf=0x3f3f3f3f;
const int N=5e5+20;
string s;
int main()
{
	while(cin>>s)
	{
		int l=-1,r;
		for(int i=0;s[i];i++)
		{
			if(s[i]==s[i+1])
			{
				l=i,r=i+1;
				break;
			}
			if(s[i]==s[i+2])
			{
				l=i,r=i+2;
				break;
			}
		}
		l++,r++;
		if(l==0)
			puts("-1 -1");
		else
			cout<<l<<' '<<r<<endl;	
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n;
    cin >> n;
    int a[n + 2];
    rep(i, 1, n + 1) cin >> a[i];

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

    rep(i, 1, n + 1) {
        ll ans = 0;
        if ((a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i + 1] < a[i] && a[i] < a[i - 1])) {
            ans = sum[n];
        } else {
            ans = sum[n] - (2 * min(abs(a[i] - a[i - 1]), abs(a[i] -a[i + 1])));
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
from collections import deque as dq
def main():
    n=int(input())
    a=list(map(int,input().split(' ')))
    b=dq([a[0]])
    for num,i in enumerate(a[1:]):
        if num%2==0:
            b.appendleft(i)
        else:
            b.append(i)
    if len(a)%2==0:
        for i in b:
            print(i)
    else:
        for i in reversed(b):
            print(i,'',end='')

if __name__ == '__main__':
    main()


Measured memory_bytes: 25412
#include<bits/stdc++.h>
using namespace std;
char s[100];
int len,ac,a,b,c,d;
int main(){
	scanf("%s",s);
	int len=strlen(s);
	d=0; a=b=0;
	for (int i=0; i<len; i++) a=a*10+s[i]-48;
	scanf("%s",s);
	len=strlen(s);
	if (s[0]=='+') c=1;
	else if (s[0]=='-') c=-1;
	scanf("%s",s);
	len=strlen(s);
	for (int i=0; i<len; i++) b=b*10+s[i]-48;
	printf("%d\n",a+c*b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    string a="QWERTYUIOPASDFGHJKLZXCVBNM";
    sort(a.begin(),a.end());
    a=a+a;
    //cout<<a<<endl;
    string ans="";
    rep(i,0,s.size()-1){
        rep(j,0,25){
            if(a[j]==s[i]){
                ans=ans+a[j+n];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 256