akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigInteger a = BigInteger.ONE;
        BigInteger b = BigInteger.ONE;
        for(int i=0;i<N;i++){
            BigInteger ta = new BigInteger(sc.next());
            BigInteger tb = new BigInteger(sc.next());
            if(a.compareTo(ta) != 1 && b.compareTo(tb) != 1){
                a = ta;
                b = tb;
            }else if(a.compareTo(ta) != -1 && b.compareTo(tb) != -1){
                BigInteger[] aa = a.divideAndRemainder(ta);
                BigInteger[] bb = b.divideAndRemainder(tb);
                if(!aa[1].equals(BigInteger.ZERO)){
                    aa[0] = aa[0].add(BigInteger.ONE);
                }
                if(!bb[1].equals(BigInteger.ZERO)){
                    bb[0] = bb[0].add(BigInteger.ONE);
                }
                BigInteger xa = aa[0].max(bb[0]);
                a = xa.multiply(ta);
                b = xa.multiply(tb);
            }else{
                if(a.compareTo(ta) != -1){
                    BigInteger[] aa = a.divideAndRemainder(ta);
                    if(!aa[1].equals(BigInteger.ZERO)){
                        aa[0] = aa[0].add(BigInteger.ONE);
                    }
                    a = aa[0].multiply(ta);
                    b = aa[0].multiply(tb);
                }else{
                    BigInteger[] bb = b.divideAndRemainder(tb);
                    if(!bb[1].equals(BigInteger.ZERO)){
                        bb[0] = bb[0].add(BigInteger.ONE);
                    }
                    a = bb[0].multiply(ta);
                    b = bb[0].multiply(tb);
                    
                }
            }
        }
        System.out.println(a.add(b));
    }
}


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

using namespace std;

long long h, n, curr;
long long a[1005], b[1005];
long long dp[10005];

int main() {
	memset(dp, 0, sizeof(dp));
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= h; i++) {
		curr = 1e8+10;
		for (int j = 0; j < n; j++) {
			if (i - a[j] <= 0) {
				curr = min(curr, b[j]);
			}
			else {
				curr = min(curr, dp[i - a[j]] + b[j]);
			}
		}
		dp[i] = curr;
	}
	cout << dp[h];
	return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
n,m,q = map(int, input().split())

d = [[0 for _ in range(n+1)] for _ in range(n+1)]

for _ in range(m):
    l,r = map(int, input().split())
    d[l][r] += 1
for i in range(n,0,-1):
    for j in range(n):
        d[i][j+1] += d[i][j]
for j in range(n,0,-1):
    for i in range(n,0,-1):
        d[i-1][j] += d[i][j]

pq = []
for _ in range(q):
    p,q = map(int, input().split())
    pq.append([p,q])

# print(d)
for o in pq:
    print(d[o[0]][o[1]])


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

int main() {
    string s;
    cin >> s;
    vector<int> ans(s.size());
    int change;//左端のL
    int x=1;//LまでのRの数
    int y=1;//Lの数
    for(int i = 1; i < s.size(); i++) {
        if(s[i-1]=='R' && s[i]=='R'){
            x++;
        }
        if(s[i-1]=='R' && s[i]=='L'){
            change = i;
        }
        if(s[i-1]=='L' && s[i]=='L'){
            y++;
        }
        if(s[i-1]=='L' && s[i]=='R'){
            if((x+y)%2==0){
                ans[change-1]=(x+y)/2;
                ans[change]=(x+y)/2;
            }
            else{
                if(x%2==1){
                    ans[change-1]=(x+y)/2+1;
                    ans[change]=(x+y)/2;
                }
                else{
                    ans[change-1]=(x+y)/2;
                    ans[change]=(x+y)/2+1;
                }
            }
            x =1;
            y =1;
        }
    }
    
    if((x+y)%2==0){
        ans[change-1]=(x+y)/2;
        ans[change]=(x+y)/2;
    }
    else{
        if(x%2==1){
            ans[change-1]=(x+y)/2+1;
            ans[change]=(x+y)/2;
        }
        else{
            ans[change-1]=(x+y)/2;
            ans[change]=(x+y)/2+1;
        }
    }

    for(int i = 0; i < s.size()-1;i++) {
        cout << ans[i] << ' ';
    }
    cout << ans[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,ans;
int a[200005],b[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i]>>b[i];
	
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	
	if (n%2==0)  ans=b[n/2]+b[(n/2)+1]-a[n/2]-a[(n/2)+1]+1;
	else ans=b[(n+1)/2]-a[(n+1)/2]+1;
	
	cout<<ans<<endl;
	
	return 0;  
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
int main() {
  int n;
  cin >> n;
  ll ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i < n; i++) {
    if (i+2 < n) {
      if (ar[i] < 0 && ar[i+1] > 0 && ar[i+2] < 0) {
        ar[i] = -ar[i];
        ar[i+2] = -ar[i+2];
      } else if (ar[i] < 0 && ar[i+1] < 0) {
        ar[i] = -ar[i];
        ar[i+1] = -ar[i+1];
      }
    }
  }
  int cnt_neg = 0;
  for (int i = 0; i < n; i++) {
    if (ar[i] < 0) cnt_neg++;
  }
  ll sum = 0;
  ll buang = 0;
  if (cnt_neg%2) {
    buang = INT_MAX;
    for (int i = 0; i < n; i++) {
      buang = min(buang, abs(ar[i]));
    }
  }
  for (int i = 0; i < n; i++) {
    sum += abs(ar[i]);
  }
  sum -= 2*buang;
  cout << sum << el;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[110];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; ++i)
		scanf("%d", &a[i]);
	int flag = 1;
	for(int i=0; i<n; ++i)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0 && a[i]%5!=0)
			{
				flag = 0;
				break;
			}
		}
	}
	if(flag)	puts("APPROVED");
	else	puts("DENIED");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


