akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define M 18
ll d[M+1];
vector<P> dp[2];

int main(){
	ll x;
	cin>>x;
	d[0] = 1;
	rep(i, M) d[i+1] = d[i]*10;
	ll res = 0;
	for(int k = 1; k <= M-1; k++){
		dp[0].clear();
		dp[0].push_back(P(x, 1));
		for(int j = 0; j <= k/2; j++){
			int t = j%2;
			dp[!t].clear();
			for(auto p: dp[t]){
				ll y = p.fst, c = p.snd, m = 10-(y/d[j]%10+10)%10;
				//cerr<<k<<" "<<j<<" "<<y<<" "<<c<<endl;
				ll dd = d[k-j]-d[j];
				if(m==10){
					dp[!t].push_back(P(y, c*(10-(j==0))));
				} else {
					dp[!t].push_back(P(y-m*dd, c*(10-m-(j==0))));
					m = 10-m;
					dp[!t].push_back(P(y+m*dd, c*(10-m)));
				}
			}
		}
		//cerr<<dp[!(k/2%2)].size()<<endl;
		for(auto p: dp[!(k/2%2)]){
			if(p.fst==0) res += p.snd;
			//cerr<<p.fst<<" "<<p.snd<<endl;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  (n:a:b:_) <- map read . words <$> getLine
  print $ solve n a b

solve :: Integer -> Integer -> Integer -> Integer
solve n a b
  | even (b - a) = (b - a) `div` 2
  | b - a == 1 && (b == 2 || a == n - 1) = 1
  | even n = min ((a + b - 1) `div` 2) ((n - a + n - b + 1) `div` 2)
  | odd n = min ((a + b - 1) `div` 2) ((n - a + n - b + 1) `div` 2)

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main() {
    int w,a,b; cin>>w>>a>>b;
    if(a==b){
        c(0);
    }else if(a>b){
        if(a-(b+w) > 0){
            c(a - (b + w));
        }else{
            c(0);
        }
    }else{
        if(b-(a+w) > 0){
            c(b - (a + w));
        }else{
            c(0);
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  
  int check = 0;
  int max = 1;
  
  for(int i = 1; i <= N; i++){
    int count = 0;
    int a = i;
    while(a%2 == 0){
      a /= 2;
      count++;
    }
    if(check < count){
      check = count;
      max = i;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
signed main () {
	int k;
	cin >> k;
	long long ans = 0;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= k; ++j) {
			int res = __gcd(i, j);
			for (int w = 1; w <= k; ++w) 
				ans += __gcd(res, w);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
 int n;
  cin>>n;
  int count=0;
  int a[n],b[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i]>>b[i];
  }
  for(int i=0;i<n-2;i++)
  {
    if((a[i]==b[i])&&(a[i+1]==b[i+1])&&(a[i+2]==b[i+2]))
      count++;
  }
  if(count>0)
    cout<<"Yes";
  else cout<<"No";
  
  
  
}

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

long long int dp[3010][3010];
int main(){
    long long int N;
    cin >> N;
    long long int i,j;
    long long int a[N];
    for(i=0;i<N;i++)cin >> a[i];
    for(i=1;i<N+1;i++){//長さでループ
        for(j=0;j<N+1-i;j++){
            if((N-i)%2==0)dp[j][i+j]=max(dp[j][j+i-1]+a[i+j-1],dp[j+1][i+j]+a[j]);
            else dp[j][i+j]=min(dp[j][j+i-1]-a[i+j-1],dp[j+1][i+j]-a[j]);
        }
    }
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
//#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0}; 	

void solve(){
	int n;
	cin>>n;
	unordered_map<string, int> mp;
	while(n--){
		string s;
		cin>>s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	int m=0;
	for(auto it=mp.begin();it!=mp.end();++it){
		int p = it->second;
		m += p*(p-1)/2;
	}
	cout<<m;
}
signed main(){	
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 10660
S = input()

counter = 0

sa = []
sb = []

for i in  range(len(S)):
  if i %2 ==0:
    sa.append(S[i])
  else:
    sb.append(S[i])

sa_0 = sa.count('0')
sa_1 = sa.count('1')
sb_0 = sb.count('0')
sb_1 = sb.count('1')
if sa_0 +sb_1 >= sa_1 +sb_0:
  counter = sa_1 +sb_0
else:
  counter = sa_0 + sb_1
  
print(counter)

Measured memory_bytes: 4052
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day3/problems/D>
問題文============================================================

 えびちゃんは素因数分解マシンの不良品を持っています。
 この機械は、2 以上の自然数 M を与えると O(logM) でその素因数分解を行ってくれますが、
 困ったことに数字以外を表示できないバグがありました。
 
 一般に、M の素因数分解が p1e1×p2e2×…×pKeK (ただし i<j ならば pi<pj、また各 pi は素数) の場合を考えます。
 M を与えると、この機械は i=1 から順に以下のように出力を行います。全ての数字はスペース区切りで表示されます。
 
 ei=1 ならば pi を出力する
 ei>1 ならば pi ei を出力する
 
 たとえば、22 や 2048 を与えると 2 11 と表示され、24 や 54 を与えると 2 3 3 と表示されます。
 
 さて、えびちゃんは表示された素因数分解をメモしておいたのですが、
 与えた自然数をメモしておくのを忘れていたことに気づきました。
 素因数分解のメモが与えられるので、元の自然数としてありえるものがいくつあるかを求めてください。
 ただし、メモが間違っていて、条件を満たす自然数が一つも存在しないこともあります。
 
 また、その個数は非常に大きくなる場合があるので、109+7 (素数) で割ったあまりを出力してください。
 
=================================================================

解説=============================================================

================================================================
*/

#define MAX_N 1000005
bool is_prime[MAX_N];
const ll MOD = 1e9+7;

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

void init(){
    for(int i = 1; i < MAX_N;i++){
        is_prime[i] = IsPrime(i);
    }
}
ll solve(){
    ll N; cin >> N;
    vector<ll> q(N);
    for(auto& in:q)cin >> in;

    if(!is_prime[q[0]]) return 0;
    if(N == 1) return 1;
    
    int cnt = 0;
    for(int i = 0; i < N;i++){
        if(!is_prime[q[i]]) cnt++;
        else cnt = 0;
        if(cnt == 2) return 0;
    }

    vector<ll> dp(N+1,0);
    dp[0] = 1;
    for(int i = 0; i < N;i++){
        if(is_prime[q[i]]){
            if( i+1 < N && is_prime[q[i+1]] && (q[i] < q[i+1])){
                (dp[i+1] += dp[i])%=MOD;
            }
            if( i+2 < N && is_prime[q[i+2]] && (q[i] < q[i+2])){
                (dp[i+2] += dp[i])%=MOD;
            }
        }
    }
    return (dp[N-1]+dp[N-2])%MOD;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    cout << solve() << endl;
	return 0;
}



Measured memory_bytes: 5476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7

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

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

const int MAX_N = 110;
struct edge {int to, cost;};
vector< vector<edge> > es;
ll d[10][10];
int cnt[10];
int H, W;

void warshallfloyd() {
    REP(j, 10) {
        REP(i, 10) {
            REP(k, 10) {
                chmin(d[i][k], d[i][j]+d[j][k]);
            }
        }
    }
}

int main() {
    cin >> H >> W;
    REP(i, 10) {
        REP(j, 10) {
            cin >> d[i][j];
        }
    }
    
    memset(cnt, 0, sizeof(cnt));
    REP(i, H) {
        REP(j, W) {
            int ind;
            cin >> ind;
            if (ind == -1) continue;
            cnt[ind] += 1;
        }
    }
	
    warshallfloyd();
    int ans = 0;
    REP(i, 10) {
        ans += cnt[i]*d[i][1];
    }
    cout << ans << endl;
    return 0;
}      

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int n;
	cin>>n;
	while(n>0)
	{
		int r=n%10;
		if(r==7){
		cout<<"Yes"<<endl;
		return 0;
	}
		n=n/10;
	}
	cout<<"No"<<endl;
	
		
	
	
	return 0;
}


Measured memory_bytes: 3644
def main():
    white_num, black_num = map(int, input().split())
    data = [['.' for i in range(100)] for j in range(50)] + [['#' for i in range(100)] for j in range(50)]

    black_change = black_num - 1
    count = 0
    for i in range(black_change // 25 + 1):
        high = i  * 2
        for j in range(50):
            width = j * 2
            if count == black_change:
                break
            count += 1
            data[high][width] = '#'
        if count == black_change:
            break

    black_change = white_num - 1
    count = 0
    for i in range(black_change // 25 + 1):
        high = i * 2 + 51
        for j in range(50):
            width = j * 2
            if count == black_change:
                break
            count += 1
            data[high][width] = '.'
        if count == black_change:
            break

    print(100, 100)
    for i in range(100):
        print(''.join(data[i]))


if __name__ == '__main__':
    main()



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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> a(M);
  vector<int> b(M);
  
  for (int i = 0; i < M; i++) {
	cin >> a.at(i) >> b.at(i);
  }
  //道路の要素
  vector<int> city(N);
  //都市の要素
  for (int i = 0; i < N; i++) {
    city.at(i) = 0;
  }
  //すべての都市の道路は０
  for (int i = 0; i < N; i++) {//都市iの場合
	for (int j = 0; j < M; j++) {//j番目の道路洗い出し
      if ( a.at(j) == i+1 ) { //i番目の都市に該当すればカウント
        city.at(i) = city.at(i) + 1;
      }
      else if ( b.at(j) == i+1 ) { //i番目の都市に該当すればカウント
        city.at(i) = city.at(i) + 1;
      }
    }
  }
 
  for (int i = 0; i < N; i++) {
    cout << city.at(i) << endl;
  } 
       
}


Measured memory_bytes: 256
# include "cstdio"

const int Inf=0x7fffffff; 

int N,T,Ans;

inline int min(int x,int y){
	return x<y?x:y; 
} 

int main(){
	register int i;
	int x,y;
	scanf("%d%d",&N,&T);
	Ans=Inf; 
	for(i=1;i<=N;i++){
		scanf("%d%d",&x,&y);
		if(y<=T){
			Ans=min(Ans,x);
		}
	}
	if(Ans==Inf){
		printf("TLE");
	}else{
		printf("%d",Ans);
	}
	return 0; 
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	for(int i=1;i<100000;i++){
		if(floor(i*0.08)==a &&  floor(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n/2){
    if(s[i]!=s[n-1-i]){
      cout << "No" << ln; return 0;
    }
  }
  rep(i,n/2){
    if(s[i]!=s[n/2-1-i]){
      cout << "No" << ln; return 0;
    }
  }
  cout << "Yes" << ln;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String[] st = new String[3];
		int[] n = new int[3];
		do{
			st = sc.nextLine().split(" ");
			for(int i = 0;i<st.length;i++){
				n[i] = Integer.parseInt(st[i]);
			}
			if(n[0]==-1&&n[1]==-1&&n[2]==-1){
				break;
			}else if(n[0]==-1||n[1]==-1){
				sb.append("F\n");
			}else if(n[0]+n[1]>=80){
				sb.append("A\n");
			}else if(n[0]+n[1]>=65){
				sb.append("B\n");
			}else if(n[0]+n[1]>=50){
				sb.append("C\n");
			}else if(n[0]+n[1]>=30){
				if(n[2]>=50){
					sb.append("C\n");
				}else{
					sb.append("D\n");
				}
			}else{
				sb.append("F\n");
			}
		}while(true);
			System.out.print(sb);
	}
}

Measured memory_bytes: 26224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		String n = sc.next();
		if(n.equals("SUN"))
			System.out.println(7);
		else if(n.equals("MON"))
			System.out.println(6);
		else if(n.equals("TUE"))
			System.out.println(5);
		else if(n.equals("WED"))
			System.out.println(4);
		else if(n.equals("THU"))
			System.out.println(3);
		else if(n.equals("FRI"))
			System.out.println(2);
		else if(n.equals("SAT"))
			System.out.println(1);
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string s;
  cin >> s;
  if(s.size() == 3) reverse(all(s));
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
      int a,b,flag;
      char ch;
      cin>>a>>b;
      for(int i= 0;i<a;i++){
            flag = -1;
            for(int j = 0 ; j < b;j++){
                  scanf(" %c",&ch);
                  if(ch == 'c'){
                        cout << '0';
                        flag = 0;
                  }else{
                        if (flag == -1)cout << flag;
                        else cout << ++flag;
                 }
                  if(j!=b-1)cout << ' ';
            }
            cout<<endl;
      }
}

Measured memory_bytes: 1192
def examA():
    N = I()
    if N%2==1:
        print("Red")
    else:
        print("Blue")
    return

def examB():
    N, M = LI()
    D = [True]*M
    for _ in range(N):
        A = LI()
        cur = [False]*M
        for a in A[1:]:
            cur[a-1] = True
        for i in range(M):
            if not cur[i]:
                D[i] = False
    ans = 0
    for d in D:
        if d:
            ans += 1
    print(ans)
    return

def examC():

    return

def examD():

    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 39024
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
  private static void solve(int n, double[] v) {
    PriorityQueue<Double> pq = new PriorityQueue<>(n);
    for (double val : v) {
      pq.add(val);
    }
    while (pq.size() > 1) {
      double v1 = pq.poll();
      double v2 = pq.poll();
      pq.add((v1 + v2) / 2);
    }
    System.out.println(pq.poll());
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] vs = sc.nextLine().split(" ");
    sc.close();
    double[] v = new double[n];
    for (int i = 0; i < n; i++) {
      v[i] = Double.parseDouble(vs[i]);
    }
    solve(n, v);
  }
}

Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct Menu {
  int limit, time;
  int id;
  Menu(int limit, int time, int id) : limit(limit), time(time), id(id) {}
  Menu() {}
};
bool operator<(const Menu &a, const Menu &b) {
  return a.time != b.time ? a.time > b.time : a.id < b.id;
};

struct Order {
  int T;
  Menu menu;
  int id;
  Order(int T, Menu menu, int id) : T(T), menu(menu), id(id) {}
  Order() {}
};
bool operator<(const Order &a, const Order &b) {
  return a.T != b.T ? a.T < b.T : a.menu < b.menu;
}

Menu menu[20];
Order order[1000];
int ok[1000];                   // »Ì¶ðoµIíÁ½Ô
int K[100];
int endTime[100][10];

int main() {
  int n, m;
  int hoge = 0;
  while(cin >> n >> m, n || m) {
    if (hoge++) cout << endl;
    map<string, int> mp;
    REP(i, n) {
      string name;
      cin >> name >> menu[i].limit >> menu[i].time;
      menu[i].id = i;
      mp[name] = i;
    }
    int endnum[m];
    int num = 0;
    REP(i, m) {
      int T;
      cin >> T;
      cin >> K[i];
      REP(j, K[i]) {
        string dish;
        cin >> dish;
        order[num] = Order(T, menu[mp[dish]], i);
        num++;
      }
    }
    sort(order, order+num);
    ll nowtime = 0;
    memset(ok, -1, sizeof(ok));
    REP(i, num) {
      if (ok[i] >= 0) continue;
      nowtime = max(nowtime, (ll)order[i].T);
      //cout << i << " " << nowtime << " " << order[i].id << " " << order[i].menu.time << " " << order[i].menu.id << endl;
      ok[i] = nowtime + order[i].menu.time;
      int cnt = 1;
      for (int j=i+1; j<num && order[j].T<=nowtime && cnt<order[i].menu.limit; ++j) {
        if (order[j].menu.id == order[i].menu.id) {
          //cout << j << endl;
          ok[j] = nowtime + order[i].menu.time;
          cnt++;
        }
      }
      nowtime += order[i].menu.time;
    }
    int ans[m];
    memset(ans, 0, sizeof(ans));
    REP(i, num) {
      ans[order[i].id] = max(ans[order[i].id], ok[i]);
    }
    REP(i, m)
      cout << ans[i] << endl;
  }
}

Measured memory_bytes: 964
n = int(input())
h = [0] + list(map(int, input().split()))
dp = [10**10 for i in range(n+1)]
dp[0] = dp[1] = 0
for i in range(1, n+1):
    if i + 1 <= n:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i] - h[i+1]))
    if i + 2 <= n:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i] - h[i+2]))
print(dp[n])

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

#define jaldi ios_base::sync_with_stdio(false)
#define fr(i,j,n) for(i=j;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define ppii pair<int,int> 
#define ppll pair<long long,long long>
#define ppcc pair<char,char>
#define ppss pair<string,string> 
#define vpll vector<pair<long long,long long>>
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

int main()
{
    jaldi;
    precision(20);
    ll i,j;

    ll n;
    cin>>n;
    
    vll A(n);
    map<ll,ll> mp;

    fr(i,0,n)
        cin>>A[i];
    
    ll ans=0;
    fr(i,0,n)
    {
        ll x=(i+1)+A[i];
        mp[x]++;
        if(mp.find((i+1)-A[i])!=mp.end())
            ans+=mp[(i+1)-A[i]];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod=1e9+7,maxn=1e6+7;
ll ksm(ll a,ll b){return b?ksm(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll n,k;
ll dp[maxn];
int main(){
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i>=1;i--){
        dp[i]=ksm(k/i,n);
        for(int j=2*i;j<=k;j+=i) dp[i]-=dp[j];
        ans=(ans+i*dp[i]%mod)%mod;
    }
    cout<<(ans+mod)%mod;
    return 0;
}


Measured memory_bytes: 4312
import collections
import math

N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
cnt = 0


sumall = 0
for x, y in c.items():
    sumall += (y*(y-1)//2)

for i in range(N):
    print(sumall - c[A[i]] + 1)


Measured memory_bytes: 26772
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s;

	cin >> s;

	if (s[0] != 'a' && s[1] != 'a' && s[2] != 'a') {
		cout << "No" << endl;
	}else if (s[0] != 'b' && s[1] != 'b' && s[2] != 'b') {
		cout << "No" << endl;
	}else if (s[0] != 'c' && s[1] != 'c' && s[2] != 'c') {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

int main() {
	int b,one=0;
	char two='1';
	long long k;
	string s;
	cin>>s>>k;
	b=s.size();
	for(int i=0;i<b;i++){
	    if(s[i]!='1'){
	        one=i;
	        two=s[i];
	        break;
	    }
	}
	if(one>=k)cout<<1;
	else cout<<two;
	return 0;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//---------------------------------------------------------------
//---------------------------------------------------------------

int N;
int p[10];

signed main(){
	cin >> N;
	REP(i, 0, N)	cin >> p[i];
	sort(p, p + 10, greater<>());
	int ans = p[0] / 2;
	REP(i, 1, N) {
		ans += p[i];
	}
	cout << ans << endl;
	
	return 0;
}


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

struct Re{
    int dx;
    int dy;
    int num;
};

int n,x[50],y[50],difx[2000],dify[2000],count=0,pass[50][50],ccc,zerocost;

Re r[2000];

int main(){

    std::cin>>n;

    for(int i=0;i<n;i++){
        std::cin>>x[i]>>y[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                if(!pass[i][j]){
                difx[count]=x[i]-x[j];
                dify[count]=y[i]-y[j];
                if(difx[count]<=0&&dify[count]<=0)
                difx[count]*=-1,dify[count]*=-1;
                if(difx[count]<0&&dify[count]>=0)
                difx[count]*=-1,dify[count]*=-1;
                pass[j][i]=true;
                pass[i][j]=true;
                count++;
                }
            }
        }
    }

    for(int i=0;i<count;i++){
        for(int j=0;j<ccc;j++){
            if(r[j].dx==difx[i]&&r[j].dy==dify[i]){
                r[j].num++;
                goto flag;
            }
        }
        r[ccc].dx=difx[i];
        r[ccc].dy=dify[i];
        r[ccc].num=1;
        ccc++;
        flag:;
    }

    for(int i=0;i<ccc;i++){
        if(zerocost<r[i].num)
        zerocost=r[i].num;
    }

    std::cout<<n-zerocost<<std::endl;

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

constexpr ll MOD = 1'000'000'007;
int N;
ll A[300100];
int cnt[64];

void add(ll x){
    for(int i=0;i<60;++i){
        cnt[i] += (x >> i & 1);
    }
}

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

  scanf("%d", &N);

  for(int i=0;i<N;++i){
      scanf("%lld", &A[i]);
  }

  add(A[N-1]);

  ll res = 0;

  for(int i=N-2;i>=0;--i){
      for(int j=0;j<60;++j){
          if(A[i] >> j & 1){
              res = (res + 1ll * (N - 1 - i - cnt[j]) * mod_expt<ll>(2, j, MOD) % MOD) % MOD;
          }else{
              res = (res + 1ll * cnt[j] * mod_expt<ll>(2, j, MOD) % MOD) % MOD;
          }
      }

      add(A[i]);
  }

  std::cout << res << std::endl;
}


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

int main() {
        int M;
        int N;
        long long a[50];
        long long b[50];
        long long c[50];
        long long d[50];
        long long distance[50];
        int index[50];
        long long mindistance;
        long long temp;
        int i;
        int j;

        scanf("%d %d",&N,&M);

        for(i=0; i<N; i++) scanf("%lld %lld",&a[i],&b[i]);
        for(i=0; i<M; i++) scanf("%lld %lld",&c[i],&d[i]);

        for(i=0; i<N; i++){
                mindistance = 10000000000;
                for(j=0; j<M; j++){
                        temp=a[i]-c[j];
                        if(temp<0) temp=-1*temp;
                        distance[j]=temp;
                        temp=b[i]-d[j];
                        if(temp<0) temp=-1*temp;
                        distance[j]+=temp;
                        if(distance[j]<mindistance)
                        { 
                                index[i]=j+1;
                                mindistance=distance[j];
                        }
                }
                printf("%d\n",index[i]);
        }
        return 0;
}


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

int main() {
    int n;
    int weights[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
    
    while (cin >> n) {
        vector<int> result;
        for (int i = 0; i != 10; ++i) {
            if (n - weights[i] >= 0) {
                n -= weights[i];
                result.push_back(weights[i]);
            }
        }
        sort(result.begin(), result.end());

        for (int i = 0; i != result.size()-1; ++i) {
            cout << result[i] << " ";
        }
        cout << result[result.size()-1];
        cout << endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){ 
  int N;
  cin >> N;
  FOR(i, 1, 50003){
    if((int)(i*1.08) == N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
const int mod=1e9+7;
char c[maxn];
ll pow(ll a,ll b)
{
    ll ans=1;
    a%=mod;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int main()
{
    cin>>c;
    int i,n=strlen(c);
    ll ans=1;
    for(i=n-1; i>=0; i--)
    {
        if(c[i]=='1')
        {
            ans=(ans<<1)%mod;
            ans=(ans+pow(3,(n-i-1)%mod))%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}









Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>

using namespace std;

typedef long long ll;

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    int dp[305][305];
    REP(i, 305)
    {
      REP(j, 305)
      {
        dp[i][j] = 0;
      }
    }
    if (n == 0)
    {
      break;
    }
    vi w = vi(n, 0);
    REP(i, n)
    {
      cin >> w[i];
    }
    for (int width = 2; width < n + 1; width++)
    {
      REP(left, n)
      {
        int right = left + width - 1;
        if (right >= n)
        {
          continue;
        }
        // 間のブロックが全部叩けるかつ両端の重さの差が1以下
        if (dp[left + 1][right - 1] == width - 2 && abs(w[left] - w[right]) <= 1)
        {
          dp[left][right] = width;
        }
        for (int k = left; k < right; k++)
        {
          dp[left][right] = max(dp[left][right], dp[left][k] + dp[k + 1][right]);
        }
      }
    }
    cout << dp[0][n - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3492
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    for(int i=0; i<3; i++){
        if(s[i]==s[i+1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int compara(const void *x, const void *y){
    int a = *((int *)x),b = *((int *)y);
    if(a<b)
        return -1;
    if(a>b)
        return 1;
}

int main(){
    int n;
    scanf("%d",&n);
    int vetor[n+1];
    for(int x=0;x<n;++x)
        scanf("%d",&vetor[x]);
    qsort(vetor,n,sizeof(vetor[0]),compara);
    int valor=0;
    valor = vetor[n-1]-vetor[0];
    printf("%d\n",valor);


    return 0;
}


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

#define int long long

const int MOD = 1e9+7;

string A, B, C;
int N;
vector<vector<int> > dp;

int dfs(int n, int r) {
  if ( dp[n][r] >= 0 ) return dp[n][r];
  if ( n == N-1 ) {
    int ret = 0;
    for ( int i = 1; i <= 9; i++ ) {
      if ( A[n] != '?' && A[n]-'0' != i ) continue;      
      for ( int j = 1; j <= 9; j++ ) {
	if ( B[n] != '?' && B[n]-'0' != j ) continue;
	if ( i+j+r >= 10 ) continue;	
	if ( C[n] == '?' ) {
	  ret++;
	} else {
	  if ( C[n]-'0' == i+j+r ) ret++;	  
	}
	ret %= MOD;
      }
    }
    return dp[n][r] = ret;
  } else {
    int ret = 0;
    for ( int i = 0; i <= 9; i++ ) {
      if ( A[n] != '?' && A[n]-'0' != i ) continue;      
      for ( int j = 0; j <= 9; j++ ) {
	if ( B[n] != '?' && B[n]-'0' != j ) continue;
	if ( C[n] == '?' ) {
	  ret += dfs(n+1, (i+j+r)/10);
	  ret %= MOD;	  
	} else {
	  if ( C[n]-'0' == (i+j+r)%10 ) ret += dfs(n+1, (i+j+r)/10);
	  ret %= MOD;	  
	}
      }
    }

    return dp[n][r] = (ret%MOD);    
  }
}

signed main() {
  while ( cin >> A, A != "0" ) {
    cin >> B >> C;
    N = A.size();
    dp = vector<vector<int> >(N+1, vector<int>(3, -1));    
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());    
    reverse(C.begin(), C.end());

    cout << dfs(0, 0)%MOD << endl;    
  }
  return 0;
}



Measured memory_bytes: 3192
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n;
    ll a[200009];
    ll s=0;
    ll e[100009];
    ll ss[100009];
    cin>>n;
    rep(i,n){
        cin>>a[i];
        s += a[i];
        a[n+i] = a[i];
    }
    rep(i,2*n){
        if(i==0||i==1){
            ss[i] = 0;
        }else{
            ss[i] = ss[i-2]+a[i-2];
        }
    }
    rep(i,n){
        e[i] = s- 2*(ss[i+n]-ss[i+1]);
    }
    rep(i,n){
        if(i!=n-1){
            cout<<e[i]<<" ";
        }else{
            cout<<e[i]<<endl;
        }
    }
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int N,K,tmp,d; cin >> N >> K;
    vector<int> snk(N,0);
    REP(i,K){
      cin >> d;
      REP(j,d){
        cin >> tmp;
        tmp--;
        snk[tmp]++;
      }
    }
    int ans = 0;
    REP(i,N) if(snk[i] == 0) ans++;
    cout << ans;
  	return 0;
}


Measured memory_bytes: 3656
def main():
    N = int(input())
    small = [tuple(map(int, input().split())) for _ in [0]*N]
    large = [tuple(map(int, input().split())) for _ in [0]*N]
    small.sort(key=lambda x: (x[0], x[1]))
    large.sort(key=lambda x: (x[0], x[1]))
    used = [0]*N
    for l in large:
        high = -1
        idx = 0
        for i, s in enumerate(small):
            if (not used[i]) and s[0] < l[0] and s[1] < l[1]:
                if high < s[1]:
                    high = s[1]
                    idx = i
        if high != -1:
            used[idx] = 1
    print(sum(used))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
const int N=1e6+10;
int a,b,c;

int main(){
  cin>>a>>b>>c;
  if(a+b+c>=22)
    cout<<"bust"<<endl;
  else
    cout<<"win"<<endl;

return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    string S;
    cin >> N;
    vector<ll> A(N);
    REP(i, N)
    {
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());

    bool flag = true;

    if (N % 2 == 1)
    {
        REP(i, N)
        {
            if (i % 2 == 0)
            {
                if (A.at(i) == i)
                {
                }
                else
                {
                    flag = false;
                    break;
                }
            }
            else
            {
                if (A.at(i) == (i + 1))
                {
                }
                else
                {
                    flag = false;
                    break;
                }
            }
        }
    }
    else
    {
        REP(i, N)
        {
            if (i % 2 == 0)
            {
                if (A.at(i) == i + 1)
                {
                }
                else
                {
                    flag = false;
                    break;
                }
            }
            else
            {
                if (A.at(i) == i)
                {
                }
                else
                {
                    flag = false;
                    break;
                }
            }
        }
    }

    ll ans = 0;

    if (flag)
    {
        if (N % 2 == 1)
        {
            ans = modpow(2, (N - 1) / 2, MOD);
        }
        else
        {
            ans = modpow(2, N / 2, MOD);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
while 1:
    H, W = map(int,raw_input().split())
    if H + W == 0: break
    for h in range(H):
        if h % 2 == 0:
            if W % 2 == 0:
                print ('#.'*(W//2))
            else:
                print ('#.'*(W//2)+'#')
        else:
            if W % 2 == 0:
                print ('.#'*(W//2))
            else:
                print ('.#'*(W//2)+'.')
    print ''

Measured memory_bytes: 4216
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int H, W, D, Q;
    cin >> H >> W >> D;
    vector<vector<ll>> A(H, vector<ll>(W));
    vector<pair<ll, ll>> ps(H * W + 93000);
    vector<ll> sum(H * W + 93000, 0);
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
            ps[A[i][j]] = {i, j};
        }
    }

    rep(j, H * W) {
        sum[j + D] = sum[j] + abs(ps[j + D].first - ps[j].first) +
                     abs(ps[j + D].second - ps[j].second);
    }

    cin >> Q;
    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<string> W(N);

	REP(i,N) cin >> W[i];

	set<string> st;
	REP(i,N) st.insert(W[i]);

	bool shi = true;
	FOR(i,1,N){
		if(W[i-1].back() != W[i].front()) shi = false;
	}

	if(st.size() == N and shi) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
const ll mod=1e9+7;
const int maxn=10000;
using namespace std;
 bool sortbysec(pair<ll,ll> &a, pair<ll,ll> &b) { 
    return (a.second < b.second); 
} 
 
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
/* #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif */
{ 
  
    
        int nb=10008;
        int v[nb+1];
        for(int i=1;i<=nb;i++)v[i]=0;
        
		for(int x=1;x<=sqrt(nb);x++)
    	{
    		for(int y=1;y<=sqrt(nb);y++)
    	    {
    		    for(int z=1;z<=sqrt(nb);z++)
    	        {
                      int k=x*x+z*z+y*y+x*y+x*z+y*z;
					  if(k<=nb)v[k]++;    		
		        }
		    }
		}
		
	int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cout<<v[i]<<endl;
	}
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  vector<pair<string, int>> p(N);
  for (int i = 0; i < N; i++) {
    string a;
    int b;
    cin >> a >> b;
    p.at(i) = make_pair(a, b);
  }
  string X;
  cin >> X;

  bool flag = false;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    string a;
    int b;
    tie(a, b) = p.at(i);
    if (flag) ans += b;
    if (a == X) flag = true;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, r; cin >> n >> r;
  cout << (n >= 10 ? r : r + 100 * (10 - n)) << '\n';
  return 0;
}


Measured memory_bytes: 256
/* Atcoder abc170c
 * See tasks at: https://atcoder.jp/contests/abc170/tasks/abc170_c
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    int x, n;
    cin >> x >> n;

    set<int> p;
    until(i, n)
    {
        int val;
        cin >> val;
        p.emplace(val);
    }
    
    until(i, 101)
    {
        if (p.find(x - i) == p.end())
        {
            cout << x - i;
            break;
        }
        if (p.find(x + i) == p.end())
        {
            cout << x + i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
from itertools import chain

# import numpy as np
# from itertools import combinations as comb
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(N: int, M: int, P: "List[int]", S: "List[str]"):
    ac = [0] * N
    wa = [0] * N
    for p, s in zip(P, S):
        if s == "AC":
            ac[p - 1] = 1
        else:  # WA
            if ac[p - 1] == 0:
                wa[p - 1] += 1
    for i in range(N):
        if ac[i] == 0:
            wa[i] = 0

    return sum(ac), sum(wa)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]"
    S = [str()] * (M)  # type: "List[str]"
    for i in range(M):
        P[i] = int(next(tokens))
        S[i] = next(tokens)
    a1, a2 = solve(N, M, P, S)
    print(a1, a2)


if __name__ == "__main__":
    main()


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

int main() {
    cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);
  double a, b, C, S, L, h;
  cin >> a >> b >> C;
  C = M_PI * (C / 180.);
  S = a * b * sin(C) / 2;
  L = a + b + sqrt(a * a + b * b - 2 * cos(C) * a * b);
  h = 2 * S / a;
 
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;
}


Measured memory_bytes: 3520