akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val a = Array.fill(scanner.nextInt)(parse(scanner.next))
    val b = bubbleSort(a)
    val s = SelectionSort(a)
    println(b.map(t => s"${t._1}${t._2}").mkString(" "))
    println(if(checkStable(b, a)) "Stable" else "Not stable")
    println(s.map(t => s"${t._1}${t._2}").mkString(" "))
    println(if(checkStable(s, a)) "Stable" else "Not stable")
  }

  def checkStable(target: Seq[(Char, Int)], original: Seq[(Char, Int)]): Boolean =
    (1 to 9).find(i => !target.filter(_._2 == i).equals(original.filter(_._2 == i))).isEmpty

  def parse(card: String): (Char, Int) =
    (card(0), card.substring(1).toInt)

  def bubbleSort(a: Seq[(Char, Int)]): Seq[(Char, Int)] = {
    val c = new Array[(Char, Int)](a.length)
    a.copyToArray(c)
    for(i <- 0 until c.length) {
      for(j <- c.length - 1 to i + 1 by -1) {
        if(c(j)._2 < c(j - 1)._2) {
          val t = c(j)
          c(j) = c(j - 1)
          c(j - 1) = t
        }
      }
    }
    c
  }

  def SelectionSort(a: Seq[(Char, Int)]): Seq[(Char, Int)] = {
    val c = new Array[(Char, Int)](a.length)
    a.copyToArray(c)
    var minj = 0
    for(i <- 0 until c.length) {
      minj = i
      for(j <- i until c.length) {
        if(c(j)._2 < c(minj)._2) {
          minj = j
        }
      }
      val t = c(i)
      c(i) = c(minj)
      c(minj) = t
    }
    c
  }
}



Measured memory_bytes: 45388
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string S, T; cin >> S >> T;
    int N = S.size(), M = T.size();

    vec s(N + 1), t(M + 1);
    s[0] = 0; t[0] = 0;
    REP(i, N){
        s[i + 1] = s[i];
        if(S[i] == 'A') s[i + 1]++;
    }
    REP(i, M){
        t[i + 1] = t[i];
        if(T[i] == 'A') t[i + 1]++;
    }

    int q; cin >> q;
    int a, b, c, d;
    REP(Q, q){
        cin >> a >> b >> c >> d;
        int SA = s[b] - s[a - 1], SB = b - a - SA;
        int TA = t[d] - t[c - 1], TB = d - c - TA;
        //cout << SA << " " << SB << " " << TA << " " << TB << endl;
        if((SA - SB - TA + TB) % 3 == 0){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }

    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 2432
import java.util.*;

public class Main{
	/*public static void main(String[] args) {
		Scanner input= new Scanner(System.in);
		int N = input.nextInt();
		int M = input.nextInt();
	    
		int a=(N*(N-1)/2);
		
		if(M < 2)
			System.out.println(a);
		else {
			System.out.println(a+M);
		}
	}*/
	 public static void main(String[] args) {
	        Scanner stdIn=new Scanner(System.in);
	 
	        int M=stdIn.nextInt();
	        int N=stdIn.nextInt();
	 
	        System.out.println(M*(M-1)/2+N*(N-1)/2);
	 }
}

Measured memory_bytes: 21844
N = int(input())
A = list(map(int, input().split()))
n = min(A) 
idx = A.index(n)
while True:
    tmpn = n
    tmpi = idx
    for i in range(N):
        if i == idx:
            continue
        if A[i] % n == 0:
            continue
        if (A[i] % n) < n:
            tmpn = A[i] % n
            tmpi = i
    if tmpn == n:
        break
    A[tmpi] = tmpn
    n = tmpn
    idx = tmpi
print(n)

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i = 0; i < m; i++) cin >> x[i];
    priority_queue<pair<int,int>> q;
    sort(x.begin(),x.end());
    for(int i = 0; i < m-1; i++){
        q.push({x[i+1]-x[i],i});
    }    
    vector<int> pin;
    pin.push_back(m-1);
    for(int i = 0; i < n-1; i++){
        if(q.empty()) break;
        pin.push_back(q.top().second);
        q.pop();
    }
    sort(pin.begin(),pin.end());
    int j = 0;
    int now = x[0];
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(i == pin[j]){
            ans += x[i]-now;
            if(i != m-1)now = x[i+1];
            j++;
        }
    }
    cout << ans << endl;
    return 0;

}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<ll>> dp(110, vector<ll>(4));
    // 0...a 1...g 2...c 3...t
    rp(i, 0, 4) dp.at(0).at(i) = 1ll;
    // a+gc, g+ac, a+cg, a+tgc, a+ggc, a+gtcは除く
    // a+cgを考えるときga+cgはg+acですでに除外されていることに注意
    rp(i, 1, n) {
        rp(j, 0, 4) {
            rp(k, 0, 4) {
                dp.at(i).at(j) += dp.at(i-1).at(k);
            }
            if(i > 1) {
                if(j == 1) {
                    dp.at(i).at(j) += mod;
                    dp.at(i).at(j) -= dp.at(i-2).at(0);
                    if(i > 2) dp.at(i).at(j) += dp.at(i-3).at(1);
                }
                if (j == 2) {
                    dp.at(i).at(j) += mod * 2;
                    dp.at(i).at(j) -= dp.at(i-2).at(0);
                    dp.at(i).at(j) -= dp.at(i-2).at(1);
                }
            }
            if(i > 2) {
                if (j == 2) {
                    dp.at(i).at(j) += mod * 3;
                    dp.at(i).at(j) -= dp.at(i-3).at(0)*3;
                }
            }
            dp.at(i).at(j) %= mod;
        }
    }
    ll res = 0;
    rp(i, 0, 4) {
        res += dp.at(n-1).at(i);
        res %= mod;
    }
    printf("%lld", res);
    return 0;

}

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