public class Main {
	
	private static int[] cache = new int[44 + 1];

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

		int n = sc.nextInt();
		
		int ret = fibonacciNum(n);
		
		System.out.println(ret);
		
         sc.close();
	}
	
	private static int fibonacciNum(int n) {
		if (cache[n] != 0) {
			return cache[n];
		}
		
		if (n == 0) {
			cache[n] = 1;
			return 1;
		} else if (n == 1) {
			cache[n] = 1;
			return 1;
		} else {
			cache[n] = fibonacciNum(n - 1) + fibonacciNum(n - 2);
			return cache[n];
		}
	}
}

Measured memory_bytes: 17164
#include <stdio.h>
#include <string.h>

int main(){
  int i, sum = 0;
  char str[1000] = {0};
  //str[0] = 'a';
  while(1) {
    scanf("%s", str);
    if(str[0] == '0') {
      break;
    }
    for(i = 0; i < strlen(str); i++) {
      sum += ((int)str[i] - 48);
    }
    printf("%d\n", sum);
    sum = 0;
  }
  return 0;
}



Measured memory_bytes: 2696
X = int(input())

if 400<=X and X<600:
  print('8')
elif 600<=X and X<800:
  print('7')
elif 800<=X and X<1000:
  print('6')
elif 1000<=X and X<1200:
  print('5')
elif 1200<=X and X<1400:
  print('4')
elif 1400<=X and X<1600:
  print('3')
elif 1600<=X and X<1800:
  print('2')
elif 1800<=X and X<2000:
  print('1')


Measured memory_bytes: 61632
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include <assert.h>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>
#include<stack>
#include <unordered_map>
#include<cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)
#define PII pair<int,int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
const int maxn=333333,mod=1000000009;
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){char ch=getchar();int x=0,f=0;while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return f?-x:x;} 

