akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}



//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
*/



int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);


string S;
  cin>>S;
  if(S=="RRR"){
    cout<<3<<endl;
  }else if(S=="RSR"){
    cout<<1<<endl;
  }else if(S=="RRS"){
    cout<<2<<endl;
  }else if(S=="SRR"){
    cout<<2<<endl;
  }else if(S=="SSS"){
    cout<<0<<endl;
  }else{cout<<1<<endl;
       }
  
  
    
}




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

int a[105], e[105];

int main()
{
	int n, s=0;
	cin >> n;
	
	for (int i=1; i<=n; i++)
	{	
		cin >> a[i];
		if (a[i]%2==0)
			if (a[i]%3!=0 && a[i]%5!=0)
				s++;
	}
		
	if (s==0)
		cout << "APPROVED";
	else
		cout << "DENIED";
		
	return 0;
}

Measured memory_bytes: 256
/*
 *	Argorithms and Data Structures
 *	Lectuire 1
 *	Insertion Sort
 */

#include <stdio.h>

#define ARRAYMAX 1000

void display_array(int*, int);

int main(void){
	int i, j, v, N, A[ARRAYMAX];
	
	scanf("%d",&N);
	for( i=0; i<N; i++) scanf("%d", &A[i]);

	display_array(A, N);

	for( i=1; i<N; i++){
		v = A[i];
		j = i-1;
		while( j>=0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		display_array(A, N);
	}
	return 0;
}

void display_array(int A[], int N){
	int i;
	for( i=0; i<N-1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[i]);
}

Measured memory_bytes: 604
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int n;
int m;
vector<int> g[100000+10];
vector<int> rg[100000+10];

int memo[100000+10];
int parent[100000+10];

int go(int u) {
  int &res = memo[u];
  if(res < 0) {
    res = 0;
    parent[u] = -1;
    REP(i, rg[u].size()) {
      int v = rg[u][i];
      int cur = go(v) + 1;
      if(res < cur) {
        res = cur;
        parent[u] = v;
      }
    }
  }
  return res;
}

int main(void) {
  scanf("%d%d", &n, &m);
  REP(i, n-1+m) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    rg[b].push_back(a);
  }

  memset(memo, -1, sizeof memo);
  REP(i, n) {
    go(i);
  }
  REP(i, n) {
    printf("%d\n", parent[i]+1);
  }
  
  return 0;
}


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

int main() {
  int N, i=0;
  char S;
  cin >> N;
  
  for(; i<N; i++) {
    cin >> S;
    if(S == 'Y') {
      cout << "Four" << endl;
      break;
    }
  }
  
  if(i == N)
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int ans=0,n,v[114],c[514];
	cin>>n;
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++)cin>>c[i];
	for(int i=0;i<n;i++)ans+=v[i]>c[i]?v[i]-c[i]:0;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const ll inf=ll(1e18)+1;

int main(){
  ll n,k; cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  ll l=-inf,r=inf;
  while(r-l!=1){
    ll x=(l+r)/2;
    bool ok=[&]{
      ll cnt=0;
      rep(i,n){
        ll l=-1,r=n;
        if(a[i]<0){
          while(r-l!=1){
            ll mid=(l+r)/2;
            if(a[i]*a[mid]<=x) r=mid;
            else l=mid;
          }
          cnt+=n-r;
        }
        else{
          while(r-l!=1){
            ll mid=(l+r)/2;
            if(a[i]*a[mid]<=x) l=mid;
            else r=mid;
          }
          cnt+=r;
        }
        if(a[i]*a[i]<=x) cnt--;
      }
      cnt/=2;
      return cnt>=k;
    }();
    if(ok) r=x;
    else l=x;
  }
  cout << r << endl;
  
}

Measured memory_bytes: 1792
count = int(input());
data = [int(n) for n in input().split(" ")];

def insert_sort(data):
    show(data);
    for i in range(1, len(data)):
        n = data[i];
        j = i - 1;
        while j >= 0 and data[j] > n:
            data[j + 1] = data[j];
            j -= 1;
        data[j + 1] = n;
        show(data);

def show(data):
    print(" ".join(str(n) for n in data));