using namespace std;
using ll = long long;

int main() {
  ll A, B;
  cin >> A >> B;
  if (A < 6)
    cout << 0 << endl;
  else if(A < 13)
    cout << B/2 << endl;
  else
    cout << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define badi_val 1000000007
const long long mod=1e9+7;
int main(){
	ll s , c;
	cin >> s >> c;
	if(c == 2 * s){
		cout << s << endl; 
	}
	else if(c < 2 * s){
		cout << c / 2 << endl;
	}
	else{
		ll ans = 0;
		ans += s;
		ans += (c - 2 * s)/4;
		cout << ans << endl;
	}

 	return 0; 
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int ans = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int j = n - i;

                String si = "" + i;
                String sj = "" + j;
                while (si.length() < 6) {
                    si = "0" + si;
                }
                while (sj.length() < 6) {
                    sj = "0" + sj;
                }

                int sum = 0;
                for (int k = 0; k < 6; k++) {
                    sum += si.charAt(k) - '0' + sj.charAt(k) - '0';
                }
                ans = Math.min(ans, sum);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int main(){
  string S;
  cin>>S;

  int sum=0;
  int sum1=0;
  int C;

  if(S.at(0)=='A'){
    sum++;
  }
  
  for(int i=2;i<S.size()-1;i++){
    if(S.at(i)=='C'){
      sum1++;
      C=i;
    }
  }
  
  if(sum1==1){
    sum++;
  }
  
  int sum2=0;
  
  for(int i=0;i<S.size();i++){
    if(islower(S.at(i))&&i!=0&&i!=C){
      sum2++;
    }
  }
  
  if(sum2==S.size()-2){
    sum++;
  }
  
  if(sum==3){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}

        
      
  
     

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

#define ll long long

int main()
{
    ll n, d, ans = 0;
    cin >> n >> d;
    for (int in = 0; in < n; in++)
    {
        ll a, b;
        cin >> a >> b;
        if (a * a + b * b <= d * d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

// ツ閉カツ篠堋療アツづ個青板篠堋づ個堕ォツつオツ算ツづーツ行ツつ、
string add (string a, string b)
{
	reverse (a.begin(), a.end() );
	reverse (b.begin(), b.end() );

	while (a.length() != b.length()){
		if (a.length() > b.length()){
			b += '0';
		}else if (a.length() < b.length() ){
			a += '0';
		} // end if
	} // end while
	
	int i;
	string res = "";
	int carry = 0;
	
	for (i = 0; i < a.length(); ++i){
	
		int an = a[i] - '0';
		int bn = b[i] - '0';
		int sum = an + bn + carry;
	
		res += sum % 10 + '0';
		carry = sum/10;

	} // end for
	
	if (carry == 1){
		res += carry + '0';
	} // end if

	reverse (res.begin(), res.end() );
	
	return res;
}

int main()
{
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	for (i = 0; i < n; ++i){
		string a,b;
		string res = "";

		getline (cin, a);
		getline (cin, b);

		res = add (a, b);

		if (res.length() > 80){
			cout << "overflow" << endl;
		}else{
			cout << res << endl;
		} // end if		
	} // end for

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

#include<stdio.h>
 
struct Card{
  char suit[2];
  int value;
  int index;
};
struct Card A[100000];

void IsStable(struct Card C[], int lenght)
{
  int stable = 0;
  int i;
  for(i = 1; i < lenght; i++){
    if((C[i].value == C[i+1].value) && (C[i].index > C[i+1].index)){
      stable = 1;
      break;
    }
  }
  if(stable == 0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  return;
}

int Partition(struct Card A[], int p, int r)
{
  struct Card w;
  int x = A[r].value;
  int i = p-1, j, k;
  for(j = p; j < r; j++){
	  if(A[j].value <= x){
		i = i+1;
		w = A[i];
		A[i] = A[j];
		A[j] = w;
	}
  }
  w = A[i+1];
  A[i+1] = A[r];
  A[r] = w;
  return(i+1);
}

void Quicksort(struct Card A[], int p, int r)
{
  int q;
  if(p < r){
    q = Partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}

int main()
{
	int n, i;

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%1s %d", A[i].suit, &(A[i].value));
		A[i].index = i;
	}

	Quicksort(A, 0, n-1);
	IsStable(A, n);
	for(i = 0; i < n; i++){
		printf("%s %d\n", A[i].suit, A[i].value);
	}

	return(0);
}

Measured memory_bytes: 1780
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int n,dt=0,dx=0,dy=0,t,x,y;
	cin>>n;
	bool f=true;
	for(int i=1; i<=n; i++) {
		scanf("%d%d%d",&t,&x,&y);
		int dis=abs(x-dx)+abs(y-dy);
		if(dis>abs(t-dt)||(abs(t-dt)-dis)%2!=0) f=false;
		dx=x;
		dy=y;
		dt=t;
	}
	if(f)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
from itertools import product

def setq(ri,ci,krc):
    for ir in range(8):
        if ir!=ri:
            if krc[ir*8+ci]=="Q":
                return False,krc
            else:
                krc[ir*8+ci]="X"
    for ic in range(8):
        if ic!=ci:
            if krc[ri*8+ic]=="Q":
                return False,krc
            else:
                krc[ri*8+ic]="X"
    for ix in range(-7,7,1):
        ir=ri+ix
        ic=ci+ix
        if 0<=ir and ir<=7 and ir!=ri:
            if 0<=ic and ic<=7 and ic!=ci:
                if krc[ir*8+ic]=="Q":
                    return False,krc
                else:
                    krc[ir*8+ic]="X"
        ir=ri-ix
        ic=ci+ix
        if 0<=ir and ir<=7 and ir!=ri:
            if 0<=ic and ic<=7 and ic!=ci:
                if krc[ir*8+ic]=="Q":
                    return False,krc
                else:
                    krc[ir*8+ic]="X"
    return True,krc

def chki(i,krc):
    krc=[""]*64
    for j in range(8):
        krc[j*8+i[j]]="Q"
        bl,krc=setq(j,i[j],krc)
#        print(j,bl)
#        prk(krc)
        if not bl :
#            print(bl,i,"-------------------")
#            prk(krc)
            return False
#    print(bl,i,"-------------------")
#    prk(krc)
    return True

        
def prk(krc2):
    for i in range(8):
        print(krc2[i*8:(i+1)*8])        
    

icase=0
kr=[[] for i in range(8)]

if icase==0:
    k=int(input())
    krc=[""]*64
    for i in range(k):
        ri,ci=map(int,input().split())
        krc[ri*8+ci]="Q"
        setq(ri,ci,krc)
        kr[ri].append(ci)
elif icase==1:
    k=2
    krc=[""]*64
    ri,ci=2,2
    krc[ri*8+ci]="Q"
    setq(ri,ci,krc)
    kr[ri].append(ci)
    ri,ci=5,3
    krc[ri*8+ci]="Q"
    setq(ri,ci,krc)
    kr[ri].append(ci)
                
#prk(krc)

icnt=0

for ir in range(8):
    for ic in range(8):
        i=ir*8+ic
        if krc[i]=="":
            kr[ir].append(ic)
            
for i in product(kr[0],kr[1],kr[2],kr[3],kr[4],kr[5],kr[6],kr[7]):
    yn=""
    krc2=[""]*64
    if not chki(i,krc2):
        yn="no"
        continue
    else:
        break
if yn!="no":
    for ir in range(8):
        sti=["."]*8
        sti[i[ir]]="Q" 
        stii="".join(sti)
        print(stii)



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

int main(void)
{
	string input;
	while(cin >> input)
	{
		int cntJOI=0, cntIOI=0;
		for(int i=1; i<input.size()-1; i++)
		{
			if(input[i] == 'O' && input[i+1] == 'I')
			{
				     if(input[i-1]=='J')cntJOI++;
				else if(input[i-1]=='I')cntIOI++;
			}
		}
		cout << cntJOI << endl;
		cout << cntIOI << endl;
	}
	return 0;
}

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

#define mod 1000000007
#define all(x) (x).begin(), (x).end()

const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> ab(n+1);
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        ab[a].push_back(b);
    }
    for(ll i = 0; i < ab[1].size(); i++){
        ll toN = ab[1][i];
        for(ll j = 0; j < ab[toN].size(); j++){
            if(ab[toN][j] == n){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin>>n>>a>>b;
	cout<<min(a, b)<<' '<<max(a+b-n, 0)<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer;

import javax.lang.model.util.ElementScanner6; 

public class Main
{
    static class FastReader
    { 
        BufferedReader br; 
        StringTokenizer st; 

        public FastReader() 
        { 
            br = new BufferedReader(new
                    InputStreamReader(System.in)); 
        } 

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

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

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

        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 

        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    

    
    public static void main(String args[])
    {  
        FastReader in=new FastReader();
        int t=1;
        //t=in.nextInt();
        while(t-->0)
        {
           String S=in.nextLine();
           String T=in.nextLine();

           
           int min=10001;
           for(int i=0;i<=S.length()-T.length();i++)
           {
            int count=0;
            for(int j=0;j<T.length();j++)
            {
                if(S.charAt(i+j)!=T.charAt(j))
                    count++;
            }
            min=Math.min(count,min);
           }
           System.out.println(min);
           
        }
    }
}

Measured memory_bytes: 25832
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = sum(b) - sum(a)
ans = 0
for ai, bi in zip(a, b):
    ans += max(0, (bi - ai + 1) // 2)
print('Yes' if ans <= cnt else 'No')


Measured memory_bytes: 74008
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<string> getDiff1(string str)  {
    vector<string> diff1(0);
    int last = str[str.length()-1] - '0';
    if (last != 0) {
        diff1.push_back(to_string(last - 1));
    }
    diff1.push_back(to_string(last));
    if (last != 9) {
        diff1.push_back(to_string(last + 1));
    }
    return diff1;
}

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

    long long count = 0;
    int digit = 1;
    vector<vector<string> > lunlun(1, vector<string>(0));
    for (int i = 1; i <= 9; i++) {
        lunlun[0].push_back(to_string(i));
        count++;
        if (count == k) {
            cout << i << endl;
            return 0;
        }
    }

    while(1) {
        lunlun.push_back(vector<string>(0));
        for (int i = 0; i < lunlun[digit-1].size(); i++) {
            vector<string> diff1 = getDiff1(lunlun[digit-1][i]);
            for (string diff : diff1) {
                lunlun[digit].push_back(lunlun[digit-1][i] + diff);
                count++;
                if (count == k) {
                    int last_index = lunlun[digit].size() - 1;
                    long long ans = stoll(lunlun[digit][last_index]);
                    cout << ans << endl;
                    return 0;
                }
            }
        }
        digit++;
    }
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Student[] s = new Student[n];
		for(int i = 0; i < n; i++){
			int a = sc.nextInt();
			s[i] = new Student(a, i + 1);
		}
		sc.close();
		new Main().solve(n, s);
	}
	void solve(int n, Student[] s){
		Arrays.sort(s);
		for(Student student : s){
			System.out.print(student.B + " ");
		}
	}
}

class Student implements Comparable<Student>{
	public int A; //生徒のいた人数
	public int B; //生徒の出席番号
	public Student(int A, int B){
		this.A = A;
		this.B = B;
	}
	@Override
	public int compareTo(Student o) {
		//生徒の人数で並び替える
		return this.A - o.A;
	}	
}

Measured memory_bytes: 64408
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n = int(input())

print(int((n-2)*180))







Measured memory_bytes: 2940
n = gets.to_i
a = gets.chomp.split(' ')
b = []
if n.odd?
  a.each_with_index do |e, index|
    if index.odd?
	  b << e
    else
      b.unshift e
    end
  end
else
  a.each_with_index do |e, index|
    if index.odd?
	  b.unshift e
    else
      b << e
    end
  end
end  
puts b.join(' ')

Measured memory_bytes: 21988
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(abs(a-b)<=d&&abs(b-c)<=d)
        printf("Yes\n");
    else if(abs(a-c)<=d)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,ll> p1,pair<ll,ll> p2){
return p1.se>p2.se;
}
void solve(){
    ll s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<endl;
     else cout<<"safe"<<endl;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<ll> vvll;
#define sort(v) sort(v.begin(), v.end())
#define rev(r) reverse(r.begin(), r.end());
#define cout(cc) cout << cc << endl;
int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else if(a<3200) cout << "red" << endl;
}


Measured memory_bytes: 256
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
# from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(input()); alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	i = 0; s = 0
	while n >= s + 26**(i):
		s += 26**i
		i += 1
	# print(i, s)
	s = n-s

	ans = ["a"]*i
	while s > 0:
		ans[i-1] = chr(97+s%26)
		i -= 1
		s //= 26
	print(("").join(ans))
		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 9164
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.StreamTokenizer

class A

fun main( args: Array<String> ) {
    val st = StreamTokenizer( BufferedReader( InputStreamReader( System.`in` ) ) )
    val n = st.nextInt()
    val k = st.nextInt()
    if ( k == 0 ) {
        println( 0 )
        return
    }
    val x = IntArray( n, { st.nextInt() } )
    x.sort()
    var best = Int.MAX_VALUE
    for ( i in 0 .. n - k ) {
        val left = x[i]
        val right = x[i + k - 1]
        val dist = if ( ( left < 0 ) == ( right < 0 ) ) {
            Math.max( Math.abs( left ), Math.abs( right ) )
        } else {
            val min = Math.min( Math.abs( left ), Math.abs( right ) )
            min + Math.abs( left ) + Math.abs( right )
        }
        best = Math.min( best, dist )
    }
    println( best )
}

private fun StreamTokenizer.nextInt(): Int {
    nextToken()
    return nval.toInt()
}


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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool ng = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || ans > MX/a || ans*a > MX) {
      ng = true;
    }
    ans *= a;
  }
  if (ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	MOD = 10**9 + 7
	n = int(rl())
	G = [[] for _ in range(n)]
	for _ in range(n-1):
		u, v = rli()
		u -= 1
		v -= 1
		G[u].append(v)
		G[v].append(u)

	def dfs(node, prnt):
		w, b = 1, 1
		for nbhr in G[node]:
			if nbhr == prnt: continue
			nw, nb = dfs(nbhr, node)
			w *= (nw + nb)
			w %= MOD
			b *= nw 
			b %= MOD
		return w, b

	answ, ansb = dfs(0, -1)
	print((answ + ansb) % MOD)

	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 942488
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 40
#define w_MAX 10
#define INF 100000

int dp[N_MAX + 1][w_MAX * (N_MAX + 10) + 1][w_MAX * (N_MAX + 10) + 1];
int a[N_MAX], b[N_MAX], c[N_MAX];

void solve(int N){
  // 初期化
  for (int i = 0; i < N_MAX + 1; i++) {
    for (int j = 0; j < w_MAX * (N_MAX + 10) + 1; j++) {
      for (int k = 0; k < w_MAX * (N_MAX + 10) + 1; k++) {
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;
  
  for (int i = 0; i < N_MAX; i++) {
    for (int j = 0; j < w_MAX * N_MAX + 1; j++) {
      for (int k = 0; k < w_MAX * N_MAX + 1; k++) {
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
      }
    }
  }

}

int main(){
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  
  for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
  solve(N);
  int ans = INF;
  for (int i = 0; i < N_MAX; i++) {
    for (int j = 1; j < w_MAX * N_MAX + 1; j++) {
      for (int k = 1; k < w_MAX * N_MAX + 1; k++) {
        if(j * Mb == k * Ma) ans = min(ans, dp[i][j][k]);
      }
    }
  }
  
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 40448
#include<cmath>
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	string a,b,c,d;
	cin>>a>>b;
	c=a+b;d=b+a;
	int len=c.length(),sum1=0,sum2=0;
	for(int i=0;i<len;++i)
	{
		sum1=sum1*10+c[i]-'0';
		sum2=sum2*10+d[i]-'0';
	}
	int x=sqrt(sum1),y=sqrt(sum2);
	if(x*x==sum1||y*y==sum2) printf("Yes");
	else printf("No");
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(100010);
    for (int i = 0; i < M; i++) {
        scanf("%d", &a[i]);
    }
    long long dp[100010];
    for (int i = 0; i < 100010; i++) {
        dp[i] = 0;
    }
    dp[0] = 1;

    int j = 0;
    for (int i = 1; i <= N; i++) {
        if (i == a[j]) {
            j++;
            continue;
        }
        dp[i] += dp[i - 1];
        if (i > 1) {
            dp[i] += dp[i - 2];
        }
        dp[i] %= 1000000007;
    }

    long long ans = dp[N];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    int a,b,c,i,n=0;
while(1){
    //if(n>0)
    scanf("%d %d",&a,&b);
    if(a==0&&b==0)
        break;
    for(i=0;i<a;i++){
        for(c=0;c<b;c++){
            printf("#");
        }
        printf("\n");
}
printf("\n");
}
    return 0;
}



Measured memory_bytes: 2056
using System;

public class Hello{
    public static void Main(){
        // Your code here!
        
        
        
        string [] str=Console.ReadLine().Split(' ');
        int a=int.Parse(str[0]);
        int b=int.Parse(str[1]);
        
        int [,] ans=new int[a+1,b+1];
        
        string [] stop =new string [b];
        
        for(int i=0;i<a;i++)
        {
            stop=Console.ReadLine().Split(' ');
            for(int w=0;w<b;w++)
            {
                ans[i,w]=int.Parse(stop[w]);
                ans[i,b]+=int.Parse(stop[w]);
                ans[a,w]+=int.Parse(stop[w]);
                ans[a,b]+=int.Parse(stop[w]);
            }
        }
        
        for(int i=0;i<a+1;i++)
        {
            Console.Write(ans[i,0]);
            for(int w=1;w<b+1;w++)
            {
                Console.Write(" {0}",ans[i,w]);
            }
            Console.WriteLine();
        }
        
    }
}



Measured memory_bytes: 17908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int pos = 0;
    while(pos < n && s[pos] == 'T') pos++;
    int ans = pos;
    int snum = 0;
    while(pos < n)
    {
        if(pos < n && s[pos] == 'S')
        {
            pos++;
            snum++;
        }
        if(pos == n) break;
        int tnum = 0;
        while(pos < n && s[pos] == 'T')
        {
            pos++;
            tnum++;
        }
        if(tnum >= snum)
        {
            tnum -= snum;
            ans += tnum;
            snum = 0;
        }
        else
        {
            snum -= tnum;
        }
    }
    cout << ans + snum << endl;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll c[51][51];
void cal_c(ll N){
  for(int i=0;i<=N;++i){
    for(int j=0;j<=i;++j){
      if(j==0){ c[i][j] = 1;}
      else if(j==i){ c[i][j] = 1;}
      else{ c[i][j] = c[i-1][j-1]+c[i-1][j];  }
    }
  }
}
ll func(ll x,ll y){ return c[x][y];}

int main(){
  ll N,A,B; cin>>N>>A>>B;
  cal_c(N);
  ld v[N]; CINA(v,N);
  sort(v,v+N,greater<ll>());
  
  ld avr_max = 0; REP(i,A){ avr_max+=v[i];} avr_max /= A;
  
  ll a_count = 0,p_a=0;
  REP(i,N){
    if(v[i]==v[A-1]){
      ++a_count;
      if(i<A){ ++p_a;}
    }
  }
  ll p=0LL;
  if(p_a==A){
    for(p_a=A;p_a<=B;++p_a){
      p += c[a_count][p_a];
    }
  }else{
    p += c[a_count][p_a];
  }
  
  cout << fixed << setprecision(7) << avr_max <<"\n";
  cout << p << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll f,l,n,m,ok;
vector<ll> v;
int main(void){
    cin>>n>>m>>s;
    l=n;
    reverse(s.begin(),s.end());
    //cout<<s<<endl;
    while(f!=l){
        if(f+m>=l){
            v.push_back(l-f);
            f=l;
        }
        else{
            if(s[f+m]=='0'){
                v.push_back(m);
                f+=m;
            }
            else{
                ok=0;
                for(int i=m-1;i>0;i--){
                    if(s[f+i]=='0'){
                        v.push_back(i);
                        f+=i;
                        ok=1;
                        break;
                    }
                }
                if(ok==0){
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
    }
    reverse(v.begin(),v.end());
    for(auto x:v){
        cout<<x<<" ";
    }
    cout<<endl;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int na=0, nb=0;
  rep(i,b) na+=pow(10, i)*a;
  rep(i,a) nb+=pow(10, i)*b;
  string s = to_string(na);
  string g = to_string(nb);
  if(s<g)cout << s;
  else cout << g;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n;
    cin >> n;
    if (n % 1000 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - n % 1000 << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
a = input().rstrip().split(" ")
 
H = int(a[0])   #行
W = int(a[1])   #列
K = int(a[2])   #操作後に残る黒いマスの数
 
m = []
for i in range(H):
    n = list(input())
    m.append(n)
 
#print(m)
ans = 0
 
#2進数のyes/no(赤く塗るか否か)列を作る
for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskC >> j & 1) == 0 and m[i][j] == "#":
                    black += 1
    
        if black == K:
            ans += 1
 
print(ans)

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            int r;
            int D;
            int x;
            Multi(out r, out D, out x);
            for(int i = 0; i < 10; i++)
            {
                x = r * x - D;
                Console.WriteLine(x);
            }
            

            //Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

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

using namespace std;

using ll = long long;

int gcd(int x, int y) {
    return y ? gcd(y, x % y) : x;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int g = 0, mx = 0;
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        g = gcd(g, x);
        mx = max(mx, x);
    }
    if (k % g == 0 && k <= mx) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
    return 0;
}


Measured memory_bytes: 256
# Dynamic Programming - Matrix Chain Multiplication
INFTY = float('inf')
MAX = 200
size = int(input())
# 1???????????§??????
C = [[INFTY for _ in range(MAX+1)] for i in range(MAX+1)]
R = [0 for i in range(MAX+2)]
for i in range(size):
    a,b = map(int, input().split())
    if i == 0:
        R[1] = a
    R[i+2] = b

for i in range(1, size+1): C[i][i] = 0

for j in range(1,size):
    for i in range(1,size):
        for k in range(i+1,i+j+1):
            cost = C[i][k-1] + C[k][i+j] + R[i]*R[k]*R[i+j+1]
            if cost < C[i][i+j]:
                C[i][i+j] = cost
print(C[1][size])


Measured memory_bytes: 8020
#include <iostream>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;
const ll m = 1e9+7;
int gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}

int main() {
  int k; cin>>k;
  ll an=0;
  for(int i=1;i<=k;i++) {
    for(int j=1;j<=k;j++) {
      int g=gcd(i,j);
      for(int l=1;l<=k;l++) {
        an+=gcd(g,l);
      }
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	int x;
	string ans;
	cin >> x;
	if (x == 3||x== 5||x== 7) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc145/tasks/abc145_e
# E - All-you-can-eat
"""

"""


def good(i):
    tv = A[i] + M
    max_used = (i + 1 + (P - 1)) * M
    free = M * V - max_used

    for j in range(i + 1, N - P + 1):
        if A[j] > tv:
            return 0
        free -= tv - A[j]

    return free <= 0


N = gi()
M = gi()
V = gi()
P = gi()
A = [0] * N
for i in range(N):
    A[i] = gi()
A.sort()

#print(A)

l = 0
h = N - 1

while l < h:
    mid = (l + h) // 2
    if good(mid):
        h = mid
    else:
        l = mid + 1

print(N - l)


Measured memory_bytes: 24204
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');


            int row = int.Parse(Input[0]);
            int column = int.Parse(Input[1]);

            int[,] matrix = new int[row, column];
            int[] vector = new int[column];
            int result = 0;


            for (int i = 0; i < row; i++)
            {
                string[] calcNum = Console.ReadLine().Split(' ');

                for (int j = 0; j < column; j++)
                {
                    matrix[i, j] = int.Parse(calcNum[j]);
                }
            }


            for(int f = 0; f < column; f++)
            {
                int Data = int.Parse(Console.ReadLine());
                vector[f] = Data;
            }


            for (int a = 0; a < row; a++)
            {
                for (int b = 0; b < column; b++)
                {
                    if (matrix[a, b] == 0) continue;

                    result += matrix[a, b] * vector[b];
                }

                Console.WriteLine(result);
                result = 0;
            }

        

        }


    }

    }

Measured memory_bytes: 9356
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 3007;
int cost[maxn][maxn], dp[maxn][maxn][4];
signed main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= k; ++i) {
    int r, c, v;
    cin >> r >> c >> v;
    cost[r][c] = v;
  }
  dp[1][1][3] = 0;
  dp[1][1][2] = cost[1][1];
  dp[1][1][1] = dp[1][1][0] = -2e18;
  for (int row = 1; row <= n; ++row) {
    for (int col = 1; col <= m; ++col) {
      for (int canPick = 0; canPick <= 3; ++canPick) {
        dp[row][col + 1][canPick] = max(dp[row][col + 1][canPick], dp[row][col][canPick]);
        dp[row + 1][col][3] = max(dp[row + 1][col][3], dp[row][col][canPick]);
        dp[row + 1][col][2] = max(dp[row + 1][col][2], dp[row][col][canPick] + cost[row + 1][col]);
        if (canPick >= 1) {
          dp[row][col + 1][canPick - 1] = max(dp[row][col + 1][canPick - 1], dp[row][col][canPick] + cost[row][col + 1]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= 3; ++i)
    ans = max(ans, dp[n][m][i]);
  cout << ans;
}

Measured memory_bytes: 355972
#include <bits/stdc++.h>
using namespace std;
int arr[100100];
int main(int argc, char const *argv[])
{
	int n; cin>>n;
	for (int i = 0; i < n; ++i)
		cin>>arr[i];
	sort(arr, arr + n);
	map <int, bool > m;
	bool one = false;
	long long area = 1;
	for(int i = n - 1; i >= 0; i--){
		if(m.count(arr[i]) && m[arr[i]] == true){
			if(one){
				cout<<area*arr[i];
				return 0;
			}
			else{
				one = true;
				area = arr[i];
			}
		}
		if(m.count(arr[i]))
			m[arr[i]] = !m[arr[i]];
		else
			m[arr[i]] = true;

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

Measured memory_bytes: 4480
//bit 0:灰, 1:茶, 2:緑, 3:水, 4:青, 5:黄, 6:橙, 7:赤
#include <stdio.h>
int main(){
  int n,m,cnt=0,outside=0;
  char a=0;
  scanf("%d",&n);
  for(int i=0; i<n; i++){
    scanf("%d",&m);
    if( m >= 3200 ){ outside++; }
    else{ a |= (1<<(m/400)); }
  }
  for(int bit=0; bit<8; bit++){
    if( (a >> bit) & 1 ){ cnt++; }
  }
  //最小
  if( cnt==0 ){ printf("%d ",   1); }
  else	      { printf("%d ", cnt); }
  //最大
  printf("%d\n", cnt+outside);
  return 0;
}

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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> a(N+1);
        a[0]=0;
        int res=0;
        int now=0;
        for(int i=0;i<N;i++){
                cin>>a[i+1];
                res+=abs(a[i+1]-now);
                now=a[i+1];
        }
        res+=abs(now);
        a.push_back(0);
        for(int i=1;i<=N;i++){
                int vres=res;
                vres-=abs(a[i]-a[i-1]);
                vres-=abs(a[i+1]-a[i]);
                vres+=abs(a[i+1]-a[i-1]);
                cout<<vres<<endl;
        }
        return 0;
}


Measured memory_bytes: 1656
#include<iostream>
#include<cstring>
#include<ctype.h>
using namespace std;

int main(){
  string str,word;
  int x=0,l,i;

  cin >> word; //みつけたい文字の入力

  /*テキストの入力*/
  while( cin >> str){
    
    if( str == "END_OF_TEXT")break;//終了
    l = str.size();
    for(i = 0 ; i < l;i++){
    str[i] = tolower(str[i]);
    }
    if( str == word )x++;    
  }

  cout << x << endl;
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10005], b[10005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
    int h, w;
	char s[25][25];
int bfs(int sx, int sy) {
	int dist[25][25];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dist[i][j] = inf;
		}
	}
	queue<P>v;
	v.push(P{ sx,sy });
	dist[sx][sy] = 0;
	while (v.size()) {
		P now = v.front();
		v.pop();

		for (int i = 0; i < 4; i++) {
			int xnext = now.first + dy[i];
			int ynext = now.second + dx[i];
			if ((0 <= xnext && xnext < h) && (0 <= ynext && ynext < w)) {
				char a = s[xnext][ynext];
				if ((dist[xnext][ynext] == inf) && (s[xnext][ynext] != '#')) {
					dist[xnext][ynext] = dist[now.first][now.second] + 1;
					v.push(P{ xnext,ynext });
				}
			}
		}

	}
	int res = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (dist[i][j] != inf) {
				res = max(res, dist[i][j]);
			}
		}
	}
	return res;

}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				int res = bfs(i, j);
				if (res != inf) {
					ans = max(ans, res);
				}
			}
			
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256