int main()
{
    string s;
    cin >> s;
    if (s == "ABC") puts("ARC");
    else puts("ABC");
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main(){
 
  int a,c5 = 0,c7 = 0;
  
  for(int i=0;i<3;i++){
  cin >> a;
  if(a == 5)c5++;
  else if(a==7)c7++;
  else break;
  }
 
  cout << (c5==2 && c7==1 ? "YES" : "NO") << endl;
  
  return  0;
}

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

 
using namespace std;
 
#define ll long long
#define ul unsigned long long
#define snd second
#define fst first


int main(){
    std::ios::sync_with_stdio(false);
    string a1,b1; cin >> a1 >> b1;
    int a = stoi(a1);
    int b = stoi(b1);
    string answer1 = "";
    string answer2 = "";
    for(int i=0;i<a;i++){
        answer1 += b1;
    }
     for(int i=0;i<b;i++){
        answer2 += a1;
    }
    cout << min(answer2,answer1);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a, b, c, i;
	int n=0;
	scanf("%d %d %d", &a, &b, &c);
	for(i=a; i<=b; i++){
		int mod= c % i; /*modは％を使って計算できる*/
		if(mod == 0){
			n++;
		}
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

#define N 101
#define M 101
#define L 101

long long calc(int a[][M], int b[][L], int n, int m, int maxWidth);

int main(){
	
	int a[N][M];
	int b[M][L];
	long long c[N][L];
	
	int n, m, l;
	int i, i2;
	
	scanf("%d %d %d", &n, &m, &l);
	for(i = 0; i < n; i++){
		for(i2 = 0; i2 < m; i2++){
			scanf("%d", &a[i][i2]);
		}
	}
	for(i = 0; i < m; i++){
		for(i2 = 0; i2 < l; i2++){
			scanf("%d", &b[i][i2]);
		}
	}
	for(i = 0; i < n; i++){
		for(i2 = 0; i2 < l; i2++){
			c[i][i2] = calc(a, b, i, i2, m);
			
			if(i2 > 0){
				printf(" ");
			}
			printf("%lld", c[i][i2]);
		}
		puts("");
	}
	
	return 0;
	
}

long long calc(int a[][M], int b[][L], int n, int m, int maxWidth){
	
	int i, i2;
	long long ret = 0;
	
	for(i = 0; i < maxWidth; i++){
		ret += (a[n][i] * b[i][m]);
	}
	
	return ret;
}

Measured memory_bytes: 696
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

int arr[100005];
void solve() {
	int n, k, q;
	cin >> n >> k >> q;
	for(int i = 0; i < q; ++i) {
		int x;
		cin >> x; 
		arr[x]++;
		}
		for(int i = 1; i <= n; ++i) {
			if(q - arr[i] < k) cout << "Yes" << endl;
			else cout << "No" << endl;
			}
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



Measured memory_bytes: 4040
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static String a;
	static boolean[] isntPrime;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		makePrimeList(100000000);
		int n = stdIn.nextInt();
		int count = 0;
		for(int i = 0; i < n; i++) {
			int x = stdIn.nextInt();
			if(x != 2 && x % 2 == 0) {
				continue;
			}
			if(!isntPrime[x]) {
				count++;
			}
		}
		System.out.println(count);
	}
	
	
	public static void makePrimeList(int n) {
		isntPrime = new boolean[n+1];
		isntPrime[0] = isntPrime[1] = true;
		for(int i = 3; i < n; i+=2) {
			if(!isntPrime[i]) {
				for(int j = i + i; j < n; j += i){
					isntPrime[j] = true;
				}
			}
		}
	}
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int turn = 0;
  while(a > 0 && c > 0) {
    if (turn == 0) {
      c -= b;
    } else {
      a -= d;
    }
    turn ^= 1;
  }
  if (a > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main () {
	long long a, b, k;
	cin >> a >> b >> k;
	a -= k;
	if(a < 0) {
		b += a;
		a = 0;
		b = max(b, (long long)0);
	}
	cout << a << " " << b << "\n";
	return 0;
}

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

using namespace std;

int main()
{
    string s[3];
    cin>>s[0]>>s[1]>>s[2];
    int ne=0, ans;
    while (1)
    {
        if (!s[ne].size()) { ans=ne; break; }
        int n=s[ne][0]-'a';
        s[ne]=s[ne].substr(1, s[ne].size()-1);
        ne=n;
    }
    if (ans==0) cout<<"A\n";
    else if (ans==1) cout<<"B\n";
    else cout<<"C\n";
    return 0;
}


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

int main(){
  
  long long N, i, cnt = 0;
  cin >> N;
  map<long long, int> A;

  for(i=0; i<N; i++){
    long long a;
    cin >> a;
    A[a]++;
  }
  
  for(auto p : A){
    cnt += p.second%2;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 9820
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals("Sunny")) {
			System.out.println("Cloudy");
		}
		else if(s.equals("Cloudy")) {
			System.out.println("Rainy");
		}
		else {
			System.out.println("Sunny");
		}

	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#define ll long long
using namespace std; 

int main(void)
{
	int n;
	ll X = 0, x = 0, ans = 1000000000000000000LL;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i]; 
		X += a[i];
	}
	for (int i = 0; i < n; i++)
	{
		x += a[i];
		if (i + 1 < n)
			ans = min(ans, abs(X - 2 * x));
	}
	cout << ans << '\n';
	return false;
}

Measured memory_bytes: 1792
N= int(input())
S = ['M','A','R','C','H']
C = [0]*5
for _ in range(N):
  X = (input())[0]
  if X in S:
    C[S.index(X)] += 1
from itertools import permutations, combinations,combinations_with_replacement,product
L = list(combinations(range(5), 3))   #nCr
ans = 0
for i in L:
  ans += C[i[0]]*C[i[1]]*C[i[2]]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int H, W, s[1400][1400], t[1401][1401];
bool check(int x) {
	for(int i = 0; i <= H - x; i++) {
		for(int j = 0; j <= W - x; j++) {
			if(!(t[i][j] + t[i + x][j + x] - t[i][j + x] - t[i + x][j])) return true;
		}
	}
	return false;
}
int main() {
	scanf("%d%d", &H, &W);
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) scanf("%d", &s[i][j]);
	}
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) t[i + 1][j + 1] = t[i + 1][j] + t[i][j + 1] - t[i][j] + s[i][j];
	}
	int l = 0, r = 1400;
	while(r - l > 1) {
		int m = (l + r) / 2;
		if(check(m)) l = m;
		else r = m;
	}
	printf("%d\n", l * l);
	return 0;
}