insert_sort(data);


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string n;
  cin>>n;
  if(n.find("7")!=string::npos)
    cout << "Yes" <<endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main(){
    int n,m ;
    int ans = 0 ;
    cin >>n >> m ;
    vector<vector<int> > s(m,vector<int>(n,-1)) ;
    vector<int> k(m,0) ;
    for (size_t i = 0; i < m; i++)
    {
        cin >> k.at(i) ;
        for (size_t j = 0; j < k.at(i); j++)
        {
            cin >> s.at(i).at(j) ;
        }
        
    }
    vector<int> p(m);
    for (size_t i = 0; i < m; i++)
    {
        cin >> p.at(i) ;
    }
    
    int c = pow(2,n) ;
    //2進数表記をスイッチのオンオフに対応させて考えるぞ！
    int judge(int num, int switchnum) ;
    /*  */
    //全ての場合について
    for (size_t i = 0; i < c; i++)
    {
        bool through = false ;
        //全ての電球について
        for (size_t j = 0; j < m; j++)
        {
            //関連するスイッチのオンの数を調べる
            int oncount = 0 ;
            for (size_t l = 0; l <k.at(j) ; l++)
            {
                if (judge(i,s.at(j).at(l)) == 1)
                {
                    oncount ++ ;
                }
                
            }
            //電球が点灯しているか調べる
            
            if (oncount % 2 != p.at(j))
            {
                //点灯してない時は飛ばす
                through = true ;
                continue ;
            }
            
        }
        //ここまで来るのは電球が全部点灯している時
        if (through == true)
        {
            continue ;
        }
        
        ans ++ ;
    }
    cout << ans << endl ;
    
}
int judge(int num,int switchnum){
    int show = num / pow(2,switchnum-1) ;
    return show % 2 ;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
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; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    ll x;
    cin >> x;
    ll sum = 0;
    for(ll i = 1; ;i++){
        sum += i;
        if(sum >= x){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int h=in.nextInt();
			if((n|h)==0)
				return;
			boolean xy[][]=new boolean[n+1][n+1];
			boolean xz[][]=new boolean[n+1][n+1];
			boolean yz[][]=new boolean[n+1][n+1];
			int cnt=n*n*n;
			for(int i=0;i<h;i++)
			{
				String st=in.next();
				int a=in.nextInt();
				int b=in.nextInt();
				if(st.equals("xy"))
				{
					for(int z=1;z<=n;z++)
						if(!(xz[a][z]||yz[b][z]))
							cnt--;
					xy[a][b]=true;
				}
				else if(st.equals("xz"))
				{
					for(int y=1;y<=n;y++)
						if(!(xy[a][y]||yz[y][b]))
							cnt--;
					xz[a][b]=true;
				}
				else 
				{
					for(int x=1;x<=n;x++)
						if(!(xy[x][a]||xz[x][b]))
							cnt--;
					yz[a][b]=true;
				}
			}
			System.out.println(cnt);
		}
	}
}

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

const int MAXN = 1e5 + 5;
int n, k, m, p;
int ans = 1e9 + 7;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == 1)
            p = i;
    }
    for (int i = 0; i < k; i++) {
        int x = max(p - i, 0);
        int y = max(n - p - 1 - (k - 1 - i), 0);
        ans = min(ans, 1 + ((x + k - 2) / (k - 1) + (y + k - 2) / (k - 1)));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=200010;
int n;
long long a[MAXN];
long long ans=0;
int main()
{
    read(n);
    for(int i=1;i<=n;++i) read(a[i]);
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<n;++i) ans+=a[(i+2)/2];
    write(ans),putchar('\n');
	return 0;
}


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

int bubble(int n, char a[], int b[]){
    for(int i = 0; i < n; i++){
        for(int j = n-1; j > 0; j--){
            if(b[j] < b[j-1]){
                swap(b[j], b[j-1]);
                swap(a[j], a[j-1]);
            }
        }
    }
    return 0;
}
int selection(int n, char a[], int b[]){
    int minj;
    for(int i = 0; i < n; i++){
        minj = i;
        for(int j = i+1; j < n; j++){
            if(b[minj] > b[j]){
                minj = j;
            }
        }
        if(minj == i){
            continue;
        }
        else{
            swap(b[i], b[minj]);
            swap(a[i], a[minj]);
        }
        
    }
    

    return 0;
}
bool isstable(int n, char a[], char b[]){
    for(int i = 0; i < n; i++){
        if(a[i] != b[i]){
            return false;
        }
    }
    return true;
}
int main(void){
    int n;
    cin >> n;
    int b[n]; 
    int b1[n];
    char c[n];
    for(int i = 0; i < n; i++){
        cin >> c[i] >> b[i];
    }
    char c1[n];
    for(int i = 0; i < n; i++){
        c1[i] = c[i];
        b1[i] = b[i];

    }
    
    bubble(n, c1, b1);
    selection(n, c, b);
    
    for(int i = 0; i < n; i++){
        if(i == 0){
            cout << c1[i] << b1[i];
        }
        else{
            cout << ' ' << c1[i] << b1[i];
        }
    }
    cout << endl << "Stable" << endl;
    for(int i = 0; i < n; i++){
        if(i == 0){
            cout << c[i] << b[i];
        }
        else{
            cout << ' ' << c[i] << b[i];
        }
    }
    if(isstable(n, c1, c)){
        cout << endl << "Stable" << endl;
    }
    else{
        cout << endl << "Not stable" << endl;
    }
}



