akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll mod;
ll dp[6010][2010];

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

	ll n;
	cin >> n >> mod;
	dp[0][0] = 1;
	rep(i, 3 * n) {
		rep(j, n + 1) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
			if (i + 2 <= 3 * n) {
				dp[i + 2][j + 1] += dp[i][j] * (3 * n - i - 1) % mod;
				dp[i + 2][j + 1] %= mod;
			}
			if (i + 3 <= 3 * n) {
				dp[i + 3][j + 1] += dp[i][j] * (3 * n - i - 1)*(3 * n - i - 2) % mod;
				dp[i + 3][j + 1] %= mod;
			}
		}
	}
	ll ans = 0;
	for (int j = 0; j <= n; j++) {
		ans += dp[3 * n][j];
		ans %= mod;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 97772
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    bool find(int x,int y){
        int rx = x;
        if(x==y)return true;
        while(par[y]!=y){
            if(x==par[y]) return true;
            else y = par[y];
        }
        return false;
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = x; //xの根をrx
        int ry = y; //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){

    int i,n,q;
    cin >> n >> q;
    int a[n-1],b[n-1],p[q],x[q],c[n];
    UnionFind tree(n);
    for(i=0;i<n-1;i++){
        cin >> a[i] >> b[i];
        tree.unite(b[i]-1,a[i]-1);
        c[i]=0;
    }
    c[n-1]=0;

    
    for(i=0;i<q;i++){
        cin >> p[i] >> x[i];
        c[p[i]-1] +=x[i]; 
    }
    

    for(i=1;i<n;i++){
        c[i]+=c[tree.par[i]];
    }

    for(i=0;i<n;i++){
        cout << c[i];
        cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 200005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int a[maxn], n;
int Max, Second;
int num;
int main() {
    n = read();
    for (reg int i = 1; i <= n; i++) {
        a[i] = read();
        if (a[i] == Max) num++;
        else if (a[i] > Max) Max = a[i], num = 1;
    }
    if (num == 1) {
        for (reg int i = 1; i <= n; i++) {
            if (a[i] != Max) Second = max(Second, a[i]);
        }
    }
    if (num == 1) {
        for (int i = 1; i <= n; i++) {
            if (a[i] == Max) cout << Second << endl;
            else cout << Max << endl;
        }
    }
    else for (int i = 1; i <= n; i++) cout << Max << endl;
    return 0;
}



Measured memory_bytes: 2432
import itertools

arr = [0] * 5
for i in range(5):
    arr[i] = int(input())

total = []
for v in itertools.permutations(arr, 5):
    s = 0
    for i in range(4):
        if v[i] % 10 == 0:
            s += v[i]
        else:
            s += (v[i] // 10) * 10 + 10
    s += v[4]
    total.append(s)

print(min(total))


Measured memory_bytes: 3060
using System;
					
public class Program
{
	public static void Main()
	{
		var sp = Console.ReadLine().Split();
		if(sp[0] == sp[1]&&sp[0] != sp[2])Console.WriteLine("Yes");
		else if(sp[0] == sp[2]&&sp[1] != sp[2])Console.WriteLine("Yes");
		else if(sp[2] == sp[1]&&sp[0] != sp[2])Console.WriteLine("Yes");
		else Console.WriteLine("No");
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

string s;

/* add your algorithm here */

int main() {
  cin >> s;

  map<char, int> mp;

  rep(i,s.size()) {
    mp[s[i]] = 1;
  }

  string res(s);

  if (s.size() < 26) {
    for (char ch = 'a'; ch <= 'z'; ++ch) {
      if (!mp[ch]) {
        s.pb(ch);
        break;
      }
    }
    cout << s << endl;
    // S.size = 26
  } else {
    if (!next_permutation(s.begin(), s.end())) {
      cout << -1 << endl;
      return 0;
    }

    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == res[i]) continue;
      s.erase(s.begin() + i + 1, s.end());
      break;
    }

    cout << s << endl;
  }

}


Measured memory_bytes: 256
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries


let () = Scanf.sscanf (read_line ()) "%d %d" (
        fun n k -> 
                let t = n mod k in
                        if t < abs (t - k) then
                                t
                        else
                                abs (t - k)
) |> Printf.printf "%d\n"


Measured memory_bytes: 5348
/*input
58 23 42
*/
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <limits>
#include <tuple>
#include <iostream>
#include <cstdlib>
#include <time.h>

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << ((abs(a-b)&1) ? "Borys" : "Alice");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    ll n;
    cin >> n;
    vl a(n+1);
    Fori(i, 1, n+1) {
        for(int j=i; j<=n; j+= i) {
            a[j]++;
        }
    }
    ll ans = 0;
    Fori(i, 1, n+1) {
        ans += i * a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81300
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string S;
	cin >> S;
	if(S[S.size()-1]=='s')
		S = S + "es";
	else
		S = S + 's';

	cout << S << endl;

	return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <set>
using namespace std;
set<int> s;
int main() {
	int x, y;
	cin >> x;
	int arr[x];
	for(int i = 0;i < x;i++){
		cin >> y;
		arr[i] = y;
	}
    set<int> s(&arr[0], &arr[x]);
    cout << s.size() << endl;
	return 0;
}

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

signed main(){
  int n, k, c;
  bool isWorkDays[200000];
  cin >> n >> k >> c;
  for(int i = 0; i < n; i++){
    char charaWork;
    cin >> charaWork;
    isWorkDays[i] = (charaWork == 'o');
  }

  int holiday = c;

  int needsWorkAfter[200000];
  int needsWorkBefore[200000];
  int day = k - 1;
  for(int i = n - 1; i >= 0 || day >= 0; i--){
    if(isWorkDays[i]){
      needsWorkBefore[day] = i;
      i -= holiday; 
      day--;
    }
 }

 day = 0;
 for(int i = 0; i < n || day < k; i++){
   if(isWorkDays[i]){
     needsWorkAfter[day] = i;
     i += holiday;
     day++;
   }
 }

 for(int i = 0; i < k; i++){
   if(needsWorkAfter[i] == needsWorkBefore[i]){
     cout << needsWorkAfter[i] + 1 << endl;
   }
 }
 return 0;
}


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

int main() {
  // 変数の型宣言と代入
  const int inf = 100000000; // とりあえず未確定な距離は無限にする用
  int N, M;
  cin >> N >> M;
  vector<int> a(1000), b(1000), c(1000);
  vector<vector<int>> dist(100, vector<int>(100));
  // 隣接ノードとリンクの代入
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
    // ノード番号はdistの位置を表す変数として使うため、
    //　0始まりになるように設定しておく。
    a.at(i)--;
    b.at(i)--;
  }

  // ↓ここから初期設定
  // -----------------------------------------------------------------
  // スタートノードとゴールノードが同じdistには0を
  // スタートノードとゴールノードが違うdistにはinfを代入
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        dist.at(i).at(j) = 0;
      }
      else {
        dist.at(i).at(j) = inf;
      }
    }
  }
  //とりあえず隣接するノードの最短距離には接続リンクの値を代入
  for (int i = 0; i < M; i++) {
    dist.at(a.at(i)).at(b.at(i)) = min(dist.at(a.at(i)).at(b.at(i)), c.at(i));
    dist.at(b.at(i)).at(a.at(i)) = min(dist.at(b.at(i)).at(a.at(i)), c.at(i));
  }
  // -----------------------------------------------------------------
  // ↑ここまで初期設定

  // -----------------------------------------------------------------
  // ここでワーシャル・フロイド法とやらを使う
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist.at(i).at(j) = min(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
      }
    }
  }
  // やったね! これで最短経路が求まったyo!
  // ------------------------------------------------------------------

  // ------------------------------------------------------------------
  // 最短経路に含まれないリンク数を数える。
  // 基本的に全てのリンクが最短経路に含まれないと仮定し、答えans = Mと置いておく。
  int ans = M;
  // リンクひとつひとつについて最短経路に含まれるか確認。初めにcount=0としておき、
  // そのリンクが最短経路に含まれる場合はcount++
  for (int i = 0; i < M; i++) {
    int count = 0;
    for (int j = 0; j < N; j++) {
      if (dist.at(j).at(b.at(i)) == dist.at(j).at(a.at(i)) + c.at(i)) {
        count++;
      }
    }
  // count=0のまま→何もしない
  // count>0→ans--
    if (count > 0) {
      ans--;
    }
  }
  // ----------------------------------------------------------------------

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

