akhauriyash/Code-Regression huggingface dataset:
#B - Nice Shopping
A,B,M= map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x =[list(map(int, input().split())) for i in range(M)]

tmp_min = min(a)+min(b)

for i in range(M):
    tmp = a[x[i][0]-1]+b[x[i][1]-1] - x[i][2]
    if tmp < tmp_min:
        tmp_min = tmp
    else:
        pass

print(tmp_min)

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
 
int solve(int a , int k){
	if(a<k) return 0;
	if(a%k==0) return a/k;
	int d = a/k + 1;
	d = (a%k+d-1)/d*d;
	return solve(a-d,k);
}
 
int main(){
	cin >> N;
	int g = 0;
	repp(i,0,N){
		int A,K;
		cin >> A >> K;
		g ^= solve(A,K);
	}
	cout << (g==0?"Aoki":"Takahashi") << endl;
	return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        int now = s[0];
        int answer = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i] != now)
            {
                answer++;
            }
            now = s[i];
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13236
def main():
    n = input()
    A = map(int,raw_input().split())
    B = [0]*n
    k = max(A)
    CountingSort(A,B,k,n)

    for i in range(n-1):
        print B[i],
    print B[-1]


def CountingSort(A,B,k,n):
    C = [0]*(k+1)

    for j in range(n):
        C[A[j]] += 1

    for i in range(1,k+1):
        C[i] += C[i-1]

    for h in range(n):
        j = n-1 - h
        B[C[A[j]]-1] = A[j]
        C[A[j]] -= 1


if __name__ == "__main__":
    main()

Measured memory_bytes: 177028
from decimal import Decimal

X=Decimal(input())
ansa=0
ansb=0
# for b in range(1000):
#     a5 = Decimal(b**5) + X
#     sig = False
#     if a5 < 0:
#         sig = True
#         a5 = abs(a5)
#     a1 = pow(a5,Decimal('0.2'))

#     if sig:
#         a1 *= -1

#     if a1 == int(a1):
#         ansa=int(a1)
#         ansb=b
#         break
# if ansa >0 or ansb>0:
#     print(ansa,ansb)
#     exit()

for a in range(-1000,1000):
    b5 = Decimal(a**5) - X
    sig = False
    if a==100:
        print()
    if b5 < 0:
        sig = True
        b5 = abs(b5)
    b1 = pow(b5,Decimal('0.2'))

    if sig:
        b1 *= -1

    if b1 == int(b1):
        ansa=a
        ansb=int(b1)
        break
print(ansa,ansb)


Measured memory_bytes: 79800
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    vector<int> a(n),v(n,0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v[a[i]]++;
    }
    sort(ALL(a));
    int ma = *max_element(ALL(a));
    int t = (ma + 1) / 2;
    for (int i = 0; i <= ma; i++) {
        if(i==t){
            if(ma%2==0){
                if(v[i]!=1){
                    puts("Impossible");
                    return 0;
                }
            }
            else{
                if(v[i]!=2){
                    puts("Impossible");
                    return 0;
                }
            }
        }
        else if(i < t){
            if(v[i]){
                puts("Impossible");
                return 0;
            }
        }
        else{
            if(v[i]<2){
                puts("Impossible");
                return 0;
            }
        }
    }
    puts("Possible");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			int year = scanner.nextInt();
			int month = scanner.nextInt();
			int day = scanner.nextInt();
			
			int[] era = {1868, 1912, 1926, 1989};
			String[] eraString = {"meiji", "taisho", "showa", "heisei"};
			
			int id=0;
			if(year < era[0])
			{
				id = 0;
			}
			else if(year == era[0])
			{
				if(month > 9 || (month==9 && day>7))
				{
					id = 1;
				}
			}
			else if(year < era[1])
			{
				id = 1;
			}
			else if(year == era[1])
			{
				id = 1;
				if(month > 7 || (month==7 && day>29))
				{
					id = 2;
				}
			}
			else if(year < era[2])
			{
				id = 2;
			}
			else if(year == era[2])
			{
				id = 2;
				if(month==12 && day>24)
				{
					id = 3;
				}
			}
			else if(year < era[3])
			{
				id = 3;
			}
			else if(year == era[3])
			{
				id = 3;
				if(month > 1 || (month==1 && day>7))
				{
					id = 4;
				}
			}
			else
			{
				id = 4;
			}
			
			String output;
			switch (id)
			{
				case 0:
					output = "pre-meiji";
					break;
	
				default:
					output = String.format("%1$s %2$d %3$d %4$d", eraString[id-1], year-era[id-1]+1, month, day);
					break;
			}			
			System.out.println(output);		
		}
	}
}