Measured memory_bytes: 3076
def f(point, arr)
  result = arr.inject(0){|result, item|
    result + (item-point)**2
  }
  return result
end
def re(low, high, arr)
  return f(((high-low)/2)+low, arr) if high-low <= 2
  mid_left = ((low * 2) + high) / 3
  mid_right = (low + (high * 2)) / 3
  if f(mid_left, arr) >= f(mid_right, arr)
    re(mid_left, high, arr)
  else
    re(low, mid_right, arr)
  end
end
n = gets.chop.to_i
arr = gets.chop.split.map(&:to_i)

print re(arr.min, arr.max, arr)

Measured memory_bytes: 1788
#include <iostream>
#include <vector>

typedef struct _POS{
	int x,
		y;
}POS;

POS incl[4] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int main()
{
	int n,
		num,
		d,
		term[4] = {0, 0, 0, 0};
	POS tmp;
	std::vector<POS> p;
	while(true){
		tmp.x = tmp.y = 0;
		p.push_back(tmp);
		std::cin >> n;
		if(n==0) break;
		for(int i=1; i<n; i++){
			std::cin >> num >> d;
			tmp.x = p[num].x+incl[d].x;
			tmp.y = p[num].y+incl[d].y;
			
			if(tmp.x < term[0]) term[0] = tmp.x;
			else if(tmp.x > term[1]) term[1] = tmp.x;

			if(tmp.y < term[2]) term[2] = tmp.y;
			else if(tmp.y > term[3]) term[3] = tmp.y;

			p.push_back(tmp);
		}
		p.clear();
		std::cout << -term[0]+term[1]+1 << ' ' << -term[2]+term[3]+1 << std::endl;
		term[0] = term[1] = term[2] = term[3] = 0;
	}
	return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

     class Main{
        public static void main(String args[]){
           Scanner sc = new Scanner(System.in);

           int x,i,j,y,n;

           x = sc.nextInt();

           int[][]c = new int[4][13];

           for(i=0;i<4;i++){
              for(j=0;j<13;j++){
              c[i][j]=0;
              }
           }

           for(y=0;y<x;y++){
              String m = sc.next();
              n = sc.nextInt()-1;

              if(m.equals("S")){
              c[0][n]=1;
              }
              if(m.equals("H")){
              c[1][n]=1;
              }           
              if(m.equals("C")){
              c[2][n]=1;
              }
              if(m.equals("D")){
              c[3][n]=1;
              }
           
           } 
          
           for(i=0;i<4;i++){
              for(j=0;j<13;j++){
                  if(c[i][j]==0){
                     if(i==0){
                     System.out.println("S"+" "+(j+1));
                     }
                     if(i==1){
                     System.out.println("H"+" "+(j+1));
                     }
                     if(i==2){
                     System.out.println("C"+" "+(j+1));
                     }
                     if(i==3){
                     System.out.println("D"+" "+(j+1));
                     }
                  }
              }

           }


        }
     }



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


int main() {
    int N;
    cin>>N;
    vector<long long> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }

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

    int count=1;
    int val=0;
    for(int i=1;i<N;i++){
        if(A.at(i)==A.at(i-1)){
            count++;
        }else{
            if(count%2!=0){
                val++;
            }
            count=1;
        }
        if(i==(N-1)){
            if(count%2!=0){
                val++;
            }
            count=1;
        }
    }
    cout<<val<<endl;

    return 0;



}