const int INF = 1e9;
const int N = 500;
const int C = 30;
int n, c;
int diff[C][C], color[N][N];
int cost[3][C];

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

	cin >> n >> c;
	for (int i = 0; i < c; i++) {
		for (int j = 0; j < c; j++) cin >> diff[i][j];
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> color[i][j];
			color[i][j]--;
			
			int k = (i + j) % 3;
			for (int x = 0; x < c; x++) {
				cost[k][x] += diff[color[i][j]][x];
			}
		}
	}
	
	int answer = INF;
	for (int x = 0; x < c; x++) {
		for (int y = 0; y < c; y++) {
			if (y == x) continue;
			for (int z = 0; z < c; z++) {
				if (z == y || z == x) continue;
				answer = min(answer, cost[0][x] + cost[1][y] + cost[2][z]);
			}
		}
	}
	cout << answer << endl;
}


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


// 44 27.672
// 46 33.227 240 2011/10/28
// 2011/10/29

// 0105 Book index
public class Main {


	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		Map<String, List<Integer>> map = new TreeMap<String, List<Integer>>();  
		
		for(;;) {
			String line = reader.readLine();
			if (line == null)
				break;
			String[] sp = line.split(" ");
			String word = sp[0];
			int page = Integer.parseInt(sp[1]);
			List<Integer> list = map.get(word);
			if (list == null) {
				list = new ArrayList<Integer>();
				map.put(word, list);
			}
			list.add(page);
		}
		