Measured memory_bytes: 17944
#include <bits/stdc++.h>
#define rep2(i, n, m) for (int i = m; i < (int)(n); i++)
#define rep(i, n) rep2(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;  //
template <typename T>
T sq(T x) {
  return x * x;
}
signed main() {
  string w;
  cin >> w;
  vector<int> a(26);
  for (char c : w) {
    a.at((int)(c - 'a'))++;
  }
  rep(i, 26) {
    if (a.at(i) % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}

void solve(){
    ll h;cin>>h;
    int a=log2(h);
    if(h==1){
        cout<<1<<endl;
        return;
    }
    cout<<2*(1LL<<a)-1<<endl;
}


int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3804
#include <iostream>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

int main()
{
	int N, K, tmp, count = 0;
	cin >> N >> K;
	rep(i, N){
		cin >> tmp;
		if (tmp >= K) count++;
	}
	cout << count;
	return 0;
}

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

int main() {
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  
  int dx=x2-x1;
  int dy=y2-y1;
  
  int x3=x2-dy;
  int y3=y2+dx;
  
  int x4=x1-dy;
  int y4=y1+dx;
  
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    //縦の変数：H と 横の変数：W を宣言する
    int H, W;
    
    //縦の変数：H と 横の変数：W に値を代入する
    cin >> H >> W;
    
    //縦の変数：H と 横の変数：W の値が両方とも 0 になるまで繰り返す。
    while(H != 0 && W != 0){
        
        //一行づつ「 # or . 」を置いて行くから繰り返し処理を使用する。
        //今回は繰り返し処理の中に繰り返し処理がある！!　➡　考えよう！！！！！
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                
                //交互に「 # or . 」置く条件を考える。➡　関数の各点を「 # or . 」を置く場所で考える。
                //「 # 」を置いているとき、（x,y）の値の和は偶数
                //「 . 」を置いているとき、（x,y）の値の和は奇数
                if(((i + j)%2 == 0)) cout << "#";
                else cout << ".";
            }
            
            // 1行が終了したら改行が必要なので、改行を出力する。
            cout << endl;
        }
        
        // 1つの四角形が終了したら改行が必要なので、改行を出力する。
        cout << endl;
        
         //縦の変数：H と 横の変数：W に値を代入する
        cin >> H >> W;

    }
    
    return 0;
}



/****************************************　for文　***************************************************


☆繰り返し処理をしたいときは「　for文　」を使用する


    〇書き方
    for(始まりの値； 条件式；　増加 or 減少の式){
        
    }
        
    
*********************************************************************************************************/



/****************************************　コメント無し回答　***************************************************

#include <iostream>
using namespace std;
int main(void){
    
    int H, W;
    cin >> H >> W;
    
    while(H != 0 && W != 0){
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
            
                if(((i + j)%2 == 0)) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;

    }
    
    return 0;
}
    
*********************************************************************************************************/





Measured memory_bytes: 3108
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();

		int W = sc.nextInt();

		int[][] a = new int[H][W];

		for(int i=0;i<H;i++) {

			for(int j=0;j<W;j++) {

				a[i][j] = sc.nextInt();
			}
		}

		int m = 0;

		int min = Integer.MAX_VALUE;

		for(int i=0;i<H;i++) {

			for(int j=0;j<W;j++) {

				m = solve(a,i,j,H,W);

				if(m<min) min = m;

			}
		}

		System.out.println(min);

	}

	static int solve(int[][] a, int x, int y, int H, int W) {

		int m = 0;

		int diffH = 0;

		int diffW = 0;

		for(int i=0;i<H;i++) {

			for(int j=0;j<W;j++) {

				diffH = Math.abs(x-i);

				diffW = Math.abs(y-j);

				m += Math.min(diffH, diffW) * a[i][j];

			}
		}

		return m;

	}
}



Measured memory_bytes: 29584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  string s;
  map<char,int>map;
  cin >> s;

  rep(i,4){
    char t = s[i];
    map[t]++;
  }

  if(map.size()!=2)
    cout << "No";

  else
    cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

ans = [0 for i in range(N)]
isTerms = [0 for i in range(N)]
jadge = True

for i in range(M):
    s, c = map(int, input().split())
    if( ans[s-1] != c and isTerms[s-1] != 0):
        jadge = False
    elif( s == 1 and c == 0):
        jadge = False
    else:
        ans[s-1] = c
        isTerms[s-1] = 1

if( N != 1 and ans[0] == 0 and jadge):
    ans[0] = 1

if( N == 1 and ans[0] == 0):
    jadge = True

if jadge:
    if(N==1):
        print(ans[0])
    else:
        for i in range(N-1):
            print(ans[i] ,end = "")
        print(ans[i+1])
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,a=0;
  cin>>x;
  if(x==3)a+=100000;
  if(x==2)a+=200000;
  if(x==1)a+=300000;
  cin>>x;
  if(x==3)a+=100000;
  if(x==2)a+=200000;
  if(x==1)a+=300000;
  if(a==600000)a+=400000;
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vl v(n + 1);
  REP(i, n) cin >> v[i + 1];
  REP(i, n) v[i + 1] += v[i];
  ll s = v[n];
  ll ans = INF * INF;
  FOR(i, 1, n) {
    ans = min(ans, abs(s - v[i] - v[i]));
  }
  cout << ans << endl;
}


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

const double eps = 1e-10;
bool dcmp(double d, double d2 = 0) { return abs(d - d2) < eps; }

struct vec {
  double x, y;
  vec(double x, double y) : x(x), y(y) {}
  vec() : x(0), y(0) {}
  const bool operator==(const vec &v) const {
    return dcmp(x, v.x) && dcmp(y, v.y);
  }
  const bool operator!=(const vec &v) const { return !(*this == v); }
  const vec operator+(const vec &v) const { return vec(x + v.x, y + v.y); }
  const vec operator-() const { return vec(-x, -y); }
  const vec operator-(const vec &v) const { return *this + (-v); }
  const vec operator*(const double d) const { return vec(x * d, y * d); }
  const vec operator/(const double d) const { return *this * (1 / d); }
  const vec unit() const { return *this / len(); };
  const double len() const { return sqrt(x * x + y * y); }
  const double dot(const vec &v) const { return x * v.x + y * v.y; }
  const double cross(const vec &v) const { return x * v.y - y * v.x; }
  const bool parallel(const vec &v) const { return dcmp(cross(v)); }
};

typedef vec point;

point p1, p2;
vec v;

int main() {
  cin >> p1.x >> p1.y >> p2.x >> p2.y;
  v = p2 - p1;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    point p;
    cin >> p.x >> p.y;
    vec v2 = p - p1;
    double d = v.cross(v2);
    if (p == p1 || p == p2)
      puts("ON_SEGMENT");
    else if (d > 0)
      puts("COUNTER_CLOCKWISE");
    else if (d < 0)
      puts("CLOCKWISE");
    else {
      if (v.unit() != v2.unit())
        puts("ONLINE_BACK");
      else if (v2.len() <= v.len())
        puts("ON_SEGMENT");
      else
        puts("ONLINE_FRONT");
    }
  }
}


Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> p;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
ll MOD=1e9+7;

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%13;
        a=a*a%13;
        x>>=1;
    }
    return res;
}
int n;
ll f(ll x,int c3,int c5,int c7){
    if(x>n) return 0;
    ll res=0;
    if(c3>0&&c5>0&&c7>0) res+=1;
    res+=f(x*10+3,c3+1,c5,c7);
    res+=f(x*10+5,c3,c5+1,c7);
    res+=f(x*10+7,c3,c5,c7+1);
    return res;
}
int main(){
    cin>>n;
    cout<<f(0,0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    //    max(h - | x - cx | - | y - cy |, 0)
    //    h>1
    //cx,cy <100
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    int posX = 0;
    int posY = 0;
    int maxH = 0;
    REP(i, N)
    {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > maxH)
        {
            maxH = h[i];
            posX = x[i];
            posY = y[i];
        }
    }
    //  cout << maxH << " " << posX << " " << posY << "\n";

    REP(i, 101)
    {
        REP(j, 101)
        {
            bool flg = true;
            int H = abs(posX - i) + abs(posY - j) + maxH;
            //cout << H << "\n";
            REP(k, N)
            {
                if (h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0))
                {
                    flg = false;
                    break;
                }
            }
            if (flg)
            {
                cout << i << " " << j << " " << H << "\n";
                i = 101;
                j = 101;
            }
        }
    }
}

