akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<tuple>
#include<algorithm>
using namespace std;

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

    vector<string> S(N);
    vector<int> P(N);
    for (int i = 0; i < N; i++)
        cin >> S[i] >> P[i];

    vector<tuple<string, int, int>> v;
    for (int i = 0; i < N; i++)
        v.push_back(make_tuple(S[i], -P[i], i + 1));

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

    for (int i = 0; i < N; i++)
        cout << get<2>(v[i]) << endl;

    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n,m,a,b;
int ans[1010][1010];
void solve(){
	cin >> n >> m >> a >> b;
	
	int cnt[1010] = {};
	for(int i = 0; i < n; i++){
		int aa = a;
		bool ok = (cnt[0] < b);
		for(int j = 0; j < m; j++){
			if(aa && ok){
				ans[i][j] = 1;
				aa--;
				cnt[j]++;
			}
			else if(aa){
				ans[i][j] = 0;
				aa--;
			}
			else if(ok){
				ans[i][j] = 0;
				cnt[j]++;
			}
			else{
				ans[i][j] = 1;
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

// #include "debug.cpp"

int main(){
	int n, i, j;
	cin >> n;

	int arr[n] = {0};

	for(i=1; i<n; i++){
		for(j=i; j<n; j+=i){
			arr[j]++;
		}
	}

	// print(arr, n);

	int ans = 0;
	for(i=0; i<n; i++){
		ans += arr[i];
	}

	cout << ans << "\n";


}

Measured memory_bytes: 7456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	int x,a,b;

	cin >> x >> a >> b;

	if(abs(a-x)<abs(b-x)) cout << "A" << endl;
	else cout << "B" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        scanner.next(); // AtCoder 固定値なので変数受けしない
        String s = scanner.next();
        scanner.close();

        System.out.println(String.format("A%cC", s.charAt(0)));
    }
}


Measured memory_bytes: 23764
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]){
    val ab = readLine().split(" ").map(_.toInt)
    val (a,b) = (ab(0),ab(1))
    if (b%a == 0) {
      println(a+b)
    } else {
      println(b-a)
    }
  }
}

Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

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

    int cnt = 0;
    while(true) {
        if (cnt * 1000 >= N) {
            break;
        }
        cnt++;
    };
    cout << cnt * 1000 - N << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
int main(){

  int n,x;


  while(true){
    cin >> n>>x;
    if(n==0 && x == 0) break;

    int count=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        for(int k=j+1;k<n;k++){

          if((i+j+k+3) == x) count++;

        }
      }
    }
    cout << count <<endl;

  }
  
  
}




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

int main() { 
  string n;
  string s;
  cin >> n;
  int m = n.size();
  if(n[m-1] == '3'){
    s = "bon";
  }else if(n[m-1] == '0' || n[m-1] == '1' || n[m-1] == '6' || n[m-1] == '8' ){
    s = "pon";
  }else{
    s = "hon";
  }
  
  cout << s;
  
}

Measured memory_bytes: 3628
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

char s[5001];
set<string> se;
int n, k;