		for(String word: map.keySet()) {
			List<Integer> list = map.get(word);
			System.out.printf("%s\n", word);
			Collections.sort(list);
			for(int i = 0; i < list.size(); i++) {
				if (i != 0)
					System.out.printf(" ");
				System.out.printf("%d", list.get(i));
			}
			System.out.printf("\n");
		}
		
		return false;
//		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "style 12:even 253:";
			
			inputStr = inputStr.replace(":", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		int N = Integer.MAX_VALUE;
		//int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌæØè¶æØèÅÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = reader.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // ¦¦¦@Ç¤àËRósðÇÞ±Æª éBÇÝòÎ·Æ¤Ü­¢­çµ¢BBBB
				break;
		}
		
		String[] sp = s.split("[ ,]"); // æØè¶ÍXy[X©J}
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 12000
#include <cstdio>

using namespace std;

int in(void)
{
	int x;
	scanf("%d", &x);
	return (x);
}

int main()
{
	char symbol = '+';
	int ans = 0;
	
	do {
		if (symbol == '+') ans += in();
		if (symbol == '-') ans -= in();
		if (symbol == '*') ans *= in();
		if (symbol == '/') ans /= in();
		scanf(" %c", &symbol);
	} while (symbol != '=');
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1), eps = 1e-10;
int n, L;
double alpha[3003], resx = 0, resy = 0;
double M(double x1, double x2) {
    double len = x2 - x1, mid;
    if (len < -eps) len += 2 * pi;
    if ((mid = x1 + len / 2) >= 2 * pi - eps) mid -= 2 * pi;
    return mid;
}
int main() {
    scanf("%d%d", &n, &L);
    for (int i = 0, x; i < n; ++i) scanf("%d", &x), alpha[i] = 2 * pi * x / L;
    for (int i = 0; i < n; ++i) {
        double sx = 0, sy = 0;
        for (int j = (i + 1) % n, k = 0; j != i; j = (j + 1) % n, ++k) {
            double m = M(alpha[j], alpha[i]), arg = alpha[j] - alpha[i];
            double tx = cos(alpha[i]) - cos(m), ty = sin(alpha[i]) - sin(m);
            resx += cos(m) * k, resy += sin(m) * k;
            resx += tx * sx - ty * sy, resy += tx * sy + ty * sx;
            if (arg < -eps) arg += 2 * pi;
            sx += cos(arg / 2), sy += sin(arg / 2);
        }
    }
    resx /= 0.5 * n * (n - 1) * (n - 2), resy /= 0.5 * n * (n - 1) * (n - 2);
    printf("%.15lf %.15lf\n", resx, resy);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b>c+d) cout << "Left" << endl;
  if (a+b<c+d) cout << "Right" << endl;
  if (a+b==c+d) cout << "Balanced" << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    same = list()

    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            same.append(True)
        else:
            same.append(False)
    