Measured memory_bytes: 1024
/*************************************************************************
  > File Name: c.cpp
  > Author: Samuel
  > Mail: enminghuang21119@gmail.com
  > Created Time: Sun Mar 22 20:08:06 2020
*************************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double a;
    cin >> a;
    cout << fixed << setprecision(7) <<  a * a * a / 27 << '\n';
    return 0;
}


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

vector<long> yakusu(long n){
  vector<long> p;
  for(int i = 1;i*i <= n;i++){
      if(n % i == 0){
      p.push_back(i);
      if(i*i != n){
        p.push_back(n/i);
      }
    }
  }
  return p;
}

int main(){
  int n,k;
  cin >> n >> k;
  long sum = 0;
  vector<long> a(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  vector<long> p = yakusu(sum);
  sort(p.begin(),p.end());
  long ans = 1;
  for(int i = 0;i < p.size();i++){
    long r[n];
    long num = 0,negasum = 0,posisum = 0;
    for(int j = 0;j < n;j++){
      r[j] = a[j]%p.at(i);
      posisum += (p.at(i) - r[j])%p.at(i);
    }
    sort(r,r+n);
    num = posisum;
    for(int j = 0;j < n;j++){
      posisum -= (p.at(i) - r[j])%p.at(i);
      negasum += r[j];
      long cur = max(posisum,negasum);
      num = min(num,cur);
    }
    if(num <= k) ans = max(ans,p.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# 解答
def abc173_a(lines):
    N = int(lines[0])
    values = map(int, lines[1].split(' '))
    answer = 0
    tmp = list()
    for value in values:
        tmp.append(value)
    for i in range(N):
        if i % 2 != 0:
            pass
        else:
            if tmp[i] % 2 != 0:
                answer += 1
    return [answer]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5', '1 3 4 5 7']
        lines_export = [2]
    elif pattern == 2:
        lines_input = ['15', '13 76 46 15 50 98 93 77 31 43 84 90 6 24 14']
        lines_export = [3]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = abc173_a(lines_input)

    for line_result in lines_result:
        print(line_result)

    if mode > 0:
        print(f'lines_input=[{lines_input}]')
        print(f'lines_export=[{lines_export}]')
        print(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            print('OK')
        else:
            print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9276
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;

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

    string s;
    while (cin >> s)
    {
        ll ans = 0;
        int n = s.size();

        string t;
        for (int i = 0; i < n - 1; i++)
        {
            if (s[i] == 'B' and s[i + 1] == 'C')
            {
                t.push_back('X');
                ++i;
            }
            else
                t.push_back(s[i]);
        }

        ll c = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (t[i] == 'A')
                ++c;
            else if (t[i] == 'X')
                ans += c;
            else
                c = 0;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a>>b>>c;

    if(c-(a-b)<0)cout << "0" << endl;
    else cout << c-(a-b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                   // below comment for pbds
#include<ext/pb_ds/assoc_container.hpp>   // to use it make ordered_set
#include<ext/pb_ds/tree_policy.hpp>       // all set fnct + = 1. order_of_key(x); // number of 
#define ll long long                      //element strictly smaller than it;
#define ld long double                    // 2. find_by_order(x),pointer el at x pos after sort  use as s.f();
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;                     
using namespace __gnu_pbds;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.flush();
	ll t=1;
	ll CaseN=1; 
	//cin>>t;
	while(t--)
	{
		ll k,a,b;
		cin>>k>>a>>b;
		bool ans=false;
		for(ll i=a;i<=b;i++)
		{
		if(i%k==0)
		{
			ans =true;
			}	
		}
		
		
		if(ans)
{ cout<<"OK"<<endl;  }
else
{cout<<"NG"<<endl;}
		
		//cout<<"Case #"<<CaseN<<": ";
		CaseN++;
		// print your ans below;
		
	}

return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {

	public static void  main(String[] args) {
		scan();
		
		
		
	}
	
	public static void scan() {
		Scanner scanner = new Scanner(System.in);
		while(true){
			int H = scanner.nextInt();
			int W = scanner.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			draw(H , W);
			System.out.println("");
		}	
		scanner.close();
		return;
	}

	public static void draw(int  H , int W) {
		for(int y = 0 ; y < H ; y++){	
			for(int x = 0 ; x < W ; x++){
				if(y % 2 == 0){
					if(x % 2 == 0){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}
				else{
					if(x % 2 != 0){
						System.out.print("#");
					}
					else{
						System.out.print(".");
					}
				}	
			}
			System.out.println("");
		}
		return ;
	}
	
}

Measured memory_bytes: 34848
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main(){
 int64_t N,ans=0,cash=100;
  cin>>N;
  //vector<int> A(N);
 // for(int i=0; i<1000000; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  while(true){
    ans++;
    cash+=floor(cash*0.01);
    if(cash>=N){cout<<ans<<endl;break;}
  }
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int a = in.nextInt();
        int b = in.nextInt();
        boolean flag = true;
        for (int i = 1; i < 1010 ; i++) {
            if (Math.floor(i * 0.08) == a && Math.floor(i * 0.1) == b) {
                System.out.println(i);
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println(-1);
        }
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

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

using namespace std;

using ll = long long;
using ll128 = long long;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<ll128> a(n);
    for (int i = 0; i < n; i++)
    {
        int tmp;cin>>tmp;
        a[i] = tmp;
    }
    // dp0[i][j] := 左から降順にして,i番目をj回4倍するときの最小回数
    vector<vector<ll>> dp0(n, vector<ll>(16, 1e15)), dp1(n, vector<ll>(16, 1e15));
    for (int j = 0; j <= 15; j++)
    {
        dp0[0][j] = j;
        dp1[n - 1][j] = j;
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j <= 15; j++)
        {
            for (int k = 0; k <= 15; k++)
            {
                // a[i-1] * 4^k, a[i] * 4^j
                ll128 pre = a[i - 1] << (2 * (k - min(j, k)));
                ll128 cur = a[i] << (2 * (j - min(j, k)));
                ll cnt = 0;
                while (pre < cur)
                {
                    cnt += i;
                    pre *= 4;
                }
                dp0[i][j] = min(dp0[i][j], dp0[i - 1][k] + cnt + j);
            }
        }
    }
    for (int i = n - 2; i >= 0; i--)
    {
        for (int j = 0; j <= 15; j++)
        {
            for (int k = 0; k <= 15; k++)
            {
                // a[i+1] * 4^k, a[i] * 4^j
                ll128 pre = a[i + 1] << (2 * (k - min(j, k)));
                ll128 cur = a[i] << (2 * (j - min(j, k)));
                ll cnt = 0;
                while (cur > pre)
                {
                    cnt += n - i - 1;
                    pre *= 4;
                }
                dp1[i][j] = min(dp1[i][j], dp1[i + 1][k] + cnt + j);
            }
        }
    }
    ll ret = min(2 * dp1[0][0], 2 * dp0[n - 1][0] + n);
    // i 番目から正
    for (int i = 1; i < n; i++)
    {
        ret = min(ret, 2 * dp0[i - 1][0] + i + 2 * dp1[i][0]);
    }
    cout << ret << endl;
}


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

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

    ll x; cin >> x;

    int y = 0;
    ll balance = 100;
    while(balance < x){
        long double t = 1.01*balance;
        balance = t;
        y++;
    }
    cout << y << "\n";


    return 0;
}


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

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

int main() {
  // 小数点以下10桁まで
  // cout << fixed << setprecision(10);

  int N, M;
  std::cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(19));
  for (size_t i = 0; i < M; i++) {
    std::cin >> k.at(i);
    k.at(i);
    for (size_t j = 0; j < k.at(i); j++) {
      std::cin >> s.at(i).at(j);
      s.at(i).at(j) -= 1;
    }
  }
  vector<int> p(M);
  for (size_t i = 0; i < M; i++) {
    std::cin >> p.at(i);
  }

  int count = 0;
  // {0, 1, ..., N-1} の部分集合の全探索
  for (size_t bit = 0; bit < (1<<N); bit++) {
    bool all = true;
    for (size_t i = 0; i < M; i++) {
      int sum = 0;
      for (size_t j = 0; j < k.at(i); j++) {
        if (bit & 1<<s.at(i).at(j)) sum+=1;
      }
      if (sum%2 != p.at(i)) all = false;
    }
    if (all) count+=1;
  }

  cout << count << endl;
}


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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

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

  vll as(n);
  rep(i, n) cin >> as[i];

  vll dp(n, INF);

  dp[0] = as[0];
  rep(i, n) {
    ll idx = Lower_bound(dp, as[i]);
    dp[idx] = as[i];
  }

  printf("%ld\n", Lower_bound(dp, INF));

  return 0;
}



Measured memory_bytes: 4408
N = gets.to_i
a = []
N.times do |i|
  a[i] = gets.to_i
end

m = a.max(2)
cnt = a.count(m[0])

a.each do |x|
  if cnt == 1 && x == m[0]
    puts m[1]
  else
    puts m[0]
  end
end

Measured memory_bytes: 5244
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	sort(a.rbegin(),a.rend());
	ll t=a[0];
	for(int i=2;i<n;i++) t+=a[i/2];
	cout<<t<<endl;
}

Measured memory_bytes: 3996
n = int(input())
p = list(map(int, input().split()))

mv_left = [float("inf")] * n
for j in range(n):
    if j == 0:
        mv_left[j] = p[j]
    else:
        mv_left[j] = min(p[j], mv_left[j - 1])

# print(p)
# print(mv_left)

count = 0
for i in range(n):
    if p[i] <= mv_left[i]:
        count += 1
print(count)

Measured memory_bytes: 79568
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
using ll=long long;

int main(){
    string s;
    cin>>s;
    ll sum=0;
    ll max_v=0;
    bool flag=false;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R'){
            if(flag){
                sum++;
            }else{
                flag=true;
                sum=1;
            }
        }
        if(s[i]=='S'){
            sum=0;
            flag=false;
        }
        max_v=max(max_v,sum);
    }
    cout<<max_v<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>

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

using namespace std;

int main(void) {
  string s;
  int array[26] = {0};
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    array[(int)s[i] - 97]++;
  }
  for (int i = 0; i < 26; i++) {
    if (array[i] % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from collections import Counter

def nC2(n):
    return n * (n - 1) // 2

N = int(input())
A = [int(i) for i in input().split()]

C = Counter([0] + list(accumulate(A)))

ans = 0
for v in C.values():
    ans += nC2(v)

print(ans)


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

using namespace std;

int main() {
	string str, method, p;
	int a, b, q, i, j;

	cin >> str >> q;

	for (i = 0; i < q; i++) {
		cin >> method >> a >> b;

		if (method == "print") {
			for (j = a; j <= b; j++) {
				cout << str[j];
			}
			cout << endl;
		}
		else if (method == "reverse") {
			reverse(str.begin() + a, str.begin() + b + 1);
		}
		else if (method == "replace") {
			cin >> p;
			str.replace(a, b - a + 1, p);
		}
	}

	return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

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

  ll ans,sum_min,sum_max;
  ans = sum_min = sum_max = 0;
  REP(i,K-1) { sum_min += i; sum_max += N - i; }
  REP(i,K-1,N+1) { ans = (ans + (sum_max += N - i) - (sum_min += i) + 1) % 1000000007; }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int goal = scan.nextInt();
        int[][] shop = new int[NUM][2];
        for(int i = 0; i < NUM; i++){
            shop[i][0] = scan.nextInt();
            shop[i][1] = scan.nextInt();
        }

        // sort
        Arrays.sort(shop, (a, b) -> Integer.compare(a[0], b[0]));

        // search
        long money = 0;
        for(int i = 0; i < NUM; i++){
            if(shop[i][1] <= goal){
                goal -= shop[i][1];
                money += (long)shop[i][0] * (long)shop[i][1];
                shop[i][1] = 0;
            } else {
                while(goal > 0 && shop[i][1] > 0){
                    goal -= 1;
                    money += shop[i][0];
                    shop[i][1] -= 1;
                }
            }
            if(goal <= 0){
                break;
            }
        }

        // answer
        System.out.println(money);

    }
}

Measured memory_bytes: 92808
n, m, x = map(int, input().split(' '))
fee_points = [x for x in map(int, input().split(' '))]
root = []
for i in range(0, n):
    if i in fee_points:
        root.append(1)
    else:
        root.append(0)

if sum(root[:x]) >= sum(root[x:]):
    print(sum(root[x:]))
else:
    print(sum(root[:x]))

Measured memory_bytes: 3064
import sys
from itertools import combinations_with_replacement
def input(): return sys.stdin.readline().strip()


def main():
    N, M, Q = map(int, input().split())
    pair = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        pair.append((a-1, b-1, c, d))

    LIST = [i for i in range(1, M + 1)]
    ans = 0
    for A in list(combinations_with_replacement(LIST, N)):
        val = 0
        for a, b, c, d in pair:
            if A[b] - A[a] == c:
                val += d
        ans = max(ans, val)
        #print("val={}, A={}".format(val, A))
    print(ans)



    


if __name__ == "__main__":
    main()

Measured memory_bytes: 87100
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
//scanf("%lld",&a);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v,u;
    pair<long long, long long>n;
    set<string>y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r=0,z,m,h,p[8]={1800,1600,1400,1200,1000,800,600,400};
    string t,s,x,q;
    double w;
    cin>>a;
    for(i=0;i<8;i++){
        if(p[i]<=a){
            cout<<i+1<<endl;
            stop;
        }
    }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<string>
#include<map>
#include<queue>

using namespace std;

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

class S{
	public:
	
	string a;
	int b;
	
	S(){}
	S(string a,int b):a(a),b(b){}
};


char nn[333][333];

int main(){
	
	nn['r']['g']='b';
	nn['g']['r']='b';
	
	nn['g']['b']='r';
	nn['b']['g']='r';
	
	nn['b']['r']='g';
	nn['r']['b']='g';
	
	while(1){
		string a;
		cin>>a;
		
		if(a=="0")break;
		
		map<string,int> ch;
		
		queue<S> que;
		que.push(S(a,0));
		
		while(1){
			if(que.empty()){
				cout<<"NA"<<endl;
				break;
			}
			
			S u = que.front();
			que.pop();
			
			if(ch[u.a]==1)continue;
			ch[u.a]=1;
			
			int flg=1;
			rep(i,u.a.size()-1){
				if(u.a[i] != u.a[i+1]){
					flg=0;
					break;
				}
			}
			if(flg==1){
				cout<<u.b<<endl;
				break;
			}
			
			rep(i,u.a.size()-1){
				if(u.a[i]!=u.a[i+1]){
					string b = u.a;
					b[i] = nn[u.a[i]][u.a[i+1]];
					b[i+1] = nn[u.a[i]][u.a[i+1]];
					
					que.push(S(b,u.b+1));
				}
			}
			
		}
	}
}

Measured memory_bytes: 0
"use strict";
function main(input) {
  const k = parseInt(input[0]);
  let i = 1;
  let runruncounter = 0;
  while(true){
    const j =  (i+"").split("").map(a => parseInt(a));
    let judge = true;

    for(let l=1;l<j.length;l++){
      //console.log(i);
      if(Math.abs(j[l]-j[l-1])>1){
        judge = false;
        if(j[l]===9){
          j[l-1]+=1;
          j[l]=0;
        }else{
          j[l]+=1;
        }
        //console.log(i +" " + j + " " + runruncounter  )
        i = parseInt(j.join(""));
        break;
      }
    }

    if(judge){
      runruncounter++;
      if(runruncounter===k){
        console.log(i);
        break;
      }
      i++;
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 22276
import sys
N = int(input())

AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))

AB.sort(key=lambda t:t[1])

t = 0
for t_job, t_dead in AB:
    t += t_job
    if (t_dead < t):
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 31824
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Control.Monad

type Parent = VUM.IOVector Int

makeUF :: Int -> IO Parent
makeUF n = do
    par <- VU.unsafeThaw $ VU.generate n id
    return par

root :: Int -> Parent -> IO Int
root x par = do
    r <- VUM.read par x
    if x == r
        then return x
        else do
            newr <- root r par
            VUM.write par x newr
            return newr

same :: Int -> Int -> Parent -> IO Bool
same x y par = do
    rx <- root x par
    ry <- root y par
    return $ rx == ry

unite :: Int -> Int -> Parent -> IO ()
unite x y par = do
    x' <- root x par
    y' <- root y par
    when (x' /= y') $ VUM.write par x' y'

toTuple :: B.ByteString -> (Int, Int)
toTuple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
    in
        (a, b)

main = do
    (n,m) <- toTuple <$> B.getLine 
    es <- VU.replicateM m (toTuple <$> B.getLine)
    let es' = VU.map (\(a,b) -> (a-1,b-1)) es
    xs <- forM [0..m-1] $ \i -> do
            par <- makeUF n
            forM_ [0..m-1] $ \j -> do 
                let (a,b) = es' VU.! j
                when (i/=j) $ unite a b par
            par' <- VU.unsafeFreeze par
            let res = VU.length $ VU.filter id $ VU.zipWith (==) par' (VU.fromList [0..n-1])
            return $ res > 1 
    print $ length [() | x<-xs, x]

Measured memory_bytes: 764
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readString() -> String {
    return readLine()!
}

func readLines(times: Int) -> [String] {
    var array = [String]()
    for _ in 0..<times {
        array.append(readLine()!)
    }
    return array
}

func readSeparatedStrings() -> [String] {
    return readLine()!.split(separator: " ").map {String($0)}
}

func readStringToStrings() -> [String] {
    return readLine()!.map{String($0)}
}

func readSeparatedInts() -> [Int] {
    return readLine()!.split(separator: " ").map {Int($0)!}
}
func readSeparatedDouble() -> [Double] {
    return readLine()!.split(separator: " ").map {Double($0)!}
}

// 二進数に変換
func convertIntToRadix2(n: Int, radix: Int = 2) -> String {
    return String(n, radix: radix)
}

//配列を逆順にする reverced ソートする　sorted

let N = readInt()
let sticks = readSeparatedInts().sorted()

var result = 0

for i in 0..<N {
    for j in 1..<N {
        for k in 2..<N {
            if (i < j) && (j < k) {
                let a = sticks[i]
                let b = sticks[j]
                let c = sticks[k]
                
                if !((a == b) || (b == c) || (c == a)) {
                    if a + b > c {
                        result += 1
                    }
                }
            }
        }
    }
}
print(result)



Measured memory_bytes: 13644
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N; cin >> N;
	vector<ll> A(N);
	rep(i, N)cin >> A[i];
	sort(A.rbegin(), A.rend());
	vector<ll> num;
	for (ll i = 0; i < N; ++i) {
		if (i != N - 1) {
			if (A[i] == A[i + 1]) {
				if (N % 2 == 0) {
					num.push_back(A[i]);
					++i;
				}
			}
		}
	}
	if (num.size() < 2) cout << 0 << endl;
	else cout << num[0] * num[1] << endl;
	cin >> N;
}

Measured memory_bytes: 1660
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999

vector<int> in[10001], out[10001];

int main(){
	int i, j, k, t, N, M, r, q, n, m, s, ts, te, ans;
	while(1){
		cin >> N >> M;
		if(!N) break;
		for(i=1;i<=M;i++){
			in[i].clear();
			out[i].clear();
		}
		cin >> r;
		for(i=0;i<r;i++){
			cin >> t >> n >> m >> s;
			if(s) in[m].push_back(t);
			else out[m].push_back(t);
		}
		for(i=1;i<=M;i++){
			for(j=0;j<in[i].size();j++){
				for(k=j+1;k<in[i].size();k++){
					if(in[i][j] <= in[i][k] && out[i][k] <= out[i][j]){
						in[i][k] = 0;
						out[i][k] = 0;
					}
					else if(in[i][j] <= in[i][k] && in[i][k] <= out[i][j]){
						out[i][j] = out[i][k];
						in[i][k] = 0;
						out[i][k] = 0;
					}
					else if(in[i][j] <= out[i][k] && out[i][k] <= out[i][j]){
						in[i][k] = in[i][j];
						in[i][j] = 0;
						out[i][j] = 0;
					}
					else if(in[i][k] <= in[i][j] && out[i][j] <= out[i][k]){
						in[i][j] = 0;
						out[i][j] = 0;
					}
				}
			}
		}
		cin >> q;
		for(i=0;i<q;i++){
			ans = 0;
			cin >> ts >> te >> m;
			for(j=0;j<in[m].size();j++){
				if(in[m][j] <= ts && te <= out[m][j]){
					ans += te - ts;
				}
				else if(in[m][j] <= ts && ts <= out[m][j]){
					ans += out[m][j] - ts;
				}
				else if(in[m][j] <= te && te <= out[m][j]){
					ans += te - in[m][j];
				}
				else if(ts <= in[m][j] && out[m][j] <= te){
					ans += out[m][j] - in[m][j];
				}
			}
			//cout << "a:";
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,k;
  cin>>n>>k;
  set<int> st;
  for (int i = 1; i <= n; ++i)
  {
    st.insert(i);
  }
  for (int i = 0; i < k; ++i)
  {
    int d;
    cin>>d;
    for (int j = 0; j < d; ++j)
    {
      int a;
      cin>>a;
      if(st.find(a)!=st.end()) st.erase(a);
    }
  }
  cout<<st.size();
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  int a,b,c,d;
  a = N/1000;
  N -= a*1000;
  b = N/100;
  N -= b*100;
  c = N/10;
  N -= c*10;
  d = N;
  bool ans = 0;//0=GOOD 1= BAD
  if(a == b){
    ans = 1;
  }
  if(b == c){
    ans = 1;
  }
  if(c == d){
    ans = 1;
  }
  if(ans){
    cout <<"Bad"<<endl;
  }else{
    cout <<"Good"<<endl;
  }
}

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

int main()
{
	int n = 0, m = 0, l = 0;
	cin >> n >> m >> l;

	long long **vec_A = new long long*[n], **vec_B = new long long*[m], **vec_C = new long long*[n];

	for (int i = 0; i < n; i++) vec_A[i] = new long long[m], vec_C[i] = new long long[l];
	for (int j = 0; j < m; j++) vec_B[j] = new long long[l];

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> vec_A[i][j];
		}
	}

	for (int j = 0; j < m; j++){
		for (int k = 0; k < l; k++){
			cin >> vec_B[j][k];
		}
	}

	for (int i = 0; i < n; i++){
		for (int k = 0; k < l; k++){
			vec_C[i][k] = 0;
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			for (int k = 0; k < l; k++){
				vec_C[i][k] += vec_A[i][j] * vec_B[j][k];
			}
		}
	}

	for (int i = 0; i < n; i++){
		cout << vec_C[i][0];
		for (int k = 1; k < l; k++){
			cout << " " << vec_C[i][k];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1432
import itertools
n=int(input())
a= list(map(int, input().split()))

# aを偶数奇数の要素で振り分け
a1=[]
a2=[]

for i in range(n):
    if i%2==0:
        a1.append(a[i])
    else:
        a2.append(a[i])

# 累積和も作っておく
a3=list(itertools.accumulate(a1))
a4=list(itertools.accumulate(a2))


x1=sum(a1)
x2=sum(a2)


if n%2==0:
    ans=-float('inf')
    for i in range(n//2):
        ans=max(a3[i]+x2-a4[i],ans)
    print(max(ans,x1,x2))
else:
    # 奇数番目だけの要素を選んだ時の最大値
    ans1=sum(a1)-min(a1)
    # dp1[i]=奇数偶数奇数or偶数奇数と移動した時のi番目までのMAX
    dp1 = [-float('inf')] * (n // 2 + 1)
    dp1[0] = a1[0]
    # dp2[i]=奇数偶数or偶数のみと移動した時のi番目までのMAX
    dp2 = [-float('inf')] * (n // 2)
    dp2[0] = a2[0]
    for i in range(n // 2 - 1):
        dp2[i + 1] = max(a3[i] + a2[i + 1], dp2[i] + a2[i + 1])
        if i==0:
            dp1[i + 2] = dp2[i] + a1[i + 2]
        else:
            dp1[i + 2] = max(dp2[i] + a1[i + 2], dp1[i + 1] + a1[i + 2])
    print(max(dp1[-1], dp2[-1],ans1))

Measured memory_bytes: 107072
n, m = map(int, input().split())

List = [list(map(int, input().split())) for i in range(n)]
sum = 0

for i in range(1,m+1):
    cnt = 0
    for j in range(n):
        if i in List[j][1:]:
            cnt += 1
            if cnt == n:
                sum += 1

print(sum)

Measured memory_bytes: 3064