int main() {
	scanf("%s %d", s, &k);
	n = strlen(s);
	
	// 5000 짜리 보고. 음... 그냥 길이 5까지만 다 뽑고 정렬하고 지우자.
	for (int i = 0; i < n; i++) {
		string st;
		for (int j = 0; j < k; j++)
			if (i + j < n) {
				st.push_back(s[i + j]);
				se.insert(st);
			}
	}

	int cnt = 0;
	auto i = se.begin();
	for (i = se.begin(); cnt < k - 1; i++, cnt++);
	printf("%s", i->c_str());
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=505;
const int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int n;
int p[N*N];
pair<int,int> pos[N*N];
int dis[N][N];
bool vis[N][N];
void dfs(int x,int y)
{
	for(int i=0;i<4;i++)
	{
		int tx=x+dir[i][0],ty=y+dir[i][1];
		if(tx<0||tx>n||ty<0||ty>n) continue;
		int d=dis[x][y];
		if(!vis[tx][ty]) d++;
		if(dis[tx][ty]>d)
		{
			dis[tx][ty]=d;
			dfs(tx,ty);
		}
	}
	return;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*n;i++)
	{
		scanf("%d",&p[i]);
		pos[i]=make_pair((p[i]-1)/n+1,p[i]%n==0?n:p[i]%n);
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dis[i][j]=min({j-1,n-j,i-1,n-i});
	long long ans=0;
	for(int i=1;i<=n*n;i++)
	{
		int x=pos[i].first,y=pos[i].second;
		vis[x][y]=true;
		ans+=dis[x][y];
		dis[x][y]--;
		for(int i=0;i<4;i++)
		{
			int tx=x+dir[i][0],ty=y+dir[i][1];
			dis[x][y]=min(dis[x][y],dis[tx][ty]);
		}
		dfs(x,y);
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    
    if (S=="Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (S=="Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std ;

int main(void){
	int a, b ;
	scanf("%d %d",&a,&b) ;
	if(a<b) {
		if(a==1) printf("Alice\n") ;
		else printf("Bob\n") ;
	} else if(a>b) {
		if(b==1) printf("Bob\n") ;
		else printf("Alice\n") ;
	} else if(a==b) printf("Draw\n") ;

	return 0 ;
}

Measured memory_bytes: 128
n,m,x = map(int,input().split())
c = [[int(i) for i in input().split()] for _ in range(n)]
import itertools
max_=-1
for i in range(n):
    c_list = list(itertools.combinations(c, i+1))
    for j in c_list:
        d=[0]*(m+1)
        for k in j:
            d = [x+y for (x,y) in zip(d,k)]
        f=1

        for l in range(1,m+1):

            if d[l] < x:
                f=0
                break

        if f==1:
            if max_ ==-1:
                max_ = d[0]
            elif d[0] < max_:
                max_ = d[0]

print(max_)

Measured memory_bytes: 74676
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    // all zero
    bool allzero = true;
    rep(i, n) {
        if (a[i] != 0) allzero = false;
    }
    if (allzero) {
        cout << "Yes\n";
        return 0;
    }

    if (n % 3 != 0) {
        cout << "No\n";
        return 0;
    }

    sort(a.begin(), a.end(), greater<ll>());

    bool allsame = true, allzero2 = true;

    rep(i, 2 * n / 3 - 1) {
        if (a[i] != a[i + 1]) allsame = false;
    }
    for (ll i = 2 * n / 3; i < n; i++) {
        if (a[i] != 0) allzero2 = false;
    }

    if (allsame && allzero2) {
        cout << "Yes\n";
        return 0;
    }

    vector<ll> num, ins_cnt;
    a.push_back(-1ll);
    ll cnt = 1;

    rep(i, a.size() - 1) {
        if (a[i] == a[i + 1]) {
            cnt++;
        } else {
            ins_cnt.push_back(cnt);
            num.push_back(a[i]);
            cnt = 1;
        }
    }

    // rep(i, num.size()) { cout << num[i] << "\n"; }

    if (num.size() != 3) {
        cout << "No\n";
        return 0;
    }

    if (!(ins_cnt[0] == ins_cnt[1] && ins_cnt[1] == ins_cnt[2])) {
        cout << "No\n";
        return 0;
    }

    if (!(num[0] == (num[1] ^ num[2]) && num[1] == (num[0] ^ num[2]) &&
          num[2] == (num[0] ^ num[1]))) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 6268
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        char[] S = scanner.next().toCharArray();
        scanner.close();

        int x = 0;
        int max = 0;

        for (char c : S) {
            if (c == 'I') x++;
            if (c == 'D') x--;

            if (x > max) max = x;
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 21588
n = int(input())

def make_divisors(n): #約数を列挙する関数
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    divisors.remove(1)
    return divisors

ans = make_divisors(n-1) #n-1の約数(1以外)を列挙し、それらは対象になる
y = make_divisors(n) #nの約数を列挙

for i in y:
    z = n
    while z >= i and z%i == 0: #割り切れるところまで割る(nがi以上のとき)
        z = int(z / i)
        if z % i == 1: #z(=余り)が1だったら
            ans.append(i)
            break

set(ans)
#print(ans)
print(len(ans))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 300

int main(void)
{
  int H,W;
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0) break;
  
    for(int i = 0;i < H;i++){
      for(int j = 0;j < W;j++){
        printf("#");
      }
    printf("\n");
    }
  printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1112
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}XY;

XY kock(int,XY,XY);

int main(){
  int len;
  XY p1={0.0,0.0},p2={100.0,0.0};
  
  
  scanf("%d",&len);
  printf("%f %f\n",p1.x,p1.y);
  p2=kock(len,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
  
  return 0;
}

XY kock(int n,XY p1,XY p2){
  XY s,t,u;
  
  if(n == 0) return p2;
  
  // p1, p2 から s, t, u を計算
  s.x=(2.0*p1.x+1.0*p2.x)/3;
  s.y=(2.0*p1.y+1.0*p2.y)/3;
  t.x=(1.0*p1.x+2.0*p2.x)/3;
  t.y=(1.0*p1.y+2.0*p2.y)/3;
  u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;
  
  kock(n-1, p1, s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1, s, u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1, u, t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1, t, p2);
  return p2;
}



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

using namespace std;

const int MOD = 998244353;

int main(){
    const int maxSize = 1000001;
	vector<long long> inv(maxSize);
	for(int i=0;i<2;i++) inv[i] = 1;
	for(int i=2;i<maxSize;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	}
    vector<int> primes; primes.push_back(2);
    for(int i=3;i<1000;i+=2){
        bool ok = true;
        for(auto& p : primes) if(i%p == 0) ok = false;
        if(ok) primes.push_back(i);
    }
    int N;
    while(cin >> N){
        vector<long long> sum(1000001, 0), sqsum(1000001, 0);
        for(int i=0;i<N;i++){
            long long A; cin >> A;
            vector<vector<int>> divs;
            int a = (int)A;
            for(int j=0;j<primes.size() && primes[j]*primes[j]<=a;j++){
                if(a%primes[j]) continue;
                divs.emplace_back(vector<int>(1, 1));
                while(a%primes[j] == 0){
                    divs.back().push_back(divs.back().back() * primes[j]);
                    a /= primes[j];
                }
            }
            if(a > 1){ divs.push_back(vector<int>({1, a})); }
            if(A == 1) divs.push_back(vector<int>(1, 1));
            int m = 1;
            for(auto& v : divs) m *= v.size();
            for(int j=0;j<m;j++){
                int idx = j;
                int val = 1;
                for(auto& v : divs){
                    val *= v[idx%v.size()];
                    idx /= v.size();
                }
                sum[val] = (sum[val] + A) % MOD;
                sqsum[val] = (sqsum[val] + A * A) % MOD;
            }
        }
        long long res = 0;
        vector<long long> val(1000001, 0);
        for(int i=1000000;i>=1;i--){
            val[i] = (sum[i] * sum[i] - sqsum[i]) % MOD * inv[2] % MOD;
            for(int j=2*i;j<=1000000;j+=i) val[i] = (val[i] + MOD - val[j]) % MOD;
            res = (res + val[i] * inv[i]) % MOD;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 31488
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int deck[4][14];

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

	map<int, char> m;

	m[0] = 'S';
	m[1] = 'H';
	m[2] = 'C';
	m[3] = 'D';

	for (int i = 0; i < 4; i++) {
		for (int j = 1; j < 14; j++) {
			deck[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		char c; int x; cin >> c >> x;

		if (c == 'S') {
			deck[0][x]++;
		}
		else if (c == 'H') {
			deck[1][x]++;
		}
		else if (c == 'C') {
			deck[2][x]++;
		}
		else {
			deck[3][x]++;
		}
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 1; j < 14; j++) {
			if (deck[i][j] == 0) {
				cout << m[i] << " " << j << endl;
			}
		}
	}


}


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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        char[] code = scanner.next().toCharArray();
        int ans = 0;
        for(int i = 1; i < 4; i++) {
            if (code[i-1] == code[i]) ans++;
        }
        if (ans > 0) out.println("Bad");
        else out.println("Good");
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


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

void print(vector<int> vec)
{
	for (unsigned int i = 0; i < vec.size(); i++)
	{
		cout << vec[i];
		if (i != vec.size() - 1){
			cout << " ";
		}
	}
	cout << endl;
}

int main()
{
	int n, m;
	int a;
	int i, j;
	vector<int> vec;

	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> m;
		vec.push_back(m);
	}
	print(vec);

	for (i = 1; i < n; i++)
	{
		a = vec[i];
		for (j = i - 1; j >= 0 && vec[j] > a; j--)
		{
			vec[j + 1] = vec[j];
		}
		vec[j + 1] = a;
		print(vec);
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("substrcmp.in", "r", stdin);
       // freopen("substrcmp.out", "w", stdout);
#endif
}

void solve(){
    int n, r;
    cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    } else{
        cout << r+100*(10-n) << endl;
    } 
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  while(true){
    string s; cin >> s;
    if(s=="-")break;
    int n;cin>>n;
    for(int i = 0; n > i; i++){
      int k;cin>>k;
      string tmp;
      for(int j = 0; s.size() > j; j++){
        tmp.push_back(s[(j+k)%s.size()]);
      }
      s = tmp;
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3228
#include<iostream>

using namespace std;

int n, m, C1[100], C2[100], sum1, sum2, d1, d2, c1, c2;

int main(){
    while(cin >> n >> m && n*m!=0){
        sum1 = 0;
        sum2 = 0;
        for (int i = 0; i < n; i++) {
            cin >> C1[i];
            sum1 += C1[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> C2[i];
            sum2 += C2[i];
        }
        c1 = 101;
        c2 = 101;
        if((sum1 + sum2) % 2 == 1){
            cout << -1 << endl;
        } else {
            for (int i = 0; i < n; i++){
                
                for (int j = 0; j < m; j++){
                    d1 = C2[j]-C1[i];
                    d2 = C1[i]-C2[j];
                    if((sum1+d1) == (sum2+d2)){
                        if((C1[i] + C2[j]) < (c1 + c2)){
                            c1 = C1[i];
                            c2 = C2[j];
                        }
                    }
                }
            }
            if (c1 * c2 <= 10000){
                cout << c1 << " " << c2 << endl;
            } else {
                cout << -1 << endl;
            }
        }
    }
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 12:27:12 2020

@author: liang
"""

N = int(input())
W = list()
for i in range(N):
    a, b = map(int, input().split())
    W.append((a,b))

W.sort(key= lambda x:x[1])

res = 0
for i in range(N):
    res += W[i][0]
    if res > W[i][1]:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 37352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner twonum = new Scanner(System.in);
		int n = twonum.nextInt();
		int m = twonum.nextInt();
		if (m == n) {
			if (n >= 1 && n <=100) {
				if (m >=0 && m <= n) System.out.println("Yes");
				else System.out.println("No");
			}
			else System.out.print("No");
		}
		else{
			System.out.println("No");
			}
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define REP(i,n) for(int i=0;i<n;i++)
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

int N;

int main()
{
	cin >> N;

	cout << (N - 2) * 180 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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; }

struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

ll dp[100010][2];

int main(){
	string l;
	cin >> l;
	dp[0][0] = 1;
	for(int i = 1; i <= l.size(); i++){
		if(l[i-1] == '1'){
			dp[i][0] = (dp[i-1][0]*2)%MOD;
			dp[i][1] = (dp[i-1][0]+dp[i-1][1]*3)%MOD;
		}else{
			dp[i][0] = (dp[i-1][0])%MOD;
			dp[i][1] = (dp[i-1][1]*3)%MOD;
		}
	}
	cout << (dp[l.size()][0]+dp[l.size()][1])%MOD << endl;
	return 0;
}

Measured memory_bytes: 2048
N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))
F = sorted(list(map(int,input().split())),reverse=True)
if K>=sum(A):
    ans = 0
else:
    low = 0
    high = 10**12
    while high-low>1:
        mid = (high+low)//2
        B = A[:]
        cnt = 0
        for i in range(N):
            if B[i]*F[i]>mid:
                cnt += (B[i]-mid//F[i])
        if cnt<=K:
            high = mid
        else:
            low = mid
    ans = high
print(ans)

Measured memory_bytes: 122572
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

Graph G(2010);

ll table[2010][2010];
ll d[2010];
queue<ll> Q;

void BFS(ll s){
    fill(d,d+2010,INF);
    while(Q.size()) Q.pop();
    Q.push(s);
    d[s] = 0;
    while(Q.size()){
        ll x = Q.front();
        ll n = G[x].size();
        Q.pop();
        rep(i,n){
            ll y = G[x][i];
            if(d[y] > d[x] + 1){
                d[y] = d[x] + 1;
                Q.push(y);
            }
        }
    }
}

int main(){
    ll N,X,Y;
    cin >> N >> X >> Y;
    X--;Y--;
    rep(i,N-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);
    rep(i,N){
        BFS(i);
        rep(j,N){
            table[i][j] = d[j];
        }
    }
    map<ll,ll> mp;
    rep(i,N){
        rep(j,N) mp[table[i][j]]++;
    }
    rep(i,N-1){
        cout << mp[i+1] / 2 << endl;
    }
}


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

int main(){
	long long int  x,a,b;
	cin>>x;
	for(long long i=-1000;i<1000;i++){
		for(long long j=-1000;j<1000;j++){
			long long int a=pow(i,5);
			long long int b=pow(j,5);
			if(b-a==x){
				cout<<-1*i<<" "<<-1*j<<endl;
				return 0;
			}

		}
	}
	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 300;
constexpr ll I_MAX = 1000000000;

ll N;
ll A[N_MAX][N_MAX];
void warshall_floyd(vector<vector<ll>> &d) {
	ll N=d.size();
	for (ll k=0; k<N; k++) {
		for (ll i=0; i<N; i++) {
			for (ll j=0; j<N; j++){
				if(d[i][k] != INF && d[k][j] != INF && d[i][k] + d[k][j] < d[i][j]){
					d[i][j] = d[i][k] + d[k][j];
				}
			}
		}
	}
}

void input() {
	scanf("%lld", &N);
	rep(i, N) rep(j, N) scanf("%lld", &A[i][j]);
}

void solve() {
	ll sum=0;
	vector<vector<ll>> d(N, vector<ll>(N, 0));
	for(ll i=0; i<N; i++) {
		for(ll j=0; j<N; j++) {
			d[i][j] = A[i][j];
		}
	}

	warshall_floyd(d);
	rep(i,N) for(ll j=i+1;j<N;j++){
		if(A[i][j]!=d[i][j]){p(-1);return;}
		sum+=d[i][j];
	}

	rep(i,N) for(ll j=i+1;j<N;j++){
		if([&]{
			rep(k,N){
				if(k==i||k==j)continue;
				if(d[i][j]==d[i][k]+d[k][j]){
					return true;
				}
			}
			return false;
		}()){sum-=d[i][j];}
	}

	p(sum);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h> 
#include <set>
using namespace std;

int main(){
	int x, y, i, aux, cont;
	cin >> x >> y;
	set<int> s;
	
	if(y == 0){
		cout << x << endl;
		return 0;
	}
	
	for(i = 0; i < y; i++){
		cin >> aux;
		s.insert(aux);
	}
	
	for(i = 0;; i++){
		
		if(!s.count(x-i)){
			cont = -i;
			break;
		}
		else if(!s.count(x+i)){
			cont = +i;
			break;
		}
		
	}
	
	
	cout << x + cont << endl;
		
	
	return 0;
}


Measured memory_bytes: 3640
import sys
import numpy as np
from bisect import bisect_left

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, H = map(int, input().split())
    A = []
    B = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    A.sort()
    B.sort(reverse=True)

    throw = []
    for i in range(N):
        if B[i] > A[-1]:
            throw.append(B[i])
    # print(throw)
    throw = throw[::-1]

    ans = 0

    while H > 0:
        if throw:
            H -= throw.pop()
            ans += 1
        else:
            need_try = (H + A[-1] - 1) // A[-1]
            ans += need_try
            break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21904
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 200000;
const int M = 1000000007;

int n;
int pre[MaxN + 1], suf[MaxN + 1];

int f[MaxN + 1];

struct object
{
	int x, v;
	object() {}
	object(const int &_x, const int &_v)
		: x(_x), v(_v) {}
};
object a[MaxN + 1];

inline bool comparator_x(const object &lhs, const object &rhs)
{
	return lhs.x < rhs.x;
}
inline bool comparator_v(const object &lhs, const object &rhs)
{
	return lhs.v < rhs.v;
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
		a[i].x = getint(), a[i].v = getint();

	sort(a + 1, a + n + 1, comparator_v);
	for (int i = 1; i <= n; ++i)
		a[i].v = i;
	sort(a + 1, a + n + 1, comparator_x);

	int cur = n;
	for (int i = n; i; --i)
		pre[i] = cur = min(cur, a[i].v);

	cur = 1;
	for (int i = 1; i <= n; ++i)
		suf[i] = cur = max(cur, a[i].v);

	int sum = f[0] = 1, p = 0;
	int res = 0;
	for (int i = 1; i <= n; ++i)
	{
		while (suf[p] < pre[i] - 1)
			sum = (sum + M - f[p++]) % M;

		f[i] = sum;
		if (suf[i] == n)
			res = (res + f[i]) % M;

		sum = sum * 2 % M;
	}

	cout << res << endl;

	return 0;
}

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

void selectionSort(int A[], int N){
  int i, minj, j, t, c = 0;
  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(A[j] < A[minj]){
    minj = j;
      }
    }
    if(i != minj){
      t = A[i];
      A[i] = A[minj];
      A[minj] = t;
      c++;
    }
  }
  for(i = 0; i < N; i++){
    printf("%d",A[i]);
    if(i <= N-2) printf(" ");
  }
  printf("\n%d\n", c);
}


int main(void){
  int i, n;
  scanf("%d", &n);
  int *a;
  a = malloc(n * sizeof(int));
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  selectionSort(a, n);
  return 0;
}

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

//29
typedef long long ll;

ll power(ll a , ll b) {
    ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans  * a;
		}
		a = a * a;
		b  /= 2;
	}
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<ll>> v(n,vector<ll> (2));
	for (int i = 0; i < n; ++i) {
		cin >> v[i][0] >> v[i][1];
	}
	sort(v.begin(),v.end());
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		if (k - v[i][1] > 0) {
			k -= v[i][1];
			sum += v[i][0] * v[i][1];
		}else {
			sum += v[i][0] * k;
			break;
		}
	}
	cout << sum;
} 	



Measured memory_bytes: 8804
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_tuple();
    if a * b % 2 == 0 {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

int a, b, c, d;

void solve() {
    int atk1, atk2 = 0;
    if (a % d == 0) {
        atk1 = a / d;
    } else {
        atk1 = a / d + 1;
    }
    if (c % b == 0) {
        atk2 = c / b;
    } else {
        atk2 = c / b + 1;
    }
    if (atk1 >= atk2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    cin >> a >> b >> c >> d;
    solve();
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n, m, x;
  cin >> n >> m >> x;
  
  vector<ll> a(m);
  ll t = 0;
  for (int i = 0; i < m; i++){
    cin >> a[i];
    if (a[i] < x)
      t++;
  }

  cout << min(t, m - t) << endl;
  

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    bool flag=true;
    H[0]--;
    for(int i=1; i<N; i++){
        if(H[i-1]<H[i]){
            H[i]--;
        }else if(H[i-1]>H[i]){
            flag=false;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1int;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  ll n;
  cin>>n;
  if(n%2==0){
    ll ans = min(n*4*q,min(n*2*h,min(n*s,n/2*d)));
    printf("%lld\n", ans);
    return 0;
  }
  ll ans1 = min((n/2*d)+4*q,min((n/2*d)+2*h,(n/2*d)+s));
  ll ans2 = min(n*4*q,min(n*2*h,n*s));
  printf("%lld\n", min(ans1,ans2));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

struct Node {
    int key;
    Node *parent = nullptr;
    Node *left = nullptr, *right = nullptr;

    Node(int _key) {
        key = _key;
    }
};

Node *root = nullptr;

void Insert(int key) {
    Node *node = new Node(key);

    Node *y = nullptr;
    Node *x = root;

    while (x != nullptr) {
        y = x;
        if (key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    node->parent = y;
    if (y == nullptr) {
        root = node;
    } else if (key < y->key) {
        y->left = node;
    } else {
        y->right = node;
    }
}

void InOrder(Node *node) {
    if (node == nullptr) {
        return;
    }

    InOrder(node->left);
    cout << " " << node->key;
    InOrder(node->right);
}

void PreOrder(Node *node) {
    if (node == nullptr) {
        return;
    }

    cout << " " << node->key;
    PreOrder(node->left);
    PreOrder(node->right);
}

Node *Find(Node *node, int key) {
    while (node != nullptr && node->key != key) {
        if (key < node->key) {
            node = node->left;
        } else {
            node = node->right;
        }
    }

    return node;
}

Node *GetMin(Node *x) {
    while (x->left != nullptr) {
        x = x->left;
    }

    return x;
}

Node *GetSuccessor(Node *x) {
    if (x->right != nullptr) {
        return GetMin(x->right);
    }

    Node *y = x->parent;
    while (y != nullptr && y->right != x) {
        x = y;
        y = y->right;
    }

    return y;
}

void DeleteNode(Node *z) {
    Node *y;
    Node *x;

    if (z->left == nullptr || z->right == nullptr) {
        y = z;
    } else {
        y = GetSuccessor(z);
    }

    if (y->left != nullptr) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != nullptr) {
        x->parent = y->parent;
    }

    if (y->parent == nullptr) {
        root = x;
    } else {
        if (y == y->parent->left) {
            y->parent->left = x;
        } else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }
}

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

    for (int i = 0; i < n; ++i) {
        string ops;
        int key;
        cin >> ops;

        if (ops == "insert") {
            cin >> key;
            Insert(key);
        } else if (ops == "find") {
            cin >> key;
            if (Find(root, key) != nullptr) {
                cout << "yes";
            } else {
                cout << "no";
            }
            cout << endl;
        } else if (ops == "delete") {
            cin >> key;
            DeleteNode(Find(root, key));
        } else {
            InOrder(root);
            cout << endl;
            PreOrder(root);
            cout << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 21820
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    string S,S1,S2;
    cin>>S;

    
    if(N%2!=0){
        cout<<"No"<<endl;
    }
    else {
        S1=S.substr(0,N/2);
        S2=S.substr(N/2);
        if(S1==S2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int S=0;
    scanf("%d",&S);
    int h=0,m=0,s=0;
    h = S/3600;
    m = S/60 -h*60;
    s = S%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 1024
import sys,math
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]
b = set(a)
dp = [0] * (N+1)
mod = 10**9+7
for i in range(N,-1,-1):
    if i in b:
        continue
    elif i == N or i == N-1:
        dp[i] = 1
    else:
        dp[i] = (dp[i+1] + dp[i+2])%mod
print(dp[0])


Measured memory_bytes: 13216
def gcd(x, y):
    if x == 0: return y
    return gcd(y%x, x)
lcm = lambda x, y: x*y//gcd(x, y)

n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e//2 for e in arr]

cm = arr[0]
for e in arr[1:]:
    cm = lcm(cm, e)

if any([cm//e % 2 == 0 for e in arr]):
    print(0)
    exit()
print((m//cm+1)//2)


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

namespace contest_Csharp
{
    class Program
    {
        

        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            var vals = Console.ReadLine().Split(' ').
                Select(x => int.Parse(x)).ToList();
            var H = vals[0];
            var W = vals[1];
            var K = vals[2];

            var s = new List<string>();
            for (int i = 0; i < H; i++)
            {
                s.Add(Console.ReadLine());
            }

            var ans = 0;
            //bit全探索
            for (int i = 0; i < 2<<(H+W-1); i++)
            {
                int blackcount = 0;
                //さらに盤面全探索
                for (int v = 0; v < H; v++)
                {
                    for (int h = 0; h < W; h++)
                    {
                        if (s[v][h]=='#' && (i>>v)%2==0 && (i >> (h+H)) % 2 == 0)
                        {
                            blackcount++;
                        }
                    }
                }
                ans += (blackcount == K) ? 1 : 0;
                if (blackcount == K)
                {

                }

            }

            

            Console.WriteLine(ans);
            Console.Out.Flush();
        }
        




    }
}




Measured memory_bytes: 28264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define PI 3.14159265358979323846264338327950L


int main(void) {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}

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

int main(){
    int N;
    string S[50];
    int T[50];
    cin >> N;
    for(int i=0; i<N; i++) cin >> S[i] >> T[i];
    string X;
    cin >> X;
    for(int i=0; i<N; i++) if(S[i] == X){
        int ans = 0;
        for(int j=i+1; j<N; j++) ans += T[j];
        cout << ans << endl;
        return 0;
    }
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e3 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

const ll MAXW = (ll) 2e4 + 10;

struct block {
	ll w;
	ll s;
	ll v;
} a[MAXN];

ll dp[MAXN][20 * MAXN];

bool CMP(block a, block b){
	return a.w + a.s < b.w + b.s;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	for(int i = 0; i < MAXN; i++) fill(dp[i], dp[i] + (20 * MAXN), -INF);
	
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i].w >> a[i].s >> a[i].v;
	
	sort(a + 1, a + n + 1, CMP);
	
	dp[0][0] = 0;
	
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < MAXW; j++){
			dp[i][j] = dp[i - 1][j];
			if(j >= a[i].w){
				if(j - a[i].w <= a[i].s) dp[i][j] = max(dp[i - 1][j - a[i].w] + a[i].v, dp[i][j]);
			}
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans;
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 159616
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
#define PP std::pair<LL,LL>
std::vector<PP> P;
LL ans;
int main() {
	int N;
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		LL A, B;
		std::cin >> A >> B;
		P.push_back({ A,B });
	}
	std::sort(P.rbegin(), P.rend());
	ans += P[0].second + 1;
	for (int i = 1; i < N; i++) {
		ans += std::min(P[i - 1].first - P[i].first, P[i].second - P[i - 1].second);
	}
	ans += P[N - 1].first - 1;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 2420
from collections import Counter
N = int(input())
work = [input() for _ in range(N)]
work = Counter(work)
i = -1
result = []
for key, value in work.most_common():
    if i == -1 or i == value:
        i = value
        result.append(key)
for r in sorted(result):
    print(r)

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

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0] + a[1] << endl;
}

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

int main(void){
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int sum{0};
    for(int Ai{0}; Ai<=A; ++Ai){
        if(500*Ai>X)
            break;
        for(int Bi{0}; Bi<=B; ++Bi){
            if(500*Ai+100*Bi>X)
                break;
            for(int Ci{0}; Ci<=C; ++Ci){

                if(500*Ai+100*Bi+50*Ci==X)
                    ++sum;
                if(500*Ai+100*Bi+50*Ci>X)
                    break;
            }
        }
    }

    cout << sum << endl;


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
long long slov[26], sol;
string s;
 
int main(){
	
  cin >> s;
 
  long long x = s.length();
  
  for (long long i = 0; i < x; i++)
    slov[s[i]-'a']++;
    
  sol = ((long long)x*(long long)(x+1))/2;
 
  for (int i = 0; i < 26; i++)
  	if(slov[i]>0)
    	sol -= ((long long)slov[i]*(long long)(slov[i]+1)) / 2;
  
 
  cout << sol+1;
  
  return 0;
  
  
}

Measured memory_bytes: 640