    for i in range(N-2):
        if same[i] and same[i + 1] and same[i + 2]:
            print("Yes")
            exit()
    
    print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;
bool f=false;
int n,a[maxn];
char s[maxn];

int check(int i,int x){
	int l=i-1,r=i+1;
	if(i==1)
		l=n;
	if(i==n)
		r=1;
	if(x){
		if((s[i]=='o'&&a[r]!=a[l])||(s[i]=='x'&&a[r]==a[l]))
			return true;
		else
			return false;
	}
	else{
		if((s[i]=='o'&&a[r]==a[l])||(s[i]=='x'&&a[r]!=a[l]))
			return true;
		else
			return false;
	}
}

void dfs(int dep,int x){
	if(f)
		return ;
	a[dep]=x;
	if(dep>n)
		return ;
	if(n==dep&&check(dep,x)&&check(1,a[1])){
		f=true;
		return ;
	}
	if(x){
		if(s[dep]=='o')
			dfs(dep+1,a[dep-1]^1);
		else
			dfs(dep+1,a[dep-1]);
	}
	else{
		if(s[dep]=='o')
			dfs(dep+1,a[dep-1]);
		else
			dfs(dep+1,a[dep-1]^1);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cin>>s+1;
	a[1]=1;
	dfs(2,1);
	if(!f){
		mm(a,0);
		a[1]=1;
		dfs(2,0);
	}
	if(!f){
		mm(a,0);
		a[1]=0;
		dfs(2,0);
	}
	if(!f){
		mm(a,0);
		a[1]=0;
		dfs(2,1);
	}
	if(f){
		for(int i=1;i<=n;i++){
			if(a[i])
				cout<<"W";
			else
				cout<<"S";
		}
	}
	else
		cout<<-1;
	cout<<"\n";
	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1 && b == 2) puts("3");
  if(a == 1 && b == 3) puts("2");
  if(a == 2 && b == 1) puts("3");
  if(a == 2 && b == 3) puts("1");
  if(a == 3 && b == 1) puts("2");
  if(a == 3 && b == 2) puts("1");
  return 0;
}


Measured memory_bytes: 256
#pragma region
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 3e3 + 5;
int n;
double p[maxn], dp[maxn][maxn];
int main() {
    IO;
    cin >> n;
    rep(i, 1, n) cin >> p[i];
    dp[0][0] = 1;
    rep(i, 1, n) per(j, 0, i) if (!j) dp[i][j] = dp[i - 1][j] * (1 - p[i]);
    else dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 49420
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n,ans=0;
	cin>>n;
	vector<pair<int,int>> s(n),t(n);
	for(int i=0;i<n;i++){
		cin>>s[i].second>>s[i].first;
	}
	for(int i=0;i<n;i++){
		cin>>t[i].first>>t[i].second;
	}
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(s.begin(),s.end());
	map<int,bool> c;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(c[j]) continue;
			if(s[j].first<t[i].second&&s[j].second<t[i].first){
				ans++;
				c[j]=true;
              break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ALL(c) begin(c),end(c)
#define SZ(c) ((int)c.size())
const int INF=1001001001001001001ll;
using pii = pair<int,int>;
int N,M,K,S,P,Q;
vector<int> c;
vector<bool> dang;
vector<bool> ng;
vector<int> already;
vector<vector<int>> g;
void rec(int i, int b) {
    if(b==0) return;
    dang[i]=true;
    for(auto x : g[i]) {
        if(already[x]>=b-1) continue;
        rec(x,b-1);
    }
    already[i]=b;
}
signed main() {
    cin>>N>>M>>K>>S>>P>>Q;
    c=vector<int>(K);
    dang=vector<bool>(N,false);
    ng=vector<bool>(N,false);
    g=vector<vector<int>>(N);
    already=vector<int>(N,0);
    for(int i=0; i<K; i++) cin>>c[i],c[i]--,ng[c[i]]=true;
    for(int i=0; i<M; i++) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for(int i=0; i<K; i++) {
        rec(c[i],S+1);
    }

    vector<int> cost(N,INF);
    priority_queue<pii,vector<pii>,greater<pii>> pq;
    pq.push({0,0});
    cost[0]=0;
    while(!pq.empty()) {
        int u=pq.top().second;
        pq.pop();
        for(auto v:g[u]) {
            if(ng[v]) continue;
            if(dang[v]) {
                if(cost[v]>cost[u]+Q) {
                    cost[v]=cost[u]+Q;
                    pq.push({cost[v],v});
                }
            } else {
                if(cost[v]>cost[u]+P) {
                    cost[v]=cost[u]+P;
                    pq.push({cost[v],v});
                }
            }
        }
    }
    if(dang[N-1]) {
        cost[N-1]-=Q;
    } else {
        cost[N-1]-=P;
    }
    cout<<cost[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 13356
import sys
def 解():
    iH, iW = [int(x) for x in input().split()]
    iCount = 0
    iSum = 0
    aHW = [[int(x) % 2 for x in sLine.split() ] for sLine in  sys.stdin.readlines()]
    aRoute = []
    aTe = []
    aMove = []


    for i in range(iH):
        if i % 2 == 0:
            for j in range(iW):
                aRoute.append((i,j))
        else:
            for j in range(iW-1,-1,-1):
                aRoute.append((i,j))
    iF = 0
    for y,x in aRoute:
        iV = aHW[y][x]
        if iV and iF == 0:
            aMove.append((y+1,x+1))
            iF = 1
        elif iV == 0 and iF :
            aMove.append((y+1,x+1))
        elif iV and iF :
            aMove.append((y+1,x+1))
            for i in range(len(aMove)-1):
                aM = (aMove[i],aMove[i+1])
                aTe.append(aM)
            aMove = []
            iF = 0
    aOut=[]
    aOut.append(str(len(aTe)))
    for aE in aTe:
        aOut.append("{} {} {} {}".format(aE[0][0],aE[0][1],aE[1][0],aE[1][1]))
    print("\n".join(aOut))
解()


Measured memory_bytes: 74352
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
using namespace std;
const int N = 1005;
const int M = 2e5 + 5;
vector<int> v[N];
bitset<N> vis;
int n, m, g1[N][N], g2[N][N], pre[N];
struct node{int x, y;}e[M];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void dfs(int x, int now)
{
	g1[now][x] = 1; vis.set(x);
	for(int i = 0; i < (int)v[x].size(); i ++)
	{
		int y = v[x][i]; if(vis[y]) continue;
		dfs(y, now);
	}
}
void dfs(int x, int id, int k, int now)
{
	if(!k) pre[x] = id; else g2[now][x] = (pre[x] != id);
	vis.set(x);
	for(int i = 0; i < (int)v[x].size(); i ++)
	{
		int y = v[x][i]; if(vis[y]) continue;
		dfs(y, id, k, now);
	}
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); m = read();
	for(int i = 1, x, y; i <= m; i ++)
	{
		x = read(); y = read();
		v[x].push_back(y); e[i] = node{x, y};
	}
	for(int i = 1; i <= n; i ++) {vis.reset(); dfs(i, i);}
	for(int i = 1; i <= n; i ++)
	{
		vis.reset(); vis.set(i); memset(pre, 0, sizeof(pre)); int d = v[i].size();
		for(int j = 0; j < d; j ++) if(!vis[v[i][j]]) dfs(v[i][j], j + 1, 0, i);
		vis.reset(); vis.set(i);
		for(int j = d - 1; j >= 0; j --) if(!vis[v[i][j]]) dfs(v[i][j], j + 1, 1, i);//d - 1
	}
	for(int i = 1; i <= m; i ++)
	{
		if(g1[e[i].y][e[i].x] ^ g2[e[i].x][e[i].y]) puts("diff");
		else puts("same");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  map<string, int> m;
  rep(i, n) {
    in(string, s);
    m[s]++;
  }
  vector<string> v = {"AC", "WA", "TLE", "RE"};
  for (auto k : v) {
    cout << k << " x " << m[k] << endl;
  }
}


Measured memory_bytes: 3636
s = raw_input()
N = len(s)
ans = 0
T = 0
for i in range(N):
    if s[i] == 'p':
        if T > 0:
            T -= 1
        else:
            T += 1
            ans -= 1
    else: # 'g'
        if T > 0:
            T -= 1
            ans += 1
        else:
            T += 1
print ans

Measured memory_bytes: 5892
// 18:05 -
#include <iostream>

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

int main() {
  int k, a, b;
  std::cin >> k >> a >> b;

  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      std::cout << "OK" << '\n';
      return 0;
    }
  }

  std::cout << "NG" << '\n';
  return 0;
}


Measured memory_bytes: 3648
# include<iostream>
# include<algorithm>
# include<cctype>
# include<cstdio>
# include<cstring>
# include<cmath>
# include<limits.h>
using namespace std;
int main()
{
      int a, b, c;
      cin >> a >> b >> c;
      if (a==b&&a!=c) cout << "Yes" << endl;
      else if (a==c&&a!=b) cout <<"Yes" << endl;
      else if (b==c&&b!=a) cout <<"Yes" << endl;
      else cout << "No" << endl;
      return 0;
}


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

int main()
{
  int N ;
  cin>>N ;
  int p[N] ;
  for(int i=0;i<N;i++) cin>>p[i] ;
  
  int flag=0 ;
  for(int i=0;i<N;i++) if(p[i]!=i+1) flag++ ;
  if(flag==2||flag==0) cout<<"YES"<<endl ;
  else cout<<"NO"<<endl ;
  
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 1 << 16;
const int LOGN = 19;

int n, m, k;
struct event {
  event(int t, int x) : t(t), x(x) {}
  int t;
  int x;
  bool operator<(const event& rhs) const
  {
    return t < rhs.t || (t == rhs.t && x < rhs.x);
  }
};

vector<event> e;

void solve(int test)
{
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int s, t, x;
    cin >> s >> t >> x;
    e.emplace_back(s - x, x);
    e.emplace_back(t - x, -x);
  }
  sort(e.begin(), e.end());
  size_t p = 0;
  set<int> st;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    for (;p < e.size() && e[p].t <= x; ++p) {
      if (e[p].x > 0) {
        st.insert(e[p].x);
      }
      else {
        st.erase(-e[p].x);
      }
    }
    if (st.empty()) {
      cout << "-1\n";
    }
    else {
      cout << *st.begin() << '\n';
    }
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 13804
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;
	
	if (S[0] != 'A') {
std::cerr << "1\n";
		std::cout << "WA\n";
		return 0;
	}
	
	auto citr = std::find(S.begin() + 2, S.end() - 1, 'C');
	if (citr == S.end() - 1) {
std::cerr << "2\n";
		std::cout << "WA\n";
		return 0;
	}
	
	if (std::find(citr + 1, S.end() - 1, 'C') != S.end() - 1) {
std::cerr << "3\n";
		std::cout << "WA\n";
		return 0;
	}
	
	for (auto it = S.begin() + 1; it != S.end(); ++it) {
		if (it == citr)
			continue;
		if (*it < 'a' || *it > 'z') {
std::cerr << "4\n";
			std::cout << "WA\n";
			return 0;
		}
	}
	
	std::cout << "AC\n";
}


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

using namespace std;

#define ll long long
#define foreach(it, S) for(__typeof (S.begin()) it = S.begin(); it != S.end(); it++)
#define all(x) x.begin(), x.end()
#define endl '\n'
#define _ ios_base :: sync_with_stdio (false); cin.tie (NULL);

const double eps = 1e-9;
const int MAXN = int (5e6) + 256, MXN = int (1e6);
const int MOD = int (1e9) + 7;

inline int nxtnt() {
	int s = 1, x = 0, c = getc(stdin);
	while (c <= 32)
		c = getc(stdin);
	if (c == '-')
		s = -1, c = getc(stdin);
	while ('0' <= c && c <= '9')
		x = x * 10 + c - '0', c = getc(stdin);
	return x * s;
}

template <typename T> inline T gcd (T a, T b) { while (a && b) a > b ? a %= b : b %= a; return a + b; }
inline bool Palindrome (const string& s) { return equal (s.begin(), s.end(), s.rbegin()); }

int a[MAXN];

inline int diff(int a, int b) {
	return abs(a-b);
}

int main () { // _
	int n = nxtnt();

	for (int i = 0; i < n; ++i) {
		a[i] = nxtnt();
	}

	int N = max_element(a, a + n) - a;
	int K = 0;

	if (N == K) ++K;

	for (int i = 0; i < n; ++i) if (i != N) {
		if (diff(a[K], a[N] / 2) > diff(a[i], a[N] / 2))
			K = i;
	}

	printf("%d %d\n", a[N], a[K]);

	return 0;
}


Measured memory_bytes: 640
import sys


def main():
    s = list(input())
    if s[0] != 'A' or s[2:-1].count("C") != 1:
        print("WA")
    else:
        for i in range(1, len(s)):
            if ord(s[i]) < ord('a') and i != s.index('C'):
                print("WA")
                sys.exit(0)
        print("AC")


if __name__ == "__main__":
    main()


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

int main()
{

	int N;
	int i;
	int *p;
	int x=0;
	int c=0;

	scanf("%d", &N);

	p = (int*)malloc(sizeof(int) * N);
	if (p == NULL){
		printf("メモリが確保できません。\n");
		return 0;
	}

	for(i=0; i<N; i++){
		scanf("%d", p+i);
	}

	while(1){
		c++;
		if(*(p+x) == 2){
			break;
		}
		if(c == N+1){
			break;
		}
		x = *(p+x) - 1;
	}

	if(c == N+1){
		printf("-1\n");
	}
	else{
		printf("%d", c);
	}

return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> X( N ), Y( N );
	for( int i = 0; i < N; ++i ) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort( Y.begin(), Y.end() );

	for( int i = 0; i < N; ++i ) {
		if( X[i] < Y[N/2] ) {
			cout << Y[N/2] << '\n';
		}
		else {
			cout << Y[N/2 - 1] << '\n';
		}
	}

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int k,a,b; std::cin >> k >> a >> b;
    bool flag = false;
    FOR(i, min(a,b), max(a,b)) {
        if (i % k == 0) flag = true;
    }
    if (flag) std::cout << "OK" << "\n";
    else std::cout << "NG" << "\n";
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++) ans += i*(n+1-i);
    for(ll i = 0; i < n-1; i++){
        ll u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        ans -= u*(n-v+1);
    }
    cout << ans << endl;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int d, t, s;
	cin >> d >> t >> s;
	int x = ceil(d / (1.0 * s));
	if (x <= t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

//!

Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int d;
    while(cin >> d){
        int ans = 0;
        for(int i=1; i<600/d; i++){
            
            ans+=d * ( i*d * i*d );
        }

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


Measured memory_bytes: 3072
N,M,C=list(map(int,input().split()))
B=list(map(int,input().split()))


A=[]
for i in range(N):
    A.append(list(map(int,input().split())))
c=0
for i in range(N):
    res=0
    for a,b in zip(A[i],B):
        res+=a*b
    res+=C
    if(res>0):
        c+=1

print(c)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = int(input())

s.sort()

ans = sum(s)

if ans % 10 == 0:
    for i in range(n):
        if s[i] % 10 != 0:
            ans -= s[i]
            break

if ans % 10 == 0:
    ans = 0

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char s[10][10];
int main(){
	for(int i = 1; i <= 3; ++i) scanf("%s", s[i] + 1);
	for(int i = 1; i <= 3; ++i) printf("%c", s[i][i]);
	return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    int a[110];

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

    int count = 0;
    for(int i = 0; i < N; i+=2){
        if(a[i] % 2 != 0 ) ++count;
    }

    cout << count << endl;
}

Measured memory_bytes: 3620
H,W = map(int, input().split())
A = [[0 for _ in range(W+1)] for _ in range(H+1)]
for h in range(H):
  l = input()
  for w in range(W):
    A[h][w] = 0 if l[w] == '.' else 1
for h in range(H):
  n = 0
  for w in range(W):
    n += A[h][w]
  A[h][W] = n
for w in range(W):
  n = 0
  for h in range(H):
    n += A[h][w]
  A[H][w] = n
for h in range(H):
  if A[h][W] == 0: continue
  ans = []
  for w in range(W):
    if 0 < A[H][w]:
      ans.append('.' if A[h][w] == 0 else '#')
  print(''.join(map(str,ans)))


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; string s;
    cin >> a >> b >> s;
    bool ok = true;
    rep (i, s.size()) {
        if (i == a) ok &= s[i] == '-';
        else ok &= (s[i] >= '0' && s[i] <= '9');
    }
    cout << (ok ? "Yes\n" : "No\n");
    return 0;
}

Measured memory_bytes: 256
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 1001
#define most_prime_number 2000010
#define prime_MAX_arr 2000010/2
ll PRIME[2000010];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/

#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 2000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;

ll C(ll n)
{
    if(n < 2) return 0;

    return (n*(n-1))/2;
}

int main()
{
    ll m, n;
    cin >> n >> m;
    cout << C(n) + C(m);
}



Measured memory_bytes: 256
import sys
#import time
#import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import itertools
#input = sys.stdin.readline
#sys.setrecursionlimit(10**6)
 
def ri():
    return list(map(int, input().split()))
def rs():
    return list(input().strip())
 
k = int(input())
s = str(input())
if len(s)<=k:
    print(s)
else:
    print(s[:k]+"...")

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int a[1005];
int b[1005];
int main(int argc,char const* argv[])
{
  int n,h,w;
  int ans=0;
  cin >> n >> h >> w;
  for(int i=0;i<n;i++)
    {
      cin >> a[i] >> b[i];
      if(a[i]>=h && b[i]>=w) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/agc036/submissions/6498999
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAXV = 200000;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n), conv(n, -1), prv(MAXV + 1, -1), fst(MAXV + 1, -1);
	rep(i,n){
		cin >> a[i];
		if(prv[a[i]] == -1){
			prv[a[i]] = i;
			fst[a[i]] = i;
		}
		else{
			conv[prv[a[i]]] = i + 1 - prv[a[i]];
			prv[a[i]] = i;
		}
	}
	if(n == 1){
		if(k%2 == 1) cout << a[0] << endl;
		return 0;
	}
	for(int i = 1; i <= MAXV; ++i){
		if(fst[i] == -1) continue;
		conv[prv[i]] = fst[i] + n + 1 - prv[i];
	}
	ll cur = 0, cycle = 0;
	while(true){
		ll nex = cur + conv[cur % n];
		if(nex > n * k) break;
		cur = nex;
		if(cur%n == 0){
			cycle = cur / n;
			break;
		}
	}
	if(cycle > 0) k %= cycle;
	cur = 0;
	while(true){
		ll nex = cur + conv[cur % n];
		if(nex > n*k){
			cur %= n;
			break;
		}
		if(nex == n*k){
			cur = n;
			break;
		}
		cur = nex;
	}
	vector<int> ans, cnt(MAXV + 1, 0);
	for(int i = cur; i < n; ++i){
		if(cnt[a[i]]){
			while(cnt[a[i]]){
				cnt[ans.back()]--;
				ans.pop_back();
			}
		}
		else{
			ans.push_back(a[i]);
			cnt[a[i]]++;
		}
	}
	rep(i,ans.size()){
		cout << ans[i] << " \n"[i+1 == ans.size()];
	}
	return 0;
}

Measured memory_bytes: 8164
# coding: utf-8

import sys
input = sys.stdin.readline

def f2(N, A, K):
    dp = [0] * (K + 1)
    for i in range(K + 1):
        if dp[i] == 0:
            # 残りi個で負けなので、ai個足した状況は勝ちになる。
            for x in A:
                if i + x <= K:
                    dp[i + x] = 1
    return(dp[K])

ans = [ "Second", "First" ]
n, k = map(int, input().split()) # 1 <= n <= 100, 1 <= k <= 10^5
a = list(map(int, input().split()))
print(ans[f2(n, a, k)])


Measured memory_bytes: 3828