Measured memory_bytes: 26064
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

class UnionFind(object):
    def __init__(self, group_size):
        self.parent = [i for i in range(group_size + 1)]
        self.size = [1 for _ in range(group_size + 1)]
        self.rank = [0 for _ in range(group_size + 1)]
    
    # 要素の根を探しつつ大元に要素をつなぐ
    def find(self, n):
        if self.parent[n] == n:
            return n
        else:
            f = self.find(self.parent[n])
            self.parent[n] = f
            return f
    
    def isSame(self, n, m):
        if self.find(n) == self.find(m):
            return True
        else:
            return False
    
    def unite(self, u, v):
        x, y = self.find(u), self.find(v)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
            self.size[x] += self.size[y]
    
    def get_size(self, x):
        r = self.find(x)
        return self.size[r]

ans = [-1] * M
ans[M-1] = N*(N-1)//2
uf = UnionFind(N)

for i in reversed(range(1, M)):
    A, B = AB[i][0], AB[i][1]
    if uf.isSame(A, B):
        n = 0
    else:
        n = uf.get_size(A) * uf.get_size(B)
    uf.unite(AB[i][0], AB[i][1])
    ans[i-1] = ans[i] - n
    
for i in ans:
    print(i)

Measured memory_bytes: 35828
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;



int main(){
	
	int n; cin >> n;
	
	vector<int> a;
	set<int> st;
	
	for(int i=0; i<n; i++){
		int temp; cin >> temp;
		a.push_back(temp);
		st.insert(temp);
	}
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	for(auto x : st){
		int num = upper_bound(a.begin(), a.end(), x) - lower_bound(a.begin(), a.end(), x);
		if( num >= x ) ans += num - x;
		else ans += num;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
 
using namespace std;
const int maxn = 1e6+16;
int n,dp[maxn][2];
char s[maxn];
int main(){
	scanf("%d %s",&n,s+1);
	memset(dp,0x3f,sizeof(dp));
	dp[0][0] = 0;
	for(int i = 1;i <= n; ++i){
		if(s[i] == '#'){
			dp[i][1] = min(dp[i-1][1],dp[i-1][0]);
			dp[i][0] = min(dp[i-1][0],dp[i][0]) + 1;
		}
		else{
			dp[i][0] = min(dp[i][0],dp[i-1][0]);
			dp[i][1] = min(dp[i-1][1],dp[i-1][0]) + 1;
		}
	}
	cout << min(dp[n][0],dp[n][1]);
	return 0;
}

Measured memory_bytes: 8192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll X; cin>>X;
  ll ans=0;
  ans+=X/500*1000;
  X%=500;
  ans+=X/5*5;
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

int main()
{
	string s;
 	
  	cin >> s;
  	
  	int cnt =0;
  	for(int i = 0; i < s.length(); i++)
    {
      if(s[i] == 'o')cnt++;
    }

  	cout << (700+ 100*cnt) << endl;
  
  return 0;
}

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

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

    for (int x = 0; x <= N; x++)
    {
        for (int y = 0; y <= N-x; y++)
        {
            if(10000*x + 5000*y + 1000*(N-x-y) == Y){
                cout << x << " " << y << " " << (N-x-y) << endl;
                return 0;
            }
        }
        
    }
    
    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
            
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        
        double X = x2 - x1;
        double Y = y2 - y1;
        
        double S = Math.sqrt(X*X + Y*Y);
        
        System.out.println(S);
            
        sc.close();
    }
}


Measured memory_bytes: 27960
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