Measured memory_bytes: 256
function Main(input){
  var arr = input.split(" ");
  var a = parseInt(arr[0],10);
  var b = parseInt(arr[1],10)
  var sum = (a * b) - (a + b - 1);
  console.log(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from collections import defaultdict, deque

def bfs(start, end, V, E):
    V[start] = 0
    Q = deque()
    Q.append(start)
    while(len(Q) > 0 and V[end] < 0):
        q = Q.popleft()
        d = V[q] + 1
        for v in E[q]:
            if V[v] > 0:
                continue
            V[v] = d
            Q.append(v)
    return V

n, m = map(int, input().split())
E = defaultdict(list)
for i in range(m):
    u, v = map(int, input().split())
    E[u].append(n + v)
    E[n + u].append(2 * n + v)
    E[2 * n + u].append(v)
s, t = map(int, input().split())
V = [-1] * (3 * n + 1)
V = bfs(s, t, V, E)
if V[t] < 0:
    print(-1)
else:
    print(V[t] // 3)


Measured memory_bytes: 79600
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    int n,k;
    cin >> n >> k;

    if(n > 8){
        cout << ":(" << endl;
        return 0;
    }
    if(k > 8){
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!" << endl;
    return 0;
       
}

Measured memory_bytes: 256
import java.lang.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = Double.parseDouble(sc.next());
        sc.close();
        System.out.printf("%f %f", n * n * Math.PI, 2 * n * Math.PI);
    }
}


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

int main() {
  int n; cin >> n;
  vector<int> as(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> as[i];
  }
  int ans = 0;
  int prevColor = 0;
  for (int i = 0; i <n; i++) {
    if (prevColor == as[i]) {
      ans++;
      prevColor = 10001;
    } else {
      prevColor = as[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;
vector <pii> v;
LL ans=0,na,nbc;

int main()
{
	cin>>s;
	if(s.size()<3) cout<<0<<endl,exit(0);
	rep(i,s.size())
	{
		if(s[i]=='A')
		{
			na++;
			continue;
		}
		if(s[i]=='B'&&i+1<s.size()&&s[i+1]=='C')
		{
			ans+=na;
			i++;
			continue;
		}
		na=0;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (int)1e9 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)1e3 + 7, MOD = (int)1e9 + 7;

int n,m;
string s[N];
ll dp[N][N];

int main(){
		
	NFS
	
	cin >> n >> m;
	
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	
	dp[0][0]=1;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(s[i][j]=='.'){
				if(i-1>=0)dp[i][j]+=dp[i-1][j];
				if(j-1>=0)dp[i][j]+=dp[i][j-1];
			}
			dp[i][j]%=MOD;
		}
	}
	
	//cout << dp[1][0]  << ' ' << dp[0][1] << endl;
	
	cout << dp[n-1][m-1]%MOD << endl;

	ioi
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
vector<int> E[N];
int n,fa[N],cnt[N],du[N],dep[N];
struct cmp {
    bool operator()(int a,int b) { return dep[a]<dep[b]; }
};
priority_queue<int,vector<int>,cmp> q;
set<int> s[N];
void dfs(int u,int ff) {
    fa[u]=ff;
    for(int v:E[u]) if(v!=ff) dep[v]=dep[u]+1,dfs(v,u);
}
void update(int u,int v) {
    s[u].insert(v);
    if(int(s[u].size())==2) puts("First"),exit(0);
}
int main() {
    cin>>n;
    for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u),du[u]++,du[v]++;
    if(n==2) return puts("Second"),0;
    if(n&1) return puts("First"),0;
    int rt=0;
    for(int i=1;i<=n;i++) if(du[i]>1) rt=i;
    dfs(rt,0);
    for(int i=1;i<=n;i++) if(du[i]==1) q.push(i),update(fa[i],i);
    while(!q.empty()) {
        int u=q.top();q.pop();
        int p=fa[fa[u]];
        if(fa[p]&&--du[p]==1) update(fa[p],p);
        if(p&&du[p]==(p!=rt)) q.push(p);
    }
    puts("Second");
    return 0;
}


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

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

	int ans = 0;
	for( int n = 0; n < 1000; n++ ) {
		int n1 = n / 100;
		int n2 = n % 100 / 10;
		int n3 = n % 10;
		int state = 0;
		for( int i = 0; i < N; i++ ) {
			int num = S[i] - '0';
			if( state == 0 && num == n1 ) state++;
			else if( state == 1 && num == n2 ) state++;
			else if( state == 2 && num == n3 ) {
				state++;
				break;
			}
		}
		if( state == 3 ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3672
n,k=map(int,input().split())
s=input()
ban=[]
if s[0]=="0": ban.append(0)
cnt=1
for i,val in enumerate(s[:-1]):
    if val!=s[i+1]:
        ban.append(cnt)
        cnt=0
    cnt+=1
if cnt>0: ban.append(cnt)
if s[n-1]=="0": ban.append(0)
ans=sum(ban[0:2*k+1])
su=ans
now=0
while now+2*k+2<=len(ban):
    su-=ban[now]+ban[now+1]
    su+=ban[now+2*k+1]+ban[now+2*k+2]
    if su>ans: ans=su
    now+=2
print(ans)

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


typedef long long ll;
typedef pair<ll,int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans;
  if(a==c) ans = 0;
  else ans = 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    string str; cin >> str;
    int s[4] = {0};
    rep(i, str.size()) {
        if (str[i] == 'S') s[0]++;
        else if (str[i] == 'W') s[1]++;
        else if (str[i] == 'E') s[2]++;
        else s[3]++;
    }
    /*
    rep(i, 4) cout << s[i] << " ";
    cout << endl;
     */
    int flg = 1;
    if (s[0]) if (!s[3]) flg = 0;
    if (s[3]) if (!s[0]) flg = 0;
    if (s[1]) if (!s[2]) flg = 0;
    if (s[2]) if (!s[1]) flg = 0;
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    if (a < 10 && b < 10) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 256
class Dice:
    def __init__(self,ls):
        self.a = ls[0]
        self.b = ls[1]
        self.c = ls[2]
        self.d = ls[3]
        self.e = ls[4]
        self.f = ls[5]
    
    def E(self):
        self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
    def W(self):
        self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
    def S(self):
        self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
    def N(self):
        self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a
    
ls = map(int,raw_input().split())
orders = raw_input()
dice = Dice(ls)
for w in orders:
    if w == 'E': dice.E()
    elif w == 'W': dice.W()
    elif w == 'S': dice.S()
    elif w == 'N': dice.N()
print dice.a

Measured memory_bytes: 4264
var binarySearch = function(key, n, arr) {
  var left = 0, right = n;
  while (left < right) {
    var mid = Math.floor((left + right) / 2);
    if (arr[mid] === key) {
      return true;
    } else if (key < arr[mid]) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  return false;
};

var countCommonNumber = function(n, s, q, t) {
  var counter = 0;
  for (var i = 0; i < q; i += 1) {
    counter += binarySearch(t[i], n, s) ? 1 : 0;
  }
  return counter;
};

(function(stdin) {
  var line = stdin.split('\n');
  var n = parseInt(line[0], 10);
  var s = line[1].split(' ').map(Number);
  var q = parseInt(line[2], 10);
  var t = line[3].split(' ').map(Number);
  console.log(countCommonNumber(n, s, q, t));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
	string S;cin>>S;
	int count=0;
	for(int i=0;i<S.size();i++){
		if(S.at(i)=='x'){
			count++;
		}
	}if(count<=7){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

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

using namespace std;

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

int main() {
	long long int n, m;
	cin >> n >> m;

	vector< vector<long long int> > shima(n);

	vector<P> ab(m);

	for (long long int i = 0; i < m; i++) {
		cin >> ab[i].first >> ab[i].second;
	}

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

	for (long long int i = 0; i < m; i++) {
		shima[ab[i].first - 1].push_back(ab[i].second - 1);
	}

	long long int kari = -1;
	long long int ans = 0;

	for (long long int i = 0; i < n; i++) {

		long long int p = -1;
		if (shima[i].size() > 0) {
			p = shima[i][0];
		}

		if (p == i+1) {
			ans++;
			kari = -1;
		} else if (p == -1) {
			if (kari == -1) {

			}
			else if (kari == i+1){
				ans++;
				kari = -1;
			}
		}
		else {
			if (kari == -1) {
				kari = p;
			}
			else if (kari == i+1) {
				ans++;
				kari = -1;
			} else {
				kari = min(kari, p);
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();W=int(W);m=int(H)*W;A=[]
for i in range(m):
 h,w=divmod(i,W)
 if S[h][w]=='S':A=[m*2,h,m*2,w+m]+A
 elif S[h][w]=='T':A=[h,m*3,w+m,m*3]+A
 elif S[h][w]=='o':A+=[h,w+m,w+m,h]
f=maximum_flow(csr_matrix(([999]*4+[1]*(len(A)//2-4),(A[::2], A[1::2])),[m*4]*2),m*2,m*3).flow_value;print(f if f<999 else -1)

Measured memory_bytes: 40792
#include<bits/stdc++.h>
#define MAX 10000
using namespace std;
int ans[MAX+1];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i*i<=MAX;++i)
	{
		for(int j=1;j*j<=MAX;++j)
		{
			for(int k=1;k*k<=MAX;++k)
			{
				int tmp = i*i+j*j+k*k+i*j+j*k+k*i;
				if(tmp<=MAX)
					++ans[tmp];
			}
		}
	}
	for(int i=1;i<=n;++i)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3560
import sys
sys.setrecursionlimit(10**6)

H, W = map(int, input().split())
S = [list(map(str, input())) for _ in range(H)]

tmp = 0
for i in range(H):
	tmp += S[i].count("#")

w_count = (H*W) - tmp

def bfs(field, dp, q):
	cp = q.pop(0)
	np = [[cp[0]+1,cp[1]], [cp[0]-1,cp[1]], [cp[0],cp[1]+1], [cp[0],cp[1]-1]]

	for n in np:
		if 0 <= n[0] <= H-1 and 0 <= n[1] <= W-1:
			if field[n[0]][n[1]] == "." and dp[n[0]][n[1]] == inf:
				q.append(n)
				dp[n[0]][n[1]] = dp[cp[0]][cp[1]] + 1
			if n == [H-1,W-1]:
				return dp[n[0]][n[1]]

	if len(q) == 0:
		return -1

	return bfs(field, dp, q)

inf = float("inf")
dp = [[inf for _ in range(W)] for _ in range(H)]
dp[0][0] = 0
nes = bfs(S, dp, [[0,0]])
if nes == -1:
	print(-1)
else:
	print(w_count-nes-1)

Measured memory_bytes: 42224
# 問題：https://atcoder.jp/contests/abc141/tasks/abc141_c


n, k, q = map(int, input().strip().split())

points = [0 for _ in range(n)]
for i in range(q):
    a = int(input())
    points[a-1] += 1
for i in range(n):
    if k - q + points[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9904
#include<bits/stdc++.h>
using namespace std;
#define int long long 
template<class T> inline bool chmin(T& a,T b){
    if( a > b) {a = b; return 1; } return 0;
}
const int INF = 1LL << 60;
signed main(){
    int n;
    cin >> n;
    vector<int> a(n),dp(100010);
    for(int i = 0; i < 100010; i++)
        dp[i] = INF;

    for(int i = 0; i < n; i++)
    cin >> a[i];
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        chmin(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
        if(i > 1)
        chmin(dp[i],dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  int d, t, s; cin >> d >> t >> s;
  cout << (t * s >= d ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 3660
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<LL,LL>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 4e3 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
char s[maxn];
int cnt[4][maxn];
int main(){
	int n;cin >> n >> s+1;
	map<int , int>mp;
	fo(i,1,n){
		if(s[i] == 'R')cnt[1][++cnt[1][0]] = i;
		if(s[i] == 'G')cnt[2][++cnt[2][0]] = i;
		if(s[i] == 'B')mp[i] = 1;
	}
	ll ans = 0;
	int sum = mp.size();
	fo(i,-2 * n,2*n){
		if(!mp.count(i))mp[i] = 0;
	}
	fo(i,1,cnt[1][0]){
		fo(j,1,cnt[2][0]){
			ans += sum;
			if(mp[min(cnt[1][i],cnt[2][j]) - abs(cnt[1][i] - cnt[2][j])] == 1)ans--;
			if(mp[max(cnt[1][i],cnt[2][j]) + abs(cnt[1][i] - cnt[2][j])] == 1)ans--;
			if(abs(cnt[1][i] - cnt[2][j])%2 ==0){
				if(mp[min(cnt[1][i],cnt[2][j]) + abs(cnt[1][i] - cnt[2][j])/2] == 1)ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define int long long

int N;
double p[3333]; // コインの表が出る確率
double dp[3333][3333]; // dp[i][j]: コインをi枚使って、表がj枚でる確率

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

  dp[0][0] = 1; // DPテーブルを初期化
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      // おもて
      dp[i+1][j+1] += dp[i][j] * p[i];
      // うら
      dp[i+1][j] += dp[i][j] * (1 - p[i]);
    }
  }

  double ans = 0;
  for (int i = N/2 +1; i <=N; i++) {
    ans += dp[N][i];
  }

  printf("%.10f\n", ans);

  return 0;
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
using namespace std;
using P = pair<int, int>;

ll f(vector<P> p)
{
    int n = p.size();
    rep(i, n) p[i].first = min(p[i].first, n);
    vector<vector<int>> s(n + 1);
    rep(i, n) s[p[i].first].push_back(p[i].second);
    ll res = 0;
    priority_queue<int> q;
    for (int i = n; i >= 1; --i)
    {
        for (int x : s[i])
            q.push(x);
        if (q.size() > 0)
        {
            res += q.top();
            q.pop();
        }
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    vector<P> pl, pr;
    ll ans = 0;
    rep(i, n)
    {
        int k, l, r;
        cin >> k >> l >> r;
        int m = min(l, r);
        ans += m;
        l -= m;
        r -= m;
        if (l > 0)
            pl.emplace_back(k, l);
        else
            pr.emplace_back(n - k, r);
    }
    ans += f(pl);
    ans += f(pr);
    cout << ans << endl;
}
int main(void)
{
    int ts;
    cin >> ts;
    rep(ti, ts) solve();
    return 0;
}

Measured memory_bytes: 10644
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int ans=0;
	cin>>n;
	if(n<105){
		cout<<"0"<<endl;
	}
	else{
		for(int i=105;i<=n;i++){
			int t=0;
			for(int j=1;j<=i;j++){
				if(i%j==0){
					t++;
				}
			}
			if(t==8)
			ans++;
			i++;
		}
		cout<<ans<<endl;
	}

  return(0);
}

Measured memory_bytes: 256