int main()
{
	string s1,s2,s3,result;
	cin>>s1>>s2>>s3;

	result+=toupper(s1[0]);
	result+=toupper(s2[0]);
	result+=toupper(s3[0]);

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

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

main(){
  int i,c0=0,n;
  string s;
  cin >> s;
  n=s.length();
  
  for(i=0;i<n;i++){
    if(s[i]=='0') c0++;
  }
  cout << 2*min(c0,n-c0) << endl;
}
  


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair

int q;
long long sumb;
long long suma;

pair<int, int> m;
set<pair<int, int> > s;
map<int, int> mp;

int main()
{
    cin >> q;
    for (int ii = 0; ii < q; ++ii)
    {
        int ty;
        cin >> ty;
        if (ty == 1)
        {
            int aa, b;
            cin >> aa >> b;
            pair<int, int> a = m_p(aa, ++mp[aa]);
            sumb += b;
            if (ii == 0)
            {
                m = a;
                s.insert(a);
            }
            else
            {
                s.insert(a);
                suma += abs(a.first - m.first);
                if (s.size() % 2 == 1)
                {
                    if (a > m)
                    {
                        set<pair<int, int> >::iterator it = s.upper_bound(m);
                        suma -= (it->first - m.first);
                        m = *it;
                    }
                }
                else
                {
                    if (a < m)
                    {
                        set<pair<int, int> >::iterator it = --s.lower_bound(m);
                        m = *it;
                    }
                }
            }
        }
        else
        {
            cout << m.first << ' ' << suma + sumb << endl;
        }
    }
    return 0;
}


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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int[] w = { 1, 5, 10, 50, 100, 500 };
		int sum = 0;
		for (int i = 0; i < 6; i++) {
			sum += w[i] * sc.nextInt();
		}
		System.out.println(sum >= 1000 ? 1 : 0);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(char[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

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

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

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}

Measured memory_bytes: 17324
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
// #define Kongxiangzhouye
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sc(x) scanf("%c",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define me(x,b) memset(x,b,sizeof(x))
#define pd(d) printf("%d\n",d);
#define plld(d) printf("%lld\n",d)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;


#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar (char ch){
	if(ch=='A')
		return 1;
	else if(ch=='C')
		return 2;
	else if(ch=='G')
		return 3;
	else if(ch=='T')
		return 4;
	else
		return 0;
}

ll getKey(char str[]){
	ll sum=0;
	ll p=1;
	for(int i=0;i<strlen(str);i++){
		sum=sum+p*(getChar(str[i]));
		p=p*5;
	}
	return sum;
}

int h1(int key){
	return key%M;
}
int h2(int key){
	return 1+(key%(M-1));
}

int find(char str[]){
	ll key;
	ll h;
	key=getKey(str);
	for(int i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
			return 1;
		else if(strlen(H[h])==0)
			return 0;
	}
	return 0;
}

int insert(char str[]){
	ll key,h;
	key=getKey(str);
	for(int i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)
			return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
}

int main()

{
	#ifdef Kongxiangzhouye
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	int i,n,h;
	char str[L],com[9];
	for(int i=0;i<M;i++)
		H[i][0]='\0';
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %s",com,str);
		if(com[0]=='i'){
			insert(str);
		}
		else {
			if(find(str))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}


	return 0;
}



Measured memory_bytes: 17572
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll l, r, d;
    cin>>l>>r>>d;
    ll ans = 0;
    for(int i = 0; i <= 1000; i++){
        if(d*i >= l && d*i <= r) ans++;
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3636
import sys
 
l1 = sys.stdin.readline()
l2 = sys.stdin.readline()
 
nums = [int(x) for x in l1.rstrip('\n').split(' ')]
l2 = int(l2)
 
out = max(nums)
 
for i in xrange(l2):
  out *= 2
print out + sum(nums) - max(nums)

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



int main(){
    int n ;
    cin >> n;
    int x[105];
    rep(i,n) cin >> x[i];
    ll min = 1000000;
    for(int p = 1; p <= 100; ++p) {
        int sum = 0;
        rep(i,n) sum += pow(x[i]-p, 2);
        if(min >= sum) min = sum;
    }
    cout << min;
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100010],mn;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	mn=a[n];
	for(int i=n;i>=1;i--){
		mn=min(a[i],mn);
		if(a[i]-mn>1){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
} 

Measured memory_bytes: 640
Option Infer On
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = CInt(ReadLine())
        Dim a As Integer() = New Integer(N - 1) {}

        For i = 0 To N - 1
            a(i) = CInt(ReadLine())
        Next

        Dim j = 1
        For i = 1 To N
            j = a(j - 1)
            If j = 2 Then
                WriteLine(i)
                Exit Sub
            End If
        Next

        WriteLine(-1)
    End Sub

End Module


Measured memory_bytes: 24792
#include <stdio.h>

int main()
{
  int stack[101] = {0};
  int n;
  int i = 0;

  while (scanf("%d", &n) != EOF) {

    if (n == 0){
      i--;
      printf("%d\n", stack[i]);
    }

    else {
      stack[i] = n;
      i++;
    }
  }

  return 0;
}

Measured memory_bytes: 596
//itp1_topic3_a
#include <bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int x, y;

    cin>>x>>y;
    if(x == 0 && y == 0) break;
    if(x > y) swap(x, y);
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}



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

int main() {
	int n,a,b;cin >> n;
	cin >> a>> b;
	int cnt_a =0;
	int cnt_b =0;
	int cnt_c =0;
	for(int i=0;i<n;++i) {
		int t;cin>>t;
		if(t<=a){
			++cnt_a;
		} else if(t>a && t<=b){
			++cnt_b;
		} else {
			++cnt_c;
		}
	}
	int out = min(cnt_a,cnt_b);
	out = min(out,cnt_c);
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &s, &k)

	ans := ""
	for _, r := range s {
		if r == rune(s[k-1]) {
			ans += string(r)
		} else {
			ans += "*"
		}
	}
	fmt.Println(ans)
}


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

int main() {
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if((j<a && i<b) || (j>=a && i>=b)) cout<<0;
      else cout<<1;
      if(j==w-1) cout<<endl;
    }
  }
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int cost(int a, int b, int c){
  int ret = 0;
  int aa = a % 5; a -= aa;
  int bb = b % 4; b -= bb;
  int cc = c % 3; c -= cc;
  ret += (int)(a * 380 * 4 / 5) + aa * 380;
  ret += (int)(b * 550 * 17/20) + bb * 550;
  ret += (int)(c * 850 * 22/25) + cc * 850;
  return ret;
}

int main(){
  int n;
  while(cin>>n, n){
    int ans = INT_MAX;
    n += 99;
    n /= 100;
    for(int i = 0; i < n + 25; i+=2){
      for(int j = 0; i + j < n + 25; j+=3){
        for(int k = 0; i + j + k < n + 25; k+=5){
          if(i + j + k == n)
            ans = min(ans, cost(i/2,j/3,k/5));
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, Q = mapint()
Cs = list(mapint())
LR = []
for i in range(Q):
    l, r = mapint()
    k = (r<<40)+(l<<20)+i
    LR.append(k)
LR.sort()
mask = (1<<20)-1
A = [0]*N

def add(A,a,w):#リストに値を追加する関数
    x = a
    while x <= N:
        A[x-1] += w
        x += x&(-x)

def sums(A,a):#k番目までの和
    x = a
    S = 0
    while x != 0:
        S += A[x-1]
        x -= x&(-x)
    return S

ans = [0]*Q
i = 0
last_appeared = [-1]*(N+1)
for k in LR:
    ans_idx = k&mask
    l = (k>>20)&mask
    r = (k>>40)
    while i<r:
        c = Cs[i]
        if last_appeared[c]==-1:
            last_appeared[c] = i+1
            add(A, i+1, 1)
        else:
            past = last_appeared[c]
            last_appeared[c] = i+1
            add(A, past, -1)
            add(A, i+1, 1)
        i += 1
    ans[ans_idx] = sums(A, r)-sums(A, l-1)
for a in ans:
    print(a)

Measured memory_bytes: 160928
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    int need_left = 0;
    int pointer = 0;
    
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '(') pointer++;
        else{
            if (pointer == 0) need_left++;
            else pointer--;
        }
    }
    
    int need_right = pointer;
    
    string res = "";
    for (int i = 0; i < need_left; ++i) res += '(';
    res += s;
    for (int i = 0; i < need_right; ++i) res += ')';
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.{PrintWriter, _}
import java.util
import java.util._


object Main {
  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      val a = in.nextInt
      val b = in.nextInt
      if (a + b < 10) {
        println(a + b)
      } else {
        println("error")
      }
    }
  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")


    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


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

#define	pb	push_back

using namespace std;

int main(){
	for(int plen,cnum,w,cspace;cin>>plen>>cnum>>w>>cspace,plen;){
		cin.ignore();

		vector<string> mul;
		for(string s;getline(cin,s),s!="?";){
			int len=s.length();
			if(len==0)	mul.pb("");
			for(int i=0;i<len;i+=w){
				if(w<len-i)	mul.pb(s.substr(i,w));
				else		mul.pb(s.substr(i));
			}
		}

		int m=mul.size();
		int pages=(m+(plen*cnum-1))/(plen*cnum);
		for(int i=0;i<pages;i++){
			int offset=i*plen*cnum;
			vector<string> pg(plen);
			if(i==pages-1){
				for(int j=offset;j<m;j++){
					pg[j%plen]+=mul[j];
					int padding=w-mul[j].length();
					pg[j%plen]+=string(padding,'.');
				}
				for(int j=m;j<offset+plen*cnum;j++){
					pg[j%plen]+=string(w,'.');
				}
			}
			else{
				for(int j=offset;j<offset+plen*cnum;j++){
					pg[j%plen]+=mul[j];
					int padding=w-mul[j].length();
					pg[j%plen]+=string(padding,'.');
				}
			}

			for(int i=0;i<plen;i++){
				for(int j=0;j<cnum;j++){
					if(j>0)	cout<<string(cspace,'.');
					cout<<pg[i].substr(w*j,w);
				}
				cout<<endl;
			}
			cout<<'#'<<endl;
		}

		cout<<'?'<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
from collections import deque

inf = float('inf')

n, m = map(int, input().split())

g = [set() for _ in range(n * 3)]
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].add(v + n)
    g[u + n].add(v + n * 2)
    g[u + n * 2].add(v)

s, t = map(int, input().split())
s -= 1
t -= 1

dq = deque()
dq.append(s)

dist = [inf] * (n * 3)
dist[s] = 0
while dq:
    v = dq.popleft()
    if v == t:
        break
    for u in g[v]:
        if dist[u] < inf: continue
        dq.append(u)
        dist[u] = dist[v] + 1

if dist[t] == inf:
    print(-1)
else:
    print(dist[t] // 3)


Measured memory_bytes: 93872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    vector<int> n(5);
    vector<int> diff(5);
    int max = 0;
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        cin >> n[i];
        diff[i] = 10 - n[i] % 10;
        if (diff[i] != 10) {
            n[i] = n[i] + diff[i];
            if (max < diff[i]) {
                max = diff[i];
            }
        }
        ans += n[i]; 
    }
    cout << ans - max << endl;
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 07.08.2020 23:44:09
**/

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

int main() {

    long long x;
    cin >> x;
    long long ans=(x/11)*2;

    if(x%11>6) ans+=2;
    else if(x%11>0) ans+=1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#ABC047b
import sys
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

w, h, n = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
square = np.zeros((h, w), dtype="int16")

for i in l:
    if (i[2] == 1):
        square[:, :i[0]] = 1
    elif (i[2] == 2):
        square[:, i[0]:] = 1
    elif (i[2] == 3):
        square[:i[1], :] = 1
    else:
        square[i[1]:, :] = 1
#print(square)
print(w*h-np.sum(square))


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

using namespace std;

#define INF 999999999

vector<pair<int, int> > rin[32][32];
int d[32][32];

queue<pair<int, int> > qu;

void search(pair<int, int> a){
	//cout << a.first << " " << a.second << " " << d[a.first][a.second] << endl;
	pair<int, int> b;
	for(int i=0;i<rin[a.first][a.second].size();i++){
		b.first = rin[a.first][a.second][i].first;
		b.second = rin[a.first][a.second][i].second;
		if(!d[b.first][b.second]){
			qu.push(b);
			d[b.first][b.second] = d[a.first][a.second] + 1;
		}
	}
	qu.pop();
	if(!qu.empty()) search(qu.front());
}

int main(){
	int i, j, k, l, w, h, ins;
	pair<int, int> s;
	while(1){
		cin >> w >> h;
		if(!w)break;
		for(i=0;i<=h+1;i++){
			for(j=0;j<=w+1;j++){
				d[i][j] = 0;
				rin[i][j].clear();
			}
		}
		
		for(i=1;i<=h-1;i++){
			for(j=1;j<=w-1;j++){
				cin >> ins;
				if(!ins){
					rin[i][j].push_back(make_pair(i,j+1));
					rin[i][j+1].push_back(make_pair(i,j));
				}
			}
			for(j=1;j<=w;j++){
				cin >> ins;
				if(!ins){
					rin[i+1][j].push_back(make_pair(i,j));
					rin[i][j].push_back(make_pair(i+1,j));
				}
			}
		}
		for(j=1;j<=w-1;j++){
			cin >> ins;
			if(!ins){
				rin[i][j].push_back(make_pair(i,j+1));
				rin[i][j+1].push_back(make_pair(i,j));
			}
		}
		/*
		for(i=0;i<=h+1;i++){
			for(j=0;j<=w+1;j++){
				cout << i << "," << j << ":";
				for(int z=0;z<rin[i][j].size();z++){
					 cout << rin[i][j][z].first << "," << rin[i][j][z].second << " ";
				}
				cout << endl;
			}
		}
		*/
		//cout << "OK" << endl;
		s.first = 1;
		s.second = 1;
		d[1][1] = 1;
		qu.push(s);
		search(s);
		cout << d[h][w] << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int pri=12;
	for(long long int i=1;i<=(long long int)sqrt(n);i++){
		if(n%i==0){
			//cout<<"fsddfsafasa "<<i<<endl;
			long long int ans=0;
			long long int coun=0;
			long long int temp=i;
			while(temp>0){
				coun++;
				temp/=10;
			}
			ans=max(coun,ans);
			coun=0;
			//cout<<ans<<endl;
			temp=n/i;
			while(temp>0){
				coun++;
				temp/=10;
			}
			ans=max(coun,ans);//cout<<ans<<endl;
			//cout<<endl;
			pri=min(pri,ans);
		}
	}
	cout<<pri<<endl;
	return 0;
}

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

int fr[100 + 10] = { 0 };

int main()
{
	int n, m;
	int target[100 + 10];

	int a;
	int i,j;

	cin >> n >> m;

	for (i = 0; i < m; i++)
	{
		cin >> target[i];
	}

	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
		{

			cin >> a;

			if (a == target[i])
			{
				fr[j]++;
			}
			else
			{
				fr[ target[i]-1 ]++;
			}
		}
	}
	
	for (i = 0; i < n; i++)
	{
		cout << fr[i] << endl;

	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
pair<int,int> BA[200000];

int main(){
    cin>>N;
    rep(i,N) cin>>BA[i].second>>BA[i].first;

    sort(BA,BA+N);

    int now=0;
    rep(i,N){
        now+=BA[i].second;
        if(now>BA[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e9;

int main() {
    int n; cin >> n;
    bool flag = true;

    for (int i = 0; i < n; i ++) {
        int a; cin >> a;
        if (a%2 == 1) {
            flag = false;
            break;
        }
    }
    if (flag) cout << "second" << endl;
    else cout << "first" << endl;
}

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

#define endl "\n"
#define ll long long int
#define f(i,st,ed) for(ll i=st;i<ed;i++)
#define fr(i,ed,st) for(ll i=ed;i>=st;i--)
#define vv vector<ll>
#define all(v) v.begin(),v.end() 
#define pb push_back
#define pp pair<ll,ll>
#define gv(v,s,e) f(i,s,e){ ll x; cin >> x; v.pb(x);}
#define pv(v,s,e) f(i,s,e){cout << v[i] << " ";}
#define MOD 1000000007
#define debug(x) cout << x << endl;


void yes(){
    cout << "YES" << endl;
}

void no(){
    cout << "NO" << endl;
}

ll powmod(ll x, ll y, ll mod)
{
    ll ans=1;

    while(y)
    {
        if(y%2==1)
        {
            ans = (ans*x)%mod;
        }

        x = (x*x)%mod;
        y/=2;
    }

    return ans;
}

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

        ll n;
        cin >> n;

        vv v;
        gv(v,0,n);

        ll dp[n+5];
        dp[0]=0;
        dp[1]=abs(v[1]-v[0]);

        f(i,2,n)
        {
            dp[i] = min(dp[i-2]+abs(v[i]-v[i-2]), dp[i-1]+abs(v[i]-v[i-1]));
        }

        cout << dp[n-1] << endl;

    return 0;
}



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

int main() {
	int64_t n, l; cin >> n >> l;
	int64_t a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	int id = -1;
	for(int i = 1; i < n; ++i) {
		if(a[i - 1] + a[i] >= l) {
			id = i;
		}
	}
	if(id == -1) {
		cout << "Impossible" << '\n';
		return 0;
	}
	cout << "Possible" << '\n';
	for(int i = 1; i < id; ++i) {
		cout << i << '\n';
	}
	for(int i = n - 1; i > id; --i) {
		cout << i << '\n';
	}
	cout << id << '\n';
	return 0;
}


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

int a,b,c;
int cnt[10];

int main()
{
	cin>>a>>b>>c;
	cnt[a]++;cnt[b]++;cnt[c]++;
	if(cnt[5]==2&&cnt[7]==1) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
py = []
for _ in range(M):
    py.append(list(map(int, input().split())))
d = {}
now = 0
num = 0
for p, y in sorted(py):
    if now != p:
        now = p
        num = 1
    d[(p, y)] = num
    num += 1
for p, y in py:
    print('{:06d}{:06d}'.format(p, d[(p, y)]))

Measured memory_bytes: 45836
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

int main(){

   int h,w,n;

   cin >> h >> w >> n;
   int x = max(h,w);

   if(n%x) cout << n/x+1;
   else cout << n/x;
}


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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while(b <= a && k > 0) {
        b *= 2;
        k--;
    }
    while(c <= b && k > 0) {
        c *= 2;
        k--;
    }

    if(c > b && b > a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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

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


Measured memory_bytes: 3592
#include <queue>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 1e3 + 7;
const int MOD = 1e9 + 7;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int n, m;
bool a[MAXN][MAXN];
int dp[MAXN][MAXN];
char str[MAXN];

inline void solve() {
	n = read<int>(); m = read<int>();
	for(int i = 1; i <= n; ++i) {
		scanf("%s", str + 1);
		for(int j = 1; j <= m; ++j) a[i][j] = (str[j] == '.');
	}

	dp[1][1] = 1; //a[1][1] = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) {
			if(a[i][j]) (dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % MOD) %= MOD;
		}
	printf("%d\n", dp[n][m]);
}

int main() {

	solve();

	return 0;
}



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

const int MAXK = 1e5 + 10;
const int MAXN = 1e3 + 10;

int A[MAXN],dp[MAXK],N,K;

int solve(int k){

	if(dp[k] != -1) return dp[k];

	if(k == 0) return dp[k] = 0;

	int ans = 0;
	for(int i = 1;i<=N;i++){
		if(A[i] > k) continue;
		if(solve(k - A[i]) == 0){
			ans = 1;
			break;
		}
	}

	return dp[k] = ans;

}

int main(){

	memset(dp,-1,sizeof(dp));
	cin >> N >> K;
	for(int i = 1;i<=N;i++){
		cin >> A[i];
	}

	if(solve(K)) cout<<"First\n";
	else cout<<"Second\n";

	return 0;

}

Measured memory_bytes: 7076
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def satisfaction(d, last, c):
    res = 0
    for i in range(26):
        res += c[i] * (d - last[i])
    return res


def main():
    d = I()
    c = LI()
    s = LIR(d)
    last = [0] * 26
    out = []
    satis = 0
    for day in range(d):
        # 貪欲法 : day 日目終了時点で満足度が最も大きくなるようなコンテスト k を選ぶ
        today_satises = []
        for k in range(26):
            last[k] = day + 1
            today_satises.append(s[day][k] - satisfaction(day + 1, last, c))
            last[k] -= day + 1  # もとに戻す
        satis += max(today_satises)
        contenst = today_satises.index(max(today_satises))
        last[contenst] = day + 1
        out.append(contenst + 1)

    print(*out, sep='\n')


main()


Measured memory_bytes: 9516
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P;

P suindex[1000001];
int cave[3000][3000];//始点は(550,550)
bool sosu[1000001];

void hurui()
{
	fill(sosu,sosu+1000001,true);
	sosu[0]=false;
	sosu[1]=false;
	for(int i=2;i<1000001;i++)
	{
		if(sosu[i])
		{
			for(int j=i*2;j<1000001;j+=i)
				sosu[j]=false;
		}
	}
	return;
}

//洞窟を作る
void setup()
{
	fill(cave[0],cave[3000],1e8-1);
	int hen=1;
	int adir[]={0,-1,0,1};
	int bdir[]={1,0,-1,0};
	int dirin=0;
	int a=1500;
	int b=1500;
	int num=1;
	int cnt=0;
	cave[a][b]=num;
	suindex[num]=P(a,b);
	num++;
	while(num<1000001)
	{
		for(int i=0;i<hen;i++)
		{
			a+=adir[dirin];
			b+=bdir[dirin];
			suindex[num]=P(a,b);
			cave[a][b]=num;
			num++;
		}
		dirin++;
		dirin%=4;
		cnt++;
		if(cnt==2)
		{
			hen++;
			cnt=0;
		}
	}
	return;
}

P dp[3000][3000];

P solve(int m,int st)
{
	int a=suindex[st].first;
	int b=suindex[st].second;
	P ret=P(0,0);
	fill(dp[0],dp[3000],P(-1,0));
	//初期位置
	if(sosu[st])
		dp[a][b]=P(1,st);
	else
		dp[a][b]=P(0,0);
	//ここからdp
	//一段ずつ調べる
	for(int i=a;i<3000;i++)
	{
		for(int j=0;j<3000;j++)
		{
			if(dp[i][j].first==-1)
				continue;
			
			//更新
			//左下
			//cerr<<cave[i][j]<<endl;
			//cerr<<cave[i+1][j-1]<<" "<<cave[i+1][j]<<" "<<cave[i+1][j+1]<<endl;
			int num=cave[i+1][j-1];
			if(num>m)
			{
				ret=max(ret,dp[i][j]);
			}else{
				if(sosu[num])
					dp[i+1][j-1]=max(dp[i+1][j-1],P(dp[i][j].first+1,num));
				else
					dp[i+1][j-1]=max(dp[i+1][j-1],dp[i][j]);
			}
			//下
			num=cave[i+1][j];
			if(num>m)
			{
				ret=max(ret,dp[i][j]);
			}else{
				if(sosu[num])
					dp[i+1][j]=max(dp[i+1][j],P(dp[i][j].first+1,num));
				else
					dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			}
			//右下
			num=cave[i+1][j+1];
			if(num>m)
			{
				ret=max(ret,dp[i][j]);
			}else{
				if(sosu[num])
					dp[i+1][j+1]=max(dp[i+1][j+1],P(dp[i][j].first+1,num));
				else
					dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]);
			}
		}
	}
	//ここまでdp
	return ret;
}

int main()
{
	hurui();
	//cerr<<"hurui"<<endl;
	setup();
	//cerr<<"setup"<<endl;
	while(1)
	{
		int m,n;
		cin>>m>>n;
		if(n==0)
			break;
		P ans=solve(m,n);
		cout<<ans.first<<" "<<ans.second<<endl;
	}
	return 0;
}


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

const int a=4;

bool Calc(string str)
{
  int sum=0;
  int n=str.size();
  for(int i=0;i<n;i++)
  {
    char c=str.at(i);
    char number=(int)c-48;
    if(i==0)
      sum+=number;
    else
    {
      if(str.at(i-1)=='+')
      {
        sum+=number;
        continue;
      }
      if(str.at(i-1)=='-')
      {
        sum-=number;
        continue;
      }
    }
  }  
  return (sum==7);
}

  
void Make(char number[],string &str,int i)
{
  if(i==a)
  {
    if(Calc(str))
    {
      cout<<str<<"=7"<<endl;
      exit(0);
    }
    return;
  }
  
  if(i==0)
  {
    str.push_back(number[i/2]);
    Make(number,str,i+1);
  }
  else
  {
    for(int j=0;j<2;j++)
    {
      if(j==0)
      {
        str.push_back('+');
        str.push_back(number[i]);
        Make(number,str,i+1);
        str.pop_back();
        str.pop_back();
      }
      else
      {
        str.push_back('-');
        str.push_back(number[i]);
        Make(number,str,i+1);
        str.pop_back();
        str.pop_back();
      }
    }
  }
}
  
int main()
{
  char number[a];
  for(int i=0;i<a;i++)
    cin>>number[i];
  string str;
  Make(number,str,0);
}


  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	bool ans=0;
	for(int i=0,cnt=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if (a==b)
			cnt++;
		else
			cnt=0;
		if (cnt==3)
		{
			ans=true;
			break;
		}
	}
	cout<<(ans?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3672
n = gets.chomp.to_i
tp = 0
xp = 0
yp = 0
ans = "Yes"
n.times do
  t, x, y = gets.chomp.split.map(&:to_i)
  unless t-tp >= (x-xp).abs + (y-yp).abs && (t-tp + x-xp + y-yp).even?
    ans = "No"
    break
  end
  tp = t
  xp = x
  yp = y
end
puts ans

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<double> v(n);
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i)>>s.at(i);
  }
  double sum=0;
  for(int j=0;j<n;j++){
    if(s.at(j)=="JPY"){
      sum+=v.at(j);
    }
    else{
      sum+=v.at(j)*380000.